2

I have a word document that I use for a mail merge which is a template of a certificate. We have a excel file it pulls in and adds all of the information to it.

I'm planing on making this more streamlined and dynamic. I have all the data in a SQL database that I will be using as the content. However, I now need to add this data to the template and create a PDF of it.

The certificate has images etc so it would be a little difficult to try and re-create that in HTML. Any suggestions of being able to dynamically create a PDF and pass the contents / coordinates along with the information to have it places in the correct areas?

1

If you know somewhat PHP you can use mPdf or tcPdf.

Here is a comparison with code samples.

0

You have a couple of options in Python, in either case you can query your SQL database from within python to get your values, (there are built in libraries or several plugin libraries for this).

Once you have your data you can either output to markdown, (including markers of where the images go), and then convert to pdf using pandoc or use libraries such as reportlab, or possibly its paid for RML variant, or one of several other python pdf libraries.

Report lab allows direct generation of pdf files including embedding images at specified locations on the page. (If you are using images that are in formats other than jpeg you will also need the python image library, (PIL), installed).

See Mouse Vs. Python for a nice tutorial.

0

If the template approach suits you, you could probably re-use those templates and use Open Office / Libre Office to automate the loading of the template, population and PDF output using their APIs. JODReports (opensource) and Docmosis (commercial) are build on that technology to do exactly the mail-merge type of thing. Please note I work for Docmosis.

All of these technologies can be driven from PHP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.