Question

Convert new JPEGS added to a folder to PDFs

  • 11 June 2021
  • 1 reply
  • 10 views

Hello guys,

This is my first FME script 

I am trying to convert new JEPGS in a folder 

to PDF 

 

how do I do that ? 

what transformers and how to is et my readers and writer to be taking all the new JPEGs and converting them into PDFs with the same names ?


1 reply

Badge +2

Hi @giorgionwigwe​ ,

 

Welcome to the FME community! 

 

When it comes to converting multiple files you can either use a Path Reader/FeatureReader combo OR simply read in the files using a wildcard in the JPEG Reader's dataset parameter. In the case of jpeg, the extension can vary between .jpeg and .jpg so I would use the wildcard on the filename as well as the extension unless you only want one extension or know all of your files are the same. 

 

Add a JPEG reader to the canvas and set the dataset parameter to:

<path>\*.jp*

2021-06-11_15-13-15This will tell the reader to read in any file in that path that starts with the .jp extension. 

 

The last step here, and one that you will likely want to make note of, is Fanning out the dataset. A fanout tells the writer to out separate files based on the fme_basename (source filename) attribute that comes along with each JPEG that is read into the workspace.  

 

Start by adding a PDF write to the canvas then connect it to the reader. Then, in the navigator pane (top left area of workbench) expand the writer and double click on the Fanout parameter. Here you will set your fanout expression to:

@Value(fme_basename).pdf

2021-06-11_15-15-24This will effectively tell the writer to create a new .pdf for every fme_basename attribute value. 

 

If you need to alter the size/position of where the image appears on the output pdf, be sure to check out the PDFPageFormatter! In my example, I'm using relative paths so you should be able to just download and run this example but it will work the same for full paths. 

 

The Fanout concept will apply to other datasets as well so keep it in mind as you continue on your FME journey! 

Reply