Skip to main content

Hi,

I want to convert 1000 jpeg files to pdf format. I have almost managed to finish the script but the one thing that i smissing is that the PDFpageformatter that I am using cannot be adjusted for each jpeg picture. What I am trying to say here is that i want the pdf to be the same extent as the jpg file without doing this manually (since I need to convert 1000 files).

Heres a picture of my script in FME

What you're looking for is the Fanout setting on the PDF writer. In your case, you can use the attribute that contains the incoming JPG filename, i.e. fme_dataset:

You may want to modify the fme_dataset attribute a bit first, however, to avoid overwriting the source JPG, e.g. by replacing ".jpg" with ".pdf" etc.

More on Fanout here: http://docs.safe.com/fme/2019.2/html/FME_Desktop_Documentation/FME_Workbench/Workbench/Setting_Dataset_Fanout_Properties.htm


What you're looking for is the Fanout setting on the PDF writer. In your case, you can use the attribute that contains the incoming JPG filename, i.e. fme_dataset:

You may want to modify the fme_dataset attribute a bit first, however, to avoid overwriting the source JPG, e.g. by replacing ".jpg" with ".pdf" etc.

More on Fanout here: http://docs.safe.com/fme/2019.2/html/FME_Desktop_Documentation/FME_Workbench/Workbench/Setting_Dataset_Fanout_Properties.htm

Thanks for the reply but that wasn't what I was after. I have already set up the fanout but like I said above, I have 1000 jpg in different sizes and I want to convert them to 1000 pdf and each one of them should have the same unique page size as they had when they were still jpeg files when converting them to PDF. When I use PDFpageformatter I can only adjust it one specific size and all will have the same pagesize. Thats not what I want to do though.


Thanks for the reply but that wasn't what I was after. I have already set up the fanout but like I said above, I have 1000 jpg in different sizes and I want to convert them to 1000 pdf and each one of them should have the same unique page size as they had when they were still jpeg files when converting them to PDF. When I use PDFpageformatter I can only adjust it one specific size and all will have the same pagesize. Thats not what I want to do though.


You need to look at creating the pdf_page_size attribute for each jpg


Sorry, seems like I didn't read your question properly. If you need to set a dynamic page size, you can set the format attribute pdf_page_size etc. manually rather than using the transformer, e.g. using an expression based on the JPG dimensions.

Here is the relevant part of the documentation:

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_ReadersWriters/pdf2d/multi_page_support.htm

Basically, the only thing the PDFPageFormatter does is to provide a friendly interface to populate the output format attributes for you:

This means that you are free to populate these format attributes yourself (which is what we had to do before this transformer was introduced, btw).


You need to look at creating the pdf_page_size attribute for each jpg

Hi, do you mean add an attribute called pdf_page_size and check the pdf_page_size in the writer format attribute?


Hi, do you mean add an attribute called pdf_page_size and check the pdf_page_size in the writer format attribute?

I think you have to set a Page Size in the writer parameters, it can not be left blank, but if you set the pdf_page_size attribute on the features this will be used in place. So the bit in yellow is set but not used, you create the pdf_page_size for each feature


You need to look at creating the pdf_page_size attribute for each jpg

Thanks! It worked!


You need to look at creating the pdf_page_size attribute for each jpg

I have one question though; why do you write 0 0 @Value(_num_columns) @Value(_num_rows) for pdf_frame_rectangle? Why do you start with "0 0"?


I have one question though; why do you write 0 0 @Value(_num_columns) @Value(_num_rows) for pdf_frame_rectangle? Why do you start with "0 0"?

The pdf_frame_rectangle needs the input as <lowerLeftX> <lowerLeftY> <upperRightX> <upperRightY>

To make the image fill the whole page, the lower left point is 0,0 whilst the upper right is the same as the page size


Reply