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.