Combining PDFs - The Blazing Fast Method

Using PDFs is easy! Working with PDFs, as a developer, is another story. While the PDF format has been around for what seems like forever, it's still a bit of a mystery to manipulate.

Fortunately, there are code libraries and a free plug-in that makes this quite easy to accomplish. Yes, FileMaker 9 and higher does provide the ability to append to existing PDFs, but this process can be quite slow in a variety of cases.

If speed is your concern, and you need to combine multiple PDFs, static or dynamically generated, then this video and technique file will provide you with everything you need to combine PDFs from within FileMaker Pro.

AttachmentSize
iTextPDFMerge.zip2.46 MB

Comments

Thank you, Matt, for this demo, as I was hitting a wall trying to achieve exactly this. However, I need to add a text string to the footer of the combined PDF (a watermark?), as well as number the pages in the combined PDF. What would I need to do to add more iText functionality?

I'm using SuperContainer to store images. I'd like to feed it the remote host filepaths rather than export each locally and use local filepaths.

I can't figure out how to rewrite the file.ospath() custom function to get it to return correctly.

Any tips?

I'm trying to use this method, but for some reason, the catpdf () external function is returning an error, but Get SMLastError isn't enlightening me as to what it is. I think my inputs are properly formatted...

Running from the sample file that's provided at the link (where the example script works perfectly), I have a modified script that includes the following:

$reports
/Volumes/Macintosh HD/Users/carlosoto/Desktop/OrderDEMENTWO4080732.pdf
/Volumes/Macintosh HD/Users/carlosoto/Desktop/Measure1.pdf
/Volumes/Macintosh HD/Users/carlosoto/Desktop/Measure2.pdf

$filepath
/Macintosh HD/Users/carlosoto/Desktop/OrderDEMENTWO4080732FINAL.pdf

catpdf( $reports ; $filepath )

And that last function returns an error, but when I try to invoke SMLastError, I get nothing.

The files are there where the paths indicate, I don't see any forbidden characters in the file names, and all the code is properly loaded.

My inputs (above) were malformed. When I corrected that, I was able to use this technique successfully. Thanks very much!

Matt,

Thank you very much for this video. It opened my eyes to the potential of iText.

I ran into a problem following your instructions. My FMP 12 client gave me an error when I tried to import the custom function file.setpath. The error was "One of the parameters “location;subfolder” is already used as a function's name. I can't find a custom function or external function that is using those parameters.

Your database does not have that problem. It runs fine.

Would you have any thoughts on where I went wrong?

John

Based on a few people asking for the files to be updated I've fixed them. The original file used a custom function which used a parameter named 'location'. This was made into an actual function with 12/13 so it needed to be renamed (Thanks Tim Cimbura!)

Also, the file.setpath function used a literal reference for the file extension, which was .fp7 when this file was created. I fixed this by adding a new custom function named file.extension, which will account for whichever version is being used.

Finally, it's worth it to note that the licensing for iText change A LOT since I had originally recording this. The included version 2 has a much more permissive licensing policy than the current version.

Always check into the licensing restrictions when using external technologies!

-- Matt Petrowsky - ISO FileMaker Magazine Editor

Hi Matt,

I need some help combining PDF files on a Mac. The solution works as a creation tool, but I can't get the combine process to work. Can you suggest something for me to try or to use?

Thank you!

-Billy Block

William Block
BlockOne
Wilmington, NC