That`s kinda tricky.
Firstly, you should download the tool to be able to use this transformer https://wkhtmltopdf.org/downloads.html . This tool is not supported by Safe Software, it is a third party transformer.
1. Use FeatureWriter to create the html files
2. Connect HTML2PDFConvertor to Summary output of FeatureWriter
3. Select the path of the tool that you download in HTML2PDF, you can use mine it is default path
3. Select the HTML file that you created from FeatureWriter
That`s kinda tricky.
Firstly, you should download the tool to be able to use this transformer https://wkhtmltopdf.org/downloads.html . This tool is not supported by Safe Software, it is a third party transformer.
1. Use FeatureWriter to create the html files
2. Connect HTML2PDFConvertor to Summary output of FeatureWriter
3. Select the path of the tool that you download in HTML2PDF, you can use mine it is default path
3. Select the HTML file that you created from FeatureWriter
@canerakin111
I received an error when my features reach the HTML2PDFCONVERTER. There seems to be a confusion on what parameters to specify.
Based on the recommendation above, the feature writer should create an attribute called '_dataset' which contains the path of each html file created (See below). In my case, there's 4 files total.
So in theory, when I configure the HTML2PDFConverter I should have the following settings:
But when it reaches said transformer, I get the following message: HTML2PDFConvertor_AttributeFileReader(TeeFactory): HTML2PDFConvertor_AttributeFileReader: @File - unable to open file '' for reading. Check that the file exists and that you have read permission
It's almost as if the 'HTML file' parameter in the transformer can't read the attribute value. What's even more odd is if I try to specify each the actual HTML file one by one (see next image), I also get another error:
Error: HTML2PDFConvertor_AttributeFileReader: @File - unable to open file 'E:\\Downloads\\.pdf' for reading. Check that the file exists and that you have read permission
Is it just me or are the parameter fields in the HTML2PDFConvertor not able to take fme functions (e.g. @Value(any_attribute) ) ?
I've attached sample data and workspace. If you would, please take a look.
pdf_creation.fmwinputdata_ffs.zip
That`s kinda tricky.
Firstly, you should download the tool to be able to use this transformer https://wkhtmltopdf.org/downloads.html . This tool is not supported by Safe Software, it is a third party transformer.
1. Use FeatureWriter to create the html files
2. Connect HTML2PDFConvertor to Summary output of FeatureWriter
3. Select the path of the tool that you download in HTML2PDF, you can use mine it is default path
3. Select the HTML file that you created from FeatureWriter
No, you are right. I tried many different things I cannot get a result.
Hi @mariofederis,
I found why it did not work and the fix is really simple. I am not sure why I created this wrapper the way I did though - it was quite a few years ago. To make it work, simply delete the Creator transformer inside the custom transformer, and that should make everything work. One more thing - make sure zoom factor is actually set to some number.
I'll make the updated version of the transformer later, and for now, I am attaching the workspace that actually produces PDF output.
I adjusted the SubstringExtractor to my local path, you will need to change the numbers back. I would consider using a regular expression to find the necessary part in the _dataset attribute.
Dmitri
dm26662-pdf-creation.fmw
exc-18-01672.pdf
Hi @mariofederis,
I found why it did not work and the fix is really simple. I am not sure why I created this wrapper the way I did though - it was quite a few years ago. To make it work, simply delete the Creator transformer inside the custom transformer, and that should make everything work. One more thing - make sure zoom factor is actually set to some number.
I'll make the updated version of the transformer later, and for now, I am attaching the workspace that actually produces PDF output.
I adjusted the SubstringExtractor to my local path, you will need to change the numbers back. I would consider using a regular expression to find the necessary part in the _dataset attribute.
Dmitri
dm26662-pdf-creation.fmw
exc-18-01672.pdf
@dmitribagh Thanks for looking into it! As you said, turning off the 'creator' inside the custom transformer did the trick! I appreciate the assistance.
Hi @dmitribagh
I can't make it to generate a pdf file with HTML2PDFConvertor; I have installed wkhtmltopdf (wkhtmltox 0.12.6-1)
Hi @felipeverdu,
I just tried the transformer, and it seems to work fine for me (I can see it would really benefit from an upgrade to FME 2023 with its parameter conditional visibility).
In order to understand what's going on, we can analyze the command line that the transformer generates - after all, it is nothing else than a wrapper that assembles and runs the command line. You can try copy/paste it into PowerShell, run it there and see whether you get an error, and what that error is about.
It looks like you generate your html dynamically, perhaps with FeatureWriter, so I would suspect that's where the problem may be. Are you creating a temp file with TempPathnameCreator? If so, partial runs won't be able to finish this workspace correctly if both the file name creation and actual command line running are not in the same run. In the TempPathnameCreator, make sure you set the extension (HTML2PDF transformer didn't work for me when I didn't set it).
If this does not help, feel free to talk to me directly.
Dmitri
Hi @dmitribagh
I am using 2022.2.4 🙂 I run this in powershell and I got this error.
PD.- I run the transformer in 2023.1 and it worked as expected.
Hi @dmitribagh
I am using 2022.2.4 I run this in powershell and I got this error.
PD.- I run the transformer in 2023.1 and it worked as expected.
Hi @felipeverdu
I am sorry, to run the command in PowerShell, you have to be in the folder of the app and prefix the app name with .\
It should look like this:
PS C:\Program Files\wkhtmltopdf\bin> .\wkhtmltopdf.exe -q -O Portrait -s Letter --outline-depth 3 --zoom 1.5 -T 3cm -B 2cm -R 2cm -L 4cm toc "C:\Temp\dataCollectedMap.htm" --encoding fme-system "c:\temp\output.pdf"
The other option would be using "start-process" command, but it makes no sense to dive into it because FME does not use PowerShell to run OS commands.
FME runs CMD and there, the command generated with FME, works as is:
C:\Program Files\wkhtmltopdf\bin>"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" -q -O Portrait -s Letter --outline-depth 3 --zoom 1.5 -T 3cm -B 2cm -R 2cm -L 4cm toc "C:\Temp\dataCollectedMap.htm" --encoding fme-system "c:\temp\output.pdf"
So now you need to find what is different with the command that transformer creates for you and the command above that actually works. For me, they both work equally well (they are the same), so I need more information from you at this point.
Dmitri
Hi @dmitribagh
For some reason everything is working fine now :)
Thanks for your help!
Best regards,
Felipe Verdú