Check with ghostscript whether a PDF has transparent objects

ghostscript, pdf, pdf-parsing, transparency

Solution

I believe pdf_info.ps (gs/toolbin) will tell you this. Ghostscript wants to know in advance if a page uses transparency or not because it can do optimisations for performance and memory if it knows there is no transparency.

Note that a large number of PDF files floating about declare 'spurious' transparency where the transparency turns out to be 100% opaque :-(

Problem

PDFs can define transparency in several parts (see eg here): As graphical style attributes: - fill opacity (`/ca`) or stroke opacities (`/CA`) below a value of 1.0 - definition of a soft mask (`\SMask`) or with the definition of a transparency page group (`/S /Transparency`). The following `grep` expression is a quick (and dirty) check for that: ``` grep -aE -e '/[Cc][Aa] +0?\.[0-9]' -e '/SMask' -e '/S /Transparency' *.pdf ``` Is it possible to check whether there are transparent objects with `gs`?

Original source