Combine PDFs – Without Using FM Append

The sample file combines PDF files that are stored in containers. It uses 360 Works’ Scriptmaster to register external functions that work their magic on the PDF files. But let’s back up a bit.

When I first looked into this, I thought, “This should be easy.” Just use Append to existing PDF, an option in FileMaker’s Save Records as PDF script step.

Nuh-uh. The Append option only works if the PDF is generated from a FileMaker record. The Append option does not work for PDFs that are stored in containers.

So, I searched and discovered Scriptmaster, plus a custom jar library, which I think is called itext. Not sure, but I’ve heard that itext has licensing restrictions, which prohibit commercial use.

Anyway, I’m a novice when it comes to jar libraries. Others have commented that not all my script steps are necessary. Thing is, the prototype works. And until I see something better, I’m sticking with it.

Update
2016-01-09 – The prototype now includes ScriptMaster v4.32 for Windows. Plus script steps that test for:
1. The presence of v4.32
2. The system platform (Windows or Mac)
3. The application architecture (Windows 32- or 64-bit)

Unfortunately, this latest version of the prototype was not tested on Windows. None of the prototypes were. So, I’m really curious if it even works.

When you use MergePDF groovy function, it opens the files parentRecord.pdf and Attachment.pdf in Filemaker to create the Assembled.pdf. The problem is that the groovy function does not close them after proceeding to the merge. It olny closes Assembled.pdf. Therefore parentRecord.pdf and Attachment.pdf are "writing or deleting locked" as long as you don't exit filemaker. This is why we can't create the following Attachment.pdf.

Actually the problem is different that the one I was suggesting. It seems that once a parentRecord.pdf, or attachment.pdf is already present, windows considers that this file is already opened with filemaker and does not let you work on it anymore. The solution could be creating different PDFs (ie. attachment1.pdf, attachment2.pdf, etc), and once done, merge them all together, before erasing them from the folder.

Unfortunately prototype 4 doesn't work on windows. It is suspect a path problem. I think that something like "filewin:/c/....." is needed. I'm trying to figure it out.

On my work database I made an opening script that detects OS platform and sets up a global variable that defines a path which will be used on the computer. This way, I my database works as well on windows as on mac. With this method I don't need to define paths in all my scripts.

Any updates to this great solution? In v14 with ScriptMaster 4.42 the iText functions seem to fail. Would love to get this same functionality working again in the latest FMP version too. Thanks so much for sharing this.

@ldicroce@eswanborg Update works great with the ScriptMaster you've included. Thank you! It still does not seem to work with SM v4.42 which is the latest version from 360Works. If I can find v4.32 for Windows I'll be all set on both platforms. If you have any thoughts on it working with v4.42 as well i'd appreciate any info that way as well. But again - thanks for the great template and process - it's a huge help to us.