Size of PDF

What I did: I created a very simplistic project and added a PNG image with a size of around 500k

What happened: I exported the project as PDF and found that the exported file grew from initially 280k to 2.3 MB.

What I expected: The file should not grow as fast as it does. I would have expected a file size of max 900K. It looks to me that no compression is applied when embedding images but the uncompressed pixel stream is stored. Thus the PDF export grows unexpectedly. I also experimented with JPEG and could observe the same behaviour. Can you please comment?

Things that might be helpful to know (Agenda version, OS and model, etc):
Agenda 4.1. MacOS High Sierra.

PDF is not a good medium for bitmap images. We recently changed PDF export to make bitmap resolution higher, because many people found the bitmaps exported to be blurry. We have decided to opt for better export quality than for file size.

The actual compression used in the PDF is entirely up to Appleā€™s systems. We just use the standard PDF generation. PDF compression is generally not as good as image compressions like PNG and JPEG.

If file size is a serious problem for you, I recommend simple tools like PDF Squeezer. They reduce the size of many PDFs a lot.

Hi Drew! I aggree that it is a challenge to deal with images in PDF. But could you at least think of enhancing the PDF export to use the quarz plugin technology, comparably to MacOS preview app. As a standard there is the ā€˜Reduce File Sizeā€™ filter which can dramatically reduce the export size. With a little fiddling at the filter library one can even control the reduction factor when using the filter. I cross checked what Appleā€™s Pages does on export. It gives you the option to control image quality (Good | Better | Best). I assume they use also the quarz filter approach with some internal presets. That would be an alternative. What do you, dev team think?

We do just use Appleā€™s technology. There is nothing custom.

We will investigate if we can apply some compression with the frameworks after we make the PDF.

Thank you for looking into this. Just a final comment. Not sure what you exactly mean by ā€˜we use Appleā€™t technologyā€™. Quartz filters are long existing Apple technology to work with image content. Quartz is tightly integrated with the OS (see also Color Sync Utility). So, depending how your statement is meant, it should actually be possible to adopt it in Agenda (one could even apply other interesting filters on images then).

Definitely, problem is not so much about technology but rather about priority. There are so many things to do that Iā€™m afraid optimising PDF file size isnā€™t near the top Iā€™m afraid.

I just meant, our app draws, and the Apple frameworks create the PDF. We arenā€™t using anything unusual to make the PDFs. Same as all the other apps.

Can you dig in and customize the PDF creation yourself? Sure. And if we were making a PDF app, we may prioritize this more. For now, we are happy to generate a good looking PDF. Until about a week ago, they were not very nice, because the images were too low in resolution. You couldnā€™t read text in images.

For now, I just recommend using PDF Squeezer or similar. That works well with most PDFs, even ones created by Appleā€™s own apps.

Drew

Thank you for the info. As there is a workaround I have an option to deal with the issue. I hope that at some point in time you find time to pick it up.

Hi Drew.
Thanks again for the explanation and if it is not on Agendaā€™s prio list I will live with work arounds. For some of my projects Iā€™m havily relying on PDF exports (with images) since I need to share them with non MacOS/iOS users. And sending 100MB files per email is not an option :wink:

Instead of using PDFSqueezer Iā€™m personnaly better off with appleā€™s macos Preview.app + Quartz Filters. This allows me better control of the export. Compare to here:

Amongst developers

Applying Quartz filters is actually not a big deal (on MacOS), according to Appleā€™s API documentation:

just a different write() call on the PDFDocument object.

This would give two options:

a) Agenda can offer a convenient option (at export) to control the existing, standard Quartz filter ā€œReduce File Sizeā€.
b) End users could select/apply Quartz filters (at export) up to their need, comparably to the standard macos Preview app.

All the best,
Erik

Regarding applying Quartz filters, sure itā€™s not a lot of work, but a) is not an option because we donā€™t want to enforce reduction in quality on all users (for sure this quartz filter will re-encode images to lower quality jpegā€™s), which leaves b) and this requires some form of UI. Perhaps at some point this can be in the file dialog etc, we have some other config options people have asked for and for sure we can try to take it along when we try to address that. Again, low priority at the moment though.

Btw, I had a quick look at the link to the docs, but I donā€™t see the PDFWritingOption where you can define the quartz filter, am I missing something?

Hi mekentosj,

sure a) is not really an option. b) true. Exactlyā€¦ + testing this will cost at least a bit effort and time, I know. At least you are aware now that you have one user asking for it :slight_smile: My workaround is currently not too costly, so it is not a deal breaker.

Regards,
Erik

1 Like

Hi mejentosj,

Not sure if today you would have to take a slightly different route, but please check the last post on this stackoverflow thread:

Cheers,
Erik

Ok excellent, thanks.

Cheers. The QuartzFilter key is mentioned only in the header files. As far as I know no mention of it on the web docs so far (please report the issue to Apple by clicking the buttons at the bottom of that page :wink: ). See for example PDFDocument.h somewhere in /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Quartz.framework (exact location depends on your SDK and installation). ā€“ Petr Mifek May 8 '10 at 8:4