Open iwelch opened 2 years ago
Cairo is just a front-end to cairographics, so we really have no control over the PDF it creates. The only control I see is cairo_pdf_surface_restrict_to_version, but that only allows to choose from PDF 1.4 or 1.5. Searching for cairographics and PDF/A doesn't yield any hits. Is seems that some mention using post-processing tools to convert PDF files into PDF/A, so perhaps that's a way?
FWIW the closest discussion I found was https://github.com/Kozea/WeasyPrint/issues/630, but they solved the problem by ditching cairographics for PDF generation and replacing it with their own PDF generation tool, so I suspect there may not be as much hope as one would wish...
thanks. would it be possible to file a suggestion with the upstream cairographics library? regards, /iaw
-- Ivo Welch @.***) http://www.ivo-welch.info/ J. Fred Weston Distinguished Professor, UCLA Anderson
On Thu, Sep 15, 2022 at 2:11 AM Simon Urbanek @.***> wrote:
FWIW the closest discussion I found was Kozea/WeasyPrint#630 https://github.com/Kozea/WeasyPrint/issues/630, but they solved the problem by ditching cairographics for PDF generation and replacing it with their own PDF generation tool, so I suspect there may not be as much hope as one would wish...
— Reply to this email directly, view it on GitHub https://github.com/s-u/Cairo/issues/38#issuecomment-1247811322, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCJU6A5V23QTIPUMJD2GDV6LRMBANCNFSM6AAAAAAQLTOO3A . You are receiving this because you authored the thread.Message ID: @.***>
actually, the upstream thinks the main problem comes from R --- how its routines are called.
there is one aspect that would be good and maybe fixable --- having an option to open the CairoPDF device without transparency. transparency is a pdf/a killer and otherwise fixable only by rasterization, which obviously ends up looking terrible.
@iwelch thanks, do you have a link to the upstream discussion? If it is a matter of some settings then it should be doable, but it would be good to get some details.
I think I overstated my case, reading back the conversation from way back when.
https://gitlab.freedesktop.org/cairo/cairo/-/issues/588#note_1549144
hi S --- without knowing much more about Cairo, apparently if you open the device with
CAIRO_FORMAT_RGB24
instead of
CAIRO_FORMAT_ARGB32
then a big piece of the pdf/a problem would be fixed. it presumably would no longer want to write transparent images. without knowing the CairoPDF code, I am guessing this one would be easy (as an option on device CairoPDF(...,rgba=FALSE).
regards, /iaw
Those flags are only relevant to image surfaces, not PDF.
FWIW whether we use ARGB or RGB for image back-ends depends on a) the image type (e.g. jpeg is always RGB) and the background (for any solid background it is always RGB).
The only place where you can run into trouble is when using rasterImage
in PDF which at this points always uses RGBA. We could modify it to not use RGBA if alpha for all pixels is 0xff
, but this will have no effect on PDFs without rasterImage
(so your example above doesn't apply).
[This is more a feature request than a bug report]
PDF/A is the archival version of PDF and therefore more suitable to long-term use of a pdf file. Many professional offset printers require PDF/A files. When a PDF/A file includes one graphic that is not PDF/A compliant, it is itself no longer compliant. Ergo, any document that includes a Cairo R pdf is no longer pdf/a compliable.
For example, take a simple file and run it through macos:
run the output through the free VeraPDF compliance checker: