Here's a bare-bones implementation. It uses a template file in the current directory called
template.org and substitutes name, phone, amount into placeholders in the template (%NAME%, %PHONE%, %AMOUNT% resp.) It then saves the resulting org-mode file in
/tmp/munged-name.org where the munged-name is just the name variable with spaces replaced by dashes. It then runs the
org-latex-export-to-pdf function to process the file to PDF (in
/tmp/munged-name.pdf). The function is bound to
F10 z (i.e. function key
F10 followed by letter
z) although you can bind it to whatever you want - see the code for details.
The lisp code:
(defun fill-template-and-export (name phone amt)
(interactive "sName: \nsPhone: \nsAmount: ")
(while (re-search-forward "%NAME%" nil t)
(while (re-search-forward "%PHONE%" nil t)
(while (re-search-forward "%AMOUNT%" nil t)
(write-file (format "/tmp/%s.org" (replace-regexp-in-string " " "-" name)))
;;; define the function key F10 as a prefix key
(setq f10-keymap (make-sparse-keymap))
(define-key global-map [f10] f10-keymap)
;;; F10 z calls the function above
(define-key f10-keymap "z" 'fill-template-and-export)
The template file:
#+OPTIONS: toc:nil num:nil
We would appreciate your immediate attention to this invoice.
You can of course tweak it if you don't like the design decisions I made.