Form2PDF is a standalone UNIX PDF utility for converting text files to PDF, optionally adding a background image (a form) in the process. It can also send the resulting PDF file as an e-mail with the PDF file as an attachment. This is done through a built-in SMTP client and it does not depend on any other components.
It can be used to add a nice look-and-feel to invoices, confirmations, license keys and any other documents that are generated in a text environment and sent out to customers or other recipients.
Form2PDF is compatible with Acrobat Reader 4 and later.
Licensed mode vs demo mode
Form2PDF is licensed per server locked to the hostid. The license key is added to the configuration file /etc/form2pdf/form2pdf.cfg. If a license is missing Form2PDF will run in demo mode and random lines in the output will be replaced with an informational text.
The background image
The background image must be in PNG, JPEG or GIF format. It will be scaled to the page size regardless of the actual image size. It is therefore important that the image has the same proportions as the page, otherwise it will be distorted. The default page size is 842 x 595 pixels (A4, 72 dpi).
SmartDraw is a software application that can be used to easily create forms and save them in PNG-format.
Form2PDF supports form-feeds (Ctrl-L or character 0x0c) in the text. When a form-feed is encountered the current page will be finalized and a new page created.
There are 14 built-in fonts in the PDF format which can always be used. The default font is a fixed space font called “Courier”. Please note that font names are case-sensitive.
The following fonts are available:
- Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique
- Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique
- Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic
- Symbol, ZapfDingbats
Form2PDF takes a number of parameters on the command-line. Most of these parameters can also be defined in a configuration file. An input and output file must be specified, all other parameters are optional. Run “form2pdf –help” for more information about available parameters.
Convert a text file to PDF
form2pdf data.txt output.pdf
Convert a text file to PDF adding a background image
form2pdf –bgimage bg.png data.txt output.pdf
Convert a text file to PDF adding a background image to page 1 only
form2pdf –bgimage bg.png –bgimagepages 1 data.txt output.pdf
Convert a text file to PDF (read data from stdin, write to stdout)
cat data.txt | form2pdf –bgimage bg.png – – >output.pdf
Convert a text file to PDF and send it as e-mail
form2pdf –bgimage bg.png –mailto firstname.lastname@example.org –sender \
email@example.com data.txt output.pdf
For more information check the User’s Guide.