3. CONTEXT
• Inherited Django + Cordova mobile app
• Mobile app sends data to Django app
• Invoice generated in PDF format
4. CONSTRAINTS
• Mobile app used once every sales cycle
• Invoices look totally different each sales cycle
• Client of client signs off on the invoice, we’re not allowed to change
how it looks
• Can’t standardise… customise every sales cycle
9. LIBREOFFICE
• Step 1: Convert the form into an image, and make that the
background of ODT document
• Step 2: Put in named fields and/or tables.
• Step 3: Use UNO and unotools to fill them in. For checkboxes,
somehow just put in a unicode check character into the right
field/table cell
• Step 4: Convert to PDF
10. PROBLEMS
• Generated invoice is in lower quality (compression) — client won’t
be happy
• Getting anything to align properly on LibreOffice is impossible
• Super annoying to do… we have 12 different invoices
• Heaps of problems getting UNO to work on later versions of
LibreOffice
13. PROBLEMS
• Couldn’t find a way to make the HTML/CSS/Fonts/etc look like the
invoice.
• Would have been nice otherwise
• Could also consider RML/ReportLab
16. FDF
• Basically, you can merge an FDF with a PDF form to get a filled-in
PDF form
• Libraries like fdfgen (https://github.com/ccnmtl/fdfgen) allow you to
generate FDF files from a Python dict
• You can use something called PDFtk to do the merging
18. PYPDFTK
• Tried out a library called PyPDFtk
(https://github.com/revolunet/pypdftk)
• It was great!
• Successfully filled in text fields
• Successfully selected radio buttons
• Successfully checked checkboxes
• ….Oh that’s right, we need a signature. Wait, image fields don’t
work!
19.
20. IMAGES IN PDF
• It’s possible.
• Convert an image into PDF, making sure it’s positioned
appropriately
• Merge two pdfs together
• Luckily, I don’t have to implement this myself.