MBS Xojo Conference
6/7th September 2018, Munich

« Xojo 2016 Release 4 a… | Home | Hotels, Beds & Places… »

Custom function to optimize PDF in FileMaker via DynaPDF

This little function can be called anywhere to optimize a PDF. Of course you should initialize DynaPDF in startup script of your solution. But than you can call OptimizePDF function everywhere and pass in a PDF container value. The PDF is optimized and returned.

If you like add further parameters to decide what optimization to do. The example be low uses a good default setting to reduce PDFs for email delivery.


# Custom Function OptimizePDF(InputPDF)


# Optimizes PDF and returns either new one or old one in case of error.


Let ([ 

PDF = MBS("DynaPDF.New");

OpenResult = MBS("DynaPDF.OpenPDFFromContainer"; PDF; InputPDF);

OpenError = MBS("IsError");

ImportResult = MBS("DynaPDF.ImportPDFFile"; PDF);

ImportError = MBS("IsError");

Options = "FlattenLayers DeleteInvPaths ScaleImages NewLinkNames DeletePrivateData IgnoreZeroLineWidth DeleteAlternateImages DeleteThumbnails";

OptimizeResult = MBS("DynaPDF.Optimize"; PDF; Options; 50; 50; 50; 150; 150; 150; "JPEG"; "JPEG"; "JPEG");

OptimizeError = MBS("IsError");

OutputPDF = MBS("DynaPDF.Save"; PDF; GetAsText(InputPDF));

SaveError = MBS("IsError");

ReleaseError = MBS("DynaPDF.Release"; PDF);


Result = If( 

  // all okay?

  OpenError = 0 and ImportError = 0 and OptimizeError = 0 and SaveError = 0 and MBS( "Container.GetSize"; OutputPDF; "PDF " ) > 0

  // than return new PDF


  // return old PDF





result )

07 12 16 - 10:39
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.