I have a PDF with a black background and white/yellow text.
How can I remove the black background before printing and invert the color of the text?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is likely to be non-trivial to solve in general, but if you have a predictable collections of PDFs (say, all from the same source) then you may be able to hack together a quick solution like so:
All of this can be done programmatically instead of via command line tools too. getpdfpage.pl and setpdfpage.pl are simple little wrappers around the CAM::PDF API.
A general solution would be to use getPageContentTree() to parse the PDF page syntax and search for the color changing operators and alter them. But if your PDF uses a custom color space (“sc”) this can be tricky. And searching for the operator that does the full-page black fill could be hard too, depending on the geometry.
If you provide an URL for a sample PDF, I could provide some more specific advice.
UPDATE: on a whim, I wrote a rudimentary color changer script that may work for some PDFs. To use it, run like this example which turns any red element green instead:
This requires you to know the PDF syntax of the color directives you’re trying to change, so it may still require something like the getpdfpage.pl steps recommended above.
And the source code: