in reply to Re^2: How to change font color in PDF based by font name
in thread How to change font color in PDF based by font name

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.

Replies are listed 'Best First'.
Re^4: How to change font color in PDF based by font name
by vinothjaguva (Novice) on Jul 07, 2011 at 06:17 UTC

    Hi

    Thanks for your help

    I am able to find the (/FontName /XJQTHX+NewsGothicStd def) with in the postscript file. Please help me out how to change the color of the font.

    If i go and inserting individual line before text (0.134 0.473 0.790 setrgbcolor) the color information, the color is change and i can able to see in PDF

    Can i get any guidence from you

    Thanks in Advance

      If i go and inserting individual line before text (0.134 0.473 0.790 setrgbcolor) the color information, the color is change and i can able to see in PDF

      Great, you're almost there! Now you just have to find the places where the font is changed.

      Notice how the prelude will probably define a function that changes font, using the primitive operator setfont or selectfont. For example, the definition may look like this:

      /Tf { dup /pdfFontSize exch def dup pdfHorizScaling mul exch matrix scale pdfTextMat matrix concatmatrix dup 4 0 put dup 5 0 put exch findfont exch makefont setfont } def

      (Of course, this function in the prelude is specific to the pdftops utility, but I'm assuming here you've used that to generate the postscript file.)

      Once you've found this, search for calls to this proceduce, such as this:

      /F784_0 1 Tf

      The F784_0 here is an identifier for the font (the actual font is assigned to it somewhere in the prelude, but pdftops generates such a short identifier because the same font will typically occur many times), and the 1 is I think a scaling modifier.

      Find these lines that change the font, and change the color after that, depending on which font is used.

      PS. the part you mention with /FontName /XJQTHX+NewsGothicStd def is where the font is defined, not the statement where that font is activated. It could be useful if you want to know which short identifier means which font.

      Hello vinothjaguva,

      Also, there's no need to post a reply two or three times. Doing this only makes it more confusing for people to respond and help you. Please preview your message, double check the thread to confirm your post has gone up and wait for a reply from one of the monks.

      Good luck with your postscript problem. :)

      Luis


      "...the adversities born of well-placed thoughts should be considered mercies rather than misfortunes." — Don Quixote