« Free tickets for youn… | Home | MBS Xojo / Real Studi… »

Optimize PDF Script

If you like to optimize a PDF with DynaPDF in FileMaker, you can use a script like the one below.

It loops over a table with container fields and imports them all in one PDF In memory.

Than it optimizes the PDF and writes it back to a container field.

For your convenience I included the commands to use files, too:



#Initialize DynaPDF if needed

If [$$DynaPDFInited  ≠ 1]

Perform Script [“InitDynaPDF”]

End If

#Clear current PDF document

Set Variable [$pdf; Value:MBS("DynaPDF.New")]

#For writing to file instead of container, pass path here:

//  Set Variable [$r; Value:MBS("DynaPDF.OpenOutputFile"; $pdf; "/Users/cs/Desktop/test.pdf")]

#Load PDF from container

Go to Record/Request/Page [First]

Set Variable [$destPage; Value:1]


#Read from file

//  Set Variable [$r; Value:MBS("DynaPDF.OpenPDFFromFile"; $pdf; "/Users/cs/Desktop/input.pdf")]

#or container

Set Variable [$r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Merge PDFs::InputPDF)]

#Import all pages

Set Variable [$r; Value:MBS("DynaPDF.ImportPDFFile"; $pdf; $destpage)]

If [GetAsNumber($r) >0]

Set Variable [$destPage; Value:$r+1]

End If

Go to Record/Request/Page [Next; Exit after last]

End Loop

#Repair & Optimize PDF

Set Variable [$r; Value:MBS("DynaPDF.Optimize"; $pdf)]

#Save to container

Set Field [Merge PDFs::FinalPDF; MBS("DynaPDF.Save"; $pdf; "Merged.pdf")]

Set Variable [$r; Value:MBS("DynaPDF.Release"; $pdf)]

19 01 16 - 21:04
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.