0
votes

want to write header over pdf files using ghostscript. i tried several thread of this forum

can I use Ghostscript to overlay a text (fax) header onto a PDF and/or TIFF?

How can I make a program overlay text on a postscript file?

i tried this code and it works. i cant see the header but when i search header using find function i can see header somewhere but its not visible.

gs \
 -o /5/7007.pdf \
 -sDEVICE=pdfwrite \
 -g5030x5320 \
 -c "/Helvetica-Italic findfont 15 scalefont setfont 453 482 moveto (544) show" \
 -f /5/77.pdf

and other code is

gs -dBATCH  -dNOPAUSE  -sDEVICE=pdfwrite \
-sOutputFile=/5/7007.pdf \
-c "/Times findfont 12 scalefont setfont 50 765 moveto (header text) show" \
-f /5/77.pdf

both codes generate the pdf fileand header also but header is not visible.

my output of ghostscript is

Page 2
Page 3
Page 4
Page 5
Can't find (or can't open) font file %rom%Resource/Font/Arial-ItalicMT.
Can't find (or can't open) font file Arial-ItalicMT.
Can't find (or can't open) font file %rom%Resource/Font/Arial-ItalicMT.
Can't find (or can't open) font file Arial-ItalicMT.
Didn't find this font on the system!
Substituting font Helvetica-Oblique for Arial-ItalicMT.
Page 6
Page 7
Page 8
Page 9
Page 10
Page 11

i want to write header and footer in all pages and i am ok with any font or if possible can change

. i used fc-list which listed several fonts . i used one of them then also getting similar error. seems ghostscript is trying to match each page font.i am not interested in matching each page font. just want to use some font for header which is available.

partial list of fonts are here

fc-list
Liberation Mono:style=Regular
Utopia:style=Bold Italic
Nimbus Sans L:style=Regular Italic
DejaVu Serif,DejaVu Serif Condensed:style=Condensed,Book
Hershey\-Gothic\-English:style=Regular
URW Palladio L:style=Roman
DejaVu Serif,DejaVu Serif Condensed:style=Condensed Bold Italic,Bold Italic
Century Schoolbook L:style=Bold Italic
DejaVu Serif,DejaVu Serif Condensed:style=Condensed Bold,Bold
Liberation Sans:style=Regular
DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
DejaVu Sans Mono:style=Bold Oblique
Carlito:style=Italic
Liberation Serif:style=Bold Italic
Caladea:style=Bold
DejaVu Serif:style=Bold Italic
Nimbus Sans L:style=Bold
OpenSymbol:style=Regular
Utopia:style=Bold
Caladea:style=Bold Italic,Italic
Hershey\-Plain\-Duplex\-Italic:style=Regular
1

1 Answers

2
votes

You need to add the code to make marks on the page as an EndPage procedure, otherwise you first make the marks on the 'page', then write the content of the PDF file. I assume you want to do that the other way around, first write the content of the PDF file then write the additional content afterwards.

You should also set the colour you want the text to be in, otherwise it will use the current colour, which might be white. 0 setgray 0 0 0 setrgbcolor or 0 0 0 1 setcmykcolor will set the current colour to black.

So something like:

-c "<</EndPage {0 setgray /Times 20 selectfont 453 482 moveto (544) show}>> setpagedevice" -f

should probably work well enough.

As regards the warning about Arial-ItalicMT this means your PDF file uses that font, but does not include it. You must either:

  1. Accept the substitution offered by Ghostscript (Helvetica-Oblique)
  2. Supply a different substitute
  3. Supply the real font

In order to do either of 2 or 3 you will need to modify fontmap.GS or cidfmap, depending on whether its a font or a CIDFont which is missing.

Add corrected code:

-sDEVICE=pdfwrite -sOutputFile=\temp\out.pdf -c "<</EndPage {2 ne {0.5 setgray /Times 20 selectfont 453 48 moveto (Test) show pop true}{pop false} ifelse} >> setpagedevice" -f