Apr 14, 2021 Replies: 4 We had a client that insisted on using a specific font in reports - we initially tried PDFjet but it was not clear if the original library which dates back to 2014 needed work and anyway we did not feel like forking out $295 to try (open source ver. is limited). So we came up with this free solution using https://wkhtmltopdf.org/ and https://github.com/janl/mustache.js/ , no need for a http server as it executes locally (command line) Install instuctions : 1) Install wkhtmltopdf on your system https://wkhtmltopdf.org/downloads.html 2) Make a folder called reports and put in the files included in the report folder in the zip 3) Modify paths in program to suit (specifically path to wkhtmltopdf "c:\program files\wkhtmltopdf\bin\wkhtmltopdf.exe") You will need to activate the jShell, Json and Javaobject libraries. Json data is created in the program and exported to render.js , report.html is the report that you can modify to suit json data using mustache.js template engine rules. Hope it's useful to someone, feel free to modify and make it neater/better. Attachments pdfreports.zip pdfreports.zip 158.2 KB · Views: 872 Click to expand...
We had a client that insisted on using a specific font in reports - we initially tried PDFjet but it was not clear if the original library which dates back to 2014 needed work and anyway we did not feel like forking out $295 to try (open source ver. is limited). So we came up with this free solution using https://wkhtmltopdf.org/ and https://github.com/janl/mustache.js/ , no need for a http server as it executes locally (command line) Install instuctions : 1) Install wkhtmltopdf on your system https://wkhtmltopdf.org/downloads.html 2) Make a folder called reports and put in the files included in the report folder in the zip 3) Modify paths in program to suit (specifically path to wkhtmltopdf "c:\program files\wkhtmltopdf\bin\wkhtmltopdf.exe") You will need to activate the jShell, Json and Javaobject libraries. Json data is created in the program and exported to render.js , report.html is the report that you can modify to suit json data using mustache.js template engine rules. Hope it's useful to someone, feel free to modify and make it neater/better.
Q Quandalle Member Licensed User Apr 14, 2021 #2 Have you considered using Apache PDFBox? It allows you to specify fonts when generating a pdf.
A andrewmp Member Licensed User Longtime User Apr 14, 2021 #3 Briefly , they seem to be transitioning from 2.0 to 3.0 and examples are lacking for the moment.
A andrewmp Member Licensed User Longtime User Apr 20, 2021 #5 The easy way is to add --footer-center [page]/[topage] to the command line of wkhtmltopdf. The hard way is to use a html footer file using --footer-html command. You'll find many examples if you google wkhtmltopdf , here is an example https://stackoverflow.com/questions...ers-in-pdf-generated-by-html-with-wkhtmltopdf
The easy way is to add --footer-center [page]/[topage] to the command line of wkhtmltopdf. The hard way is to use a html footer file using --footer-html command. You'll find many examples if you google wkhtmltopdf , here is an example https://stackoverflow.com/questions...ers-in-pdf-generated-by-html-with-wkhtmltopdf