I'm trying to take a PDF file and set an opacity level to the entire document or page. The PDF's are always a single page and contain vectors but no raster images like this PDF file and can have RGB or CMYK colors. In this case, I'm trying to set an opacity level of 0.5 so everything is half-transparent.
I found a lot about watermarking PDFs which I think it's easier because the content is added to the PDF, in my case I want to modify the PDF content. I found these amazing transparency operators for Ghostscript but I can't make them work! I created a very simple postscript program and called it program.ps:
0 .pushpdf14devicefilter
0.5 .setopacityalpha 0.5 .setshapealpha
Then I run Ghostscript:
gswin64c.exe -dNOCACHE -dNOPAUSE -dBATCH -dNOSAFER -dALLOWPSTRANSPARENCY -sDEVICE=pdfwrite -o "opacity.pdf" program.ps circles.pdf
But the output is exactly the same, no transparency is applied. This results in a blank page:
<<
/EndPage {
2 eq { pop false }
{
0 .pushpdf14devicefilter
0.5 .setopacityalpha 0.5 .setshapealpha
true
} ifelse
} bind
>> setpagedevice
This makes no difference at all:
<<
/EndPage {
2 eq { pop false }
{
0.5 .setopacityalpha 0.5 .setshapealpha
true
} ifelse
} bind
>> setpagedevice
Changing the operators to .setfillconstantalpha and .setstrokeconstantalpha makes no difference. I'm obviously blindly trying out stuff because I can't find much information about this and I'm not entirely sure this is even possible.
Does anyone have any experience with this or any articles/papers/books I can use as a guide?