Florian Bw
Florian Bw

Reputation: 756

Check with ghostscript whether a PDF has transparent objects

PDFs can define transparency in several parts (see eg here):

As graphical style attributes:

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?

Upvotes: 4

Views: 2736

Answers (1)

KenS
KenS

Reputation: 31199

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 :-(

Upvotes: 6

Related Questions