Creating the Filter
First you show the QuartzFilter Manager panel with executing the plugin command MBS("QuartzFilterManager.ShowPanel"). This will show the panel where you can use plus button to make a new filter. With the new filter named, use the button on the right side to add the Image compression effect from the image effects menu. Than select options, e.g. JPEG with middle quality.
The prebuilt filter "Reduce File Size" also reduces all images to a maximum size of 512 pixel, but that is in our tests often too small. Replacing uncompressed images with JPEG versions reduces the size significantly alone.
Using the Filter
Once the filter is created, it should appear in the list returned by QuartzFilterManager.Filters function. You can now use the plugin function PDFKit.SetCurrentFilter to make this filter the current one. Your next call to PDFKit.Combine, PDFKit.GetPDFPagesPDF or PDFKit.GetPDFPagePDF will use the filter. So the call to PDFKit.Combine passing existing PDF in container can shrink it and you store the PDF in a new container.
Your milage may vary. Some PDFs can be compressed a lot this way, but others are not affected or even bigger! So be careful and compare size before and after and use the smaller one.
Those filters are also available in our Combine PDFs utility and in our MBS Xojo Plugins.