Frequently Asked Questions
Commercial FAQ | Technical FAQ
Contents
- Creating a landscape PDF document
- Creating a PDF with different page sizes for different pages
- How to print barcodes
- Sending HTML e-mail
- Form2PDF and Unicode
Creating a landscape PDF document
Default values in PDF for page height and page width are for A4 portrait. However, by simply switching the width and height it is possible to create a landscape document instead.
form2pdf --pageheight 595 --pagewidth 842 data.txt myfile.pdf
Creating a PDF with different page sizes for different pages
Starting with Form2PDF 1.7 it is possible to merge generated data with an existing PDF file. This also enables you to generate a document with different page sizes for different pages.
We start with the first page, the cover page, which will default to A4 portrait:
form2pdf first.txt first.pdf
Then we generate more pages from "data.txt" as A4 landscape, append them to "first.pdf" and put the resulting PDF in "final.pdf"
form2pdf --pageheight 595 --pagewidth 842 first.pdf data.txt final.pdf
How to print barcodes
The currently supported encodings are "code 39" and "code 128".- Find a truetype font for the barcode (there are several free and commercial available), and make sure it can be found by form2pdf by copying them to the directory given by the --fontdir parameter.
- Surrond the barcode value with the two tags "font" and "barcode", selecting the font name and encoding.
Example:
<font name="MW6Code128M">
<barcode encoding="code128">Code 128</barcode></font>
<font name="IDAutomationHC39M">
<barcode encoding="code39">12345ABCDE/</barcode></font>
Run form2pdf with the --xml flag to enable the XML parsing.
Sending HTML e-mail
Form2PDF 3.2 can use input files in HTML format.Example:
form2pdf --sender john@example.com --subject "This is the subject"
--mailto joe@example.com --mailonly test.html
test.html:
<html>
<head>
<style type="text/css">
<!--
body, input, table {
font-family: Verdana;
font-size: x-small;
}
-->
</style>
</head>
<body>
<h1>This is our header</h1>
<p>
...and this is the e-mail body
</p>
<p>
<strong>Some "strong" text...</strong>
</p>
<p style="color: red;">
...and some red text...
</p>
</body>
</html>
If you need to use a different encoding/charset than the default, you can specify that as a modifier before the filename. Example when file is in "utf-8":
form2pdf --sender john@example.com --subject "This is the subject"
--mailto joe@example.com --mailonly utf-8:test.html
Form2PDF and Unicode
Form2PDF supports conversion of Unicode characters into PDF provided that a font is used that includes the glyphs (characters) used. The PDF built-in fonts only contains a subset of glyphs and therefore an external true-type font may be necessary.Example:
form2pdf --fontname Georgia --utf8 polish.txt polish.pdf
where polish.txt is a text file containing national characters from Poland in utf-8 encoding, and the Georgia font is made available to Form2PDF by copying georgia.ttf to /etc/form2pdf/fonts.