At my current job me and the rest of the staff that work in my area are uisng a lot of files that when opened look like PDF files but there not. They're actually .exe files and the the program that opens them is called Omni Form Mailable Filler. I've already touched base with that company and they don't support that program anymore. When we use the files we are always having to fill in a lot of the same information over and over through 6 or more files. I'd like to be able to write a small simple GUI program that would allow us to enter all relevant informationg once and have the program create all the needed forms. So I have two objectives.
1: I need to be able to create PDF files taht look like the Omni Form files. So what I need is a recomendation on a good program for PDF file creation, preferably on Linux.
2: A recomendaiton on a good python library for writting to and filling in info on PDF files.

Thanks for any and all replies.

Dani AI

Generated

Quick expert summary and a practical path forward for : the .exe/OmniForm artifacts should be treated as either (A) containers that happen to include a PDF-like view, or (B) proprietary interactive packages that need to be re-created as standard PDFs. Two pragmatic routes minimize friction and long-term maintenance: try to extract a true PDF from the .exe (fast win), otherwise re-create a set of standard AcroForm PDFs on Linux and drive them from one Python GUI/data layer.

Suggested extraction checks and fallbacks (fast diagnostics): inspect the file bytes for the PDF header string "%PDF-"; try opening the .exe as an archive (some installers/resource bundles expose embedded files); on Windows inspect resources if possible. If a printable view exists, print to PDF (virtual PDF printer) and use that as the template. If extraction fails or the embedded format is nonstandard, recreate templates in a document tool (LibreOffice, LaTeX/html) as and mentioned, or generate them programmatically (ReportLab as noted by ).

Recommended Linux + Python workflow: design templates with named fields (consistent names across forms), then populate them from a single Python GUI (Tkinter or PySimpleGUI for simplicity). For filling, common approaches are:

  • Programmatically set form field values (libraries: pdfrw or pypdf/PyPDF2) and write a new PDF.
  • Or generate an overlay with ReportLab and merge it (useful to avoid missing appearance streams).
  • Optionally use pdftk or flattening to bake values into page content.

Short pdfrw example (fill a template by field name):

from pdfrw import PdfReader, PdfWriter, PdfDict

ANNOT_KEY = '/Annots'
ANNOT_FIELD_KEY = '/T'
SUBTYPE_KEY = '/Subtype'
WIDGET_SUBTYPE_KEY = '/Widget'

def fill_pdf(template_path, output_path, data):
    pdf = PdfReader(template_path)
    for page in pdf.pages:
        annots = page.get(ANNOT_KEY, [])
        for annot in annots:
            if annot.get(SUBTYPE_KEY) == WIDGET_SUBTYPE_KEY and annot.get(ANNOT_FIELD_KEY):
                name = annot[ANNOT_FIELD_KEY][1:-1]
                if name in data:
                    annot.update(PdfDict(V='({})'.format(data[name])))
    PdfWriter().write(output_path, pdf)

Caveats: checkboxes/radio buttons require the correct on/off names, and many viewers need appearance streams or flattening to render programmatic values—overlay+flatten or regenerate appearances if values are invisible. Combining a simple Tkinter front end (one data entry per job) with a pdfrw/pypdf filling step and a final flattening step will meet the original goal of entering data once and producing many filled forms.

Recommended Answers

All 6 Replies

Did you google for pdf file format?

But ... since the software you were using is NOT supported any longer ...
why not write your own data input forms?

From my experience, it is usually easier to create pdf from another format, such as latex or rst or doconce or whatever. I never created a pdf file with forms because this seems to be very specific to adobe software.

Apparently, there is a way to create pdf forms with pdflatex by using a latex package named hyperref. Here is a tutorial Click Here. If it works, you could create a template for python (with mako or ninja ...) which would output a latex file with the forms filled, then process this through pdflatex.

Same here. I usually write it in Postscript and convert it, or when it is simple, do it in LibreOffice and save the file as a PDF.

Note that libreoffice can also convert files from the command line using a syntax such as

soffice --headless -env:UserInstallation="file:///home/user/.libreoffice-alt" --convert-to pdf[:filter] --outdir "/tmp" myfile.odt

Edit: different filter parameter are possible, such as writer8 for example.

I discovered by ixquick(ing) that LibreOffice can create pdf forms too. It seems quite plausible to me that python can be used to fill the forms by altering the opendocument file.

Edit: from what I read elsewhere, some html to pdf converters such as wkhtmltopdf (install with apt-get) can also be used to convert html forms to pdf forms. It means that you could perhaps write your files in html (and style them with css).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.