vinothjaguva has asked for the wisdom of the Perl Monks concerning the following question:

Hi I have pdf with 8 to 9 font. I want to change the font color for each fonts. Is there any possibilities in perl.
  • Comment on How to change font color in PDF based by font name

Replies are listed 'Best First'.
Re: How to change font color in PDF based by font name
by ambrus (Abbot) on Jul 06, 2011 at 09:34 UTC

    I'd recommend on not trying to parse the PDF in perl, but leave that to a PDF/postscript interpreter. First, convert the PDF to postscript. Then, edit the postscript to change setfont operations to some procedure that both sets the font and changes the color. (Hope that the postscript program does not change the color after that.) Try to extract the full name of a postscript font with /FontInfo get /FullName get , and change the color according to that.

      Thanks for your suggestion. I am unable to find out FontInfo get /FullName get.

      Could you please recommand any module (or) sample coding

        A few more pointers. Convert the PDF to postscript using the pdf interpreter pdftops in the http://www.foolabs.com/xpdf/download.html. In the postscript file you get, setfont is used to change to a font. You change this operator to set not only the font but also the color. Finally, you run the modified postscript file with a real postscript interpreter, such as ghostscript (gs). If you want to produce a pdf file, the utility script a2ping (which also uses ghostscript) may help.