I'd like to elaborate my proof of concept so that I can be confident with selected tools/packages for this task before I start implementing it.
Scenario. I have several documents (each document has its own template) and in order to provide a user friendly document creation process, I needed to include some pdf forms in certain documents so that end user gets just one pdf, not bunch of pdfs. Number of included pdfs is most of the time just one, but there are some occasions where more than one included pdf are necessary.
Top-level workflow. I have a web application that generates html code based on user input. I use Pandoc with Latex template to which I pass required variables. Pandoc generates pdf output for end users (pdflatex). This html -> Pandoc/Latex -> pdf workflow works well and it is out of the scope regarding those questions below, just for your information.
Included pdfs. These pdfs may or may not be filled as forms. Each pdf equals one page.
My initial concept.
Include pdf as background image using package pdfpages
\documentclass[finnish,a4paper,11pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[final]{pdfpages}
\usepackage{graphicx}
\begin{document}
\setboolean{@twoside}{false}
\includepdf[pages=-]{file.pdf}
\end{document}
Since I do all the form filling in automated manner (form data as pandoc template variables), I ignore form filling features and just write text to absolute coordinates.
Quickly add text to existing pdf files / fill forms
Questions.
Q1. Any other tools that you might consider for this task?
Q2. Some examples that you'd recommend?
Q3. Better way to pass variables to forms than Pandoc command line variables?
Q4. General comments and suggestions for this concept are welcome.
UPDATE.
I made a test document that includes a pdf form, based on the method presented below. I passed the form data via Pandoc variables to Latex template and I can live with this method since everything happens automatically, once programmed. However, this leads to another question that follows
Q5. Since there are number of possible forms to be included based on the end user's selections in web application, I'm forced to make this kind of "if" structure into my template header
\ifthenelse{\equal{\detokenize{$headertitle$}}{\detokenize{myformA}}}
{ % load packages, make new commands to set coordinates for form fields, ... }
and similar structure in templates document part
\ifthenelse{\equal{\detokenize{$headertitle$}}{\detokenize{myformA}}}
{ % run those new commands based on Pandoc variables }
When the number of the possible forms grows, my template size grows accordingly and as a programmer (but as a Latex newbie) I'm a bit concerned if this is viable solution to add everything in one template file. So, I'm asking if there is a better way organizing this kind of code like in sub-templates or alike?
I updated my own answer below with new example code.
\parbox, etc. – Steven B. Segletes Jan 04 '15 at 20:51