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?
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.
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
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:
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.
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?
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 My workaround is currently not too costly, so it is not a deal breaker.
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 ). 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 MifekMay 8 '10 at 8:4