2016-09-18 48 views
0

想使用ghostscript在pdf文件上编写标题。我想这个论坛的几个线程ghostscript header在pdf文件

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?

我想这个代码和它的作品。我不能看到标题,但是当我使用查找功能搜索标题时,我可以看到标题的某处,但它不可见。

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

和其他代码是

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 

两个代码生成PDF fileand头部还但报头是不可见的。

我的ghostscript的输出

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 

我想写页眉和页脚中的所有页面和我行与任何字体,或者如果可能的话可以改变

。我用fc-list列出了几种字体。我用他们其中的一个,然后也得到类似的错误。似乎ghostscript正试图匹配每个页面font.i我不感兴趣匹配每个页面的字体。只是想使用一些可用的标题字体。字体

部分列表在这里

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

您需要添加代码,以使页面的尾页的程序上的标记,否则,你首先要“页”上的标记,然后写的内容的PDF文件。我假设你想这样做,先写下PDF文件的内容,然后再写下其他内容。

您还应该设置想要文本的颜色,否则将使用当前的颜色,可能是白色。 0 setgray0 0 0 setrgbcolor0 0 0 1 setcmykcolor会将当前颜色设置为黑色。

因此,像:

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

或许应该工作不够好。

至于关于Arial-ItalicMT的警告,这意味着您的PDF文件使用该字体,但不包括它。你必须:

  1. 接受为Ghostscript(黑体斜)
  2. 供应不同的替代
  3. 供应真正的字体

提供的替代为了做到无论是2或3您将需要修改fontmap.GS或cidfmap,具体取决于它是否缺少字体或CIDFont。

加纠正代码:

-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 
+0

要么是给只有头或整页页无头 – Steeve

+0

然后你做错了什么。你**应该**有错误。我修改了上述编辑中的代码,这对我有用。 – KenS

+0

输入文件将在-f右后????/ – Steeve