Skip to main content

Hi,

I am trying to insert a watermark disclaimer into construction PDF's as part of a distribution workspace that is an part of a FME Server App.

The key part of the workspace is that pdf's are filecopied into a zipped folder before being distributed, these pdf's range in size (napkin to Arch D, to legal letter, whatever was scanned), but the disclaimer can be in the same spot (ie. bottom left hand corner, 150x, 150y).

The PDF writers limitation is that it can only write to certain page sizes, which is an issue, so inserting a text disclaimer is not feasible.

The filecopy maintains the page size/pdf quality, but I am at a loss for adding a watermark/overlay/text.

FME Desktop 2021.0

FME Server FME Server 2021.0.1

 

Thanks!

I can think of a way to do it directly in fme, but it looks like its pretty straightforward to do in python. You could place a python caller at the end of your process to insert the watermark

 

https://www.codespeedy.com/how-to-add-watermark-to-a-pdf-file-using-python/


@hkingsbury​ thank you for the solution, my boss's would prefer to keep the solution directly in FME. Shortly after posting this question I went on parental leave and promptly forgot about this. How would you perform this in FME?

Thanks!


@hkingsbury​ thank you for the solution, my boss's would prefer to keep the solution directly in FME. Shortly after posting this question I went on parental leave and promptly forgot about this. How would you perform this in FME?

Thanks!

A python caller would still run in the FME workbench, so you wouldn't be managing a separate, external script


Hello @dmerrick​ ,

If you are only interested in a purely FME solution for adding a watermark to a PDF document, I would recommend taking a look at the workspace shared in this post as an example. I hope it helps.


Hello @dmerrick​ ,

If you are only interested in a purely FME solution for adding a watermark to a PDF document, I would recommend taking a look at the workspace shared in this post as an example. I hope it helps.

@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

The PDF writer has a drop-down list of common PDF page sizes, but that does not mean the PDF writer is limited to only writing to these page sizes.

If the PDF format attribute pdf_page_size is set on features, the writer will use that value for the page size. Note the value of pdf_page_size is page points, where 1 page point = 1/72 inch. However, you shouldn't need to calculate this manually as this value is stored on the pdf_page_metadata feature. You can join this value to the PDF vector and text features to set the page size.

I've included an example of using the PDF reader/writer to add a text disclaimer to each PDF page. If you inspect the example PDFs, you can see they include a variety of non-standard page sizes (2"x3.5", 20"x15", etc.).

 

I've also included an example of using a PythonCaller and the PyPDF2 library, the library used in the link shared by @hkingsbury. Since that specific library cannot create PDFs from scratch and can only merge objects from an existing PDF, you can use the PDF reader/writer to read the number of pages and page size for each PDF file and create a temporary PDF with the disclaimer text in the correct page size(s). Then use the PythonCaller to merge the original PDF pages with the disclaimer PDFs. Since the PyPDF2 Python library is not shipped with FME, follow the documentation here for installing Python packages to FME Desktop.

 

Another alternative is to use a SystemCaller to call a PDF utility application. I have not tested this approach myself but it should work.


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

Hi @debbiatsafe​ thank you for the workspace, would you be able to post a few screenshots of the workspace?

I am running FME Desktop 2021.0 and I lose the feature joiner and settings that enable this workspace to solve my disclaimer issue in the reader/writer example.

Thank you!


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

There are two FeatureJoiners in the workspace. For the FeatureJoiner in the PDF reader/writer workflow (top bookmark), these are the settings:

Join on fme_dataset and pdf_page_numberFor the FeatureJoiner in the Python workflow (bottom bookmark):

Join on fme_datasetI've also included a 2021.0 version of the workspace in case it helps.


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

The text pdf (multi_page_nonstandard) is able to be written out correctly, but the FME Lizard and Racecar image do not write out correctly. Any solutions?pdf


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

Are you running the template workspace without modification? It looks like the image was shifted/corrupted when writing. I ran the template workspace on my machine again and the output is shows correctly.

Do both workflows (PDF reader/writer, PDF reader + Python) show this incorrect behaviour?


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

@debbiatsafe​ I realized the issue is that Bluebeam is unable to open the pdf image correctly, it displays text fine. Adobe displays the "stamped" pdf correctly. Many of the users for the stamped PDF's would prefer to use Bluebeam and not Adobe, but I have not had any luck adjusting the Writer parameters to avoid the image issue on the pdf's, thoughts?


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

Unfortunately, I'm not familiar with Bluebeam and don't have it installed to test. The only PDF writer parameter I know of that affects raster is the PDF 1.4 Compatible parameter. Have you tried enabling this parameter?

In addition, does the PDF files created using the Python method display correctly in the Bluebeam?


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

@debbiatsafe​ enabling the PDF 1.4 Compatibile parameter solved part of the writer issue, I also needed to remove the alpha band, and calculate the page size (the writer rejects page sizes which are not whole numbers to the default 8.5x11 letter output).

I did not test the python method as the FME method prevents any FME server-python library issues


@debbiatsafe​, I had previously reviewed that post, but that deals with letters on a standard sized page where FME can "read" and correctly write out the pdf. I am dealing with non-standard size pdf images that FME is unable to properly read/write out, the file copy writer is able to correctly duplicate the file, but that is as far as FME can go.

Any other suggestions?

Thanks,

The method described above works for pdf's which are images/rasters. If the PDF is full of vectors/mark ups then FME is quickly bogged down and struggles to finish a single page, let alone multi page pdfs.


Reply