2016-09-18 47 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