Skip to main content
Solved

Convert 1000 jpg files to 1000 PDF files


souryana
Contributor
Forum|alt.badge.img+7

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

Best answer by ebygomm

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

View original
Did this help you find an answer to your question?

10 replies

david_r
Evangelist
  • November 21, 2019

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


souryana
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • November 22, 2019
david_r wrote:

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.


souryana
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • November 22, 2019

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.


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • November 22, 2019

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


david_r
Evangelist
  • November 22, 2019

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).


souryana
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • November 22, 2019
ebygomm wrote:

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?


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • November 22, 2019
souryana wrote:

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


souryana
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • November 22, 2019
ebygomm wrote:

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

Thanks! It worked!


souryana
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • November 22, 2019
ebygomm wrote:

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"?


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • November 22, 2019
souryana wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings