PDFKit.AppendPages

PDFKit.AppendPages

I am trying to append two PDF pages. I am grabbing the PDF’s from a network drive. I wanted to know if it is possible to append without using a container field to hold the PDF's.
It just seems a bit slow with 300 records to loop through...

EDIT: I completely spaced on your original question specifics, sorry, I'll leave this here but I don't think it directly answers your specific question


can you use an external tool like pdftk?

if so then use the path to the files on disk and do something like:

pdftk path/to/file1.pdf path/to/file2.pdf cat output path/to/result.pdf

You can call the above using a plugin like BaseElements with BE_ExecuteSystemCommand

if your files are stored in external storage containers you can get the path to the container file with GetContainerAttribute ( MyTable::pdfField1 ; "externalFiles" ), and use those paths as inputs. Be careful not to write to this same location as the pdftk output. I recommend using Get(TemporaryPath) & "output.pdf"

Note, when constructing paths to use in an external system command, you want to convert them to OS-style paths like this ConvertFromFileMakerPath ( $fmpathformat ; WinPath ) (assuming windows in this case)

Finally, to get that combined pdf into fm, you can use Insert From URL (Insert File won't work on FMS), or the Data file script steps.

Yes, you can just pass file paths to add pages.

e.g. like the script:

Go to Record/Request/Page [ First ]
Set Variable [ $pdf ; Value: MBS( "PDFKit.NewPDFDocument" ) ]
Loop
    Set Variable [ $r ; Value: MBS( "PDFKit.AppendPages"; $pdf; Merge PDFs::InputPDF) ]
    Set Variable [ $r ; Value: MBS( "PDFKit.AddEmptyPage"; $pdf; 700; 500) ]
    Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
Set Field [ Merge PDFs::FinalPDF ; MBS("PDFKit.GetPDFDocument"; $pdf) ]
Set Variable [ $r ; Value: MBS("PDFKit.Release"; $pdf) ]
2 Likes

Awesome! Thank you for your reply.