Hello...I've created a HTML report using HTMLReportGenerator/HTML Writer and am trying to write this report to a pdf but have not been successful. I've tried connecting both a pdf FeatureWriter and a PDF Writer to the HTMLReportGenerator output and do get a pdf file created but it's blank. Thanks.
The HTMLReportGenerator will generate a complete HTML page which can be viewed in a web browser (there's an HTML writer you can use for that), if you output that to PDF you'll indeed get nothing. This is because they're two completely different formats.
If you want to generate PDF reports you can use the PDFPageFormatter and PDFStyler although it'll most likely take a bit more effort than the HTMLReportGenerator to get nice output. Alternatively you can use a PDF printer driver and print the HTML report to PDF out of your web browser. Hope this helps.
Thanks @redgeographics. I was hoping I could simply take the HTML report I've created and transform it into a pdf version; however, I guess this is not possible.
Thanks @redgeographics. I was hoping I could simply take the HTML report I've created and transform it into a pdf version; however, I guess this is not possible.
Note that we DO want to be able to do exactly what @aviveiro wants eventually. If anyone has any good suggestions for HTML->PDF converters...I'm all ears.
Note that we DO want to be able to do exactly what @aviveiro wants eventually. If anyone has any good suggestions for HTML->PDF converters...I'm all ears.
Okay, I found https://pypi.python.org/pypi/pdfkit/0.5.0 and we'll give that a spin at Safe to see what it might do for us, but if someone out there has a good python install and wants to try, do let us know your results.
Hi @aviveiro,
I use the following tool to convert HTML to PDF.
The tool allows you to include header and footers and a lot more:
Good luck!
Okay, I found https://pypi.python.org/pypi/pdfkit/0.5.0 and we'll give that a spin at Safe to see what it might do for us, but if someone out there has a good python install and wants to try, do let us know your results.
Maybe you can also check the next tool?
This is one I like a lot:
For now, instead of generating the HTML report, maybe try a custom transformer called TableAdder. This will turn a set of attributes into a table of vector data/outlines that you could indeed write to PDF.
I just tried using http://wkhtmltopdf.org/ but it doesn't handle css. I have even tried downloading the web page locally and made sure any images and css files were also available locally (when opened in a browser, the locally saved page loads and renders properly). However when I use the command line option to print to pdf, it errors on any links to css etc., even though they are not locked in any way. So the printed result doesn't look like the original page.
I also tried printing to pdf using Chrome's headless mode but the problem I'm having is that the original URL of the pages I want to print is behind a login (if opened via browser after signing in, the persistent cookie allows you to keep opening pages). However in headless mode, I cannot find info. on how to load the session cookie so when I try to print, I get the login page instead.
If anyone has any other potential solution, I would love to hear about it! I really wish I could take html and convert to pdf in FME.
Hi,
Has anyone found a solution to this?
I'm trying to create a PDF from a nicely formatted report that has been created using the HTML Report Generator.
Thanks,
David.
Hi,
Has anyone found a solution to this?
I'm trying to create a PDF from a nicely formatted report that has been created using the HTML Report Generator.
Thanks,
David.
I've had success before in using the custom transformer HTML2PDFConverter that uses the WKHTMLTOPDF executable file that requires you to set the executable path within the transformer. In my workspace I am creating an HTML table with some other elements in the HTMLReportGenerator, then passing this html to the HTML2PDFConverter transformer to generate the PDF.
Download WKHTMLTOPDF here: wkhtmltopdf