如何在Linux中的postscript或pdf文件的每一页底部添加页脚? [英] How can I add a footer to the bottom of each page of a postscript or pdf file in linux?
问题描述
因此,我想在Linux中使用groff通过postscript生成的pdf文件的每一页底部添加一个页脚"(属性).我自己使用ps2pdf工具将文件从ps转换为pdf,因此可以同时使用这两种格式.
So I'd like to add a "footer" (an attribution) to the bottom of every page of a pdf file I am generating via postscript with groff in linux. I am converting the file from ps to pdf myself, with the ps2pdf tool, so I have access to both formats.
这两个帖子对您有所帮助:
These two posts have been somewhat helpful:
我不反对使用第一种方法,但是我无权访问第一个脚本中提到的pdflatex
实用程序,也没有选择将其安装在需要执行此操作的计算机上的选择
I'm not against using the first method, but I don't have access to the pdflatex
utility mentioned in the first script, nor do I have the option to install it on the machine that needs to do the work.
看起来第二种方法可能可行,但是我安装了8.15版的ghostscript,并且在手册页上没有看到很多标志(
It looks like the second method could possibly work, but I have version 8.15 of ghostscript installed and I didn't see many of the flags listed on the man page ( http://unix.browserdebug.com/man/gs/ ). I think I have access to the "-c" flag to insert some postscript code, even though it is not listed. Anyhow, here are two commands I tried unsuccessfully:
gs -o output.pdf -sDEVICE=pdfwrite -g5030x5320 \
-c "/Helvetica-Italic findfont 15 scalefont setfont 453 482 moveto (test-string) show" \
-f input.ps
这给了我这个
Unknown switch -o - ignoring
ESP Ghostscript 815.02 (2006-04-19)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
ERROR: /undefinedfilename in (output.pdf)
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:1117/1686(ro)(G)-- --dict:0/20(G)-- --dict:102/200(L)--
Current allocation mode is local
Last OS error: 2
ESP Ghostscript 815.02: Unrecoverable error, exit code 1
因此-o标志显然存在问题,因此我进行了一些研究并尝试了以下语法:
So obviously the -o flag has a problem and so I did some research and tried this syntax:
gs -sOUTPUTFILE=output.pdf -sDEVICE=pdfwrite -g5030x5320 \
-c "/Helvetica-Italic findfont 15 scalefont setfont 453 482 moveto (test-string) show" \
-f input.ps
输出此内容并使我按回车键4次(也许input.ps中有4页)
which outputs this and makes me hit return 4 times (maybe there are 4 pages in input.ps)
ESP Ghostscript 815.02 (2006-04-19)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Can't find (or can't open) font file /usr/share/ghostscript/8.15/Resource/Font/Helvetica-Italic.
Can't find (or can't open) font file Helvetica-Italic.
Querying operating system for font files...
Didn't find this font on the system!
Substituting font Helvetica-Oblique for Helvetica-Italic.
Loading NimbusSanL-ReguItal font from /usr/share/fonts/default/Type1/n019023l.pfb... 3742416 2168114 2083056 759694 1 done.
Loading NimbusRomNo9L-ReguItal font from /usr/share/fonts/default/Type1/n021023l.pfb... 3781760 2362033 2365632 1015713 1 done.
Loading NimbusRomNo9L-Medi font from /usr/share/fonts/default/Type1/n021004l.pfb... 3865136 2547267 2365632 1029818 1 done.
Loading NimbusRomNo9L-Regu font from /usr/share/fonts/default/Type1/n021003l.pfb... 4089592 2759001 2365632 1032885 1 done.
Using NimbusRomanNo9L-Regu font for NimbusRomNo9L-Regu.
>>showpage, press <return> to continue<<
>>showpage, press <return> to continue<<
>>showpage, press <return> to continue<<
>>showpage, press <return> to continue<<
因此,使用gs
来简单地在ps文件中插入内容似乎很简单,但是事实证明它相当复杂...
So it seems like it would be simple enough to use gs
to simply insert something in a ps file, but it is proving to be quite complicated...
推荐答案
ESP Ghostscript是 O-o-o-o-old .除非您绝对绝对不能避免使用它,否则不要再使用它.它是CUPS使用了一段时间的原始Ghostscript的一个分支. (并且在解决了开发人员之间的一些问题之后,CUPS的最新版本现在也再次使用了GPL Ghostscript ...)
ESP Ghostscript is O-o-o-o-old. Don't use it any more unless you absolutely, absolutely cannot avoid it. It was a fork of the original Ghostscript which used by CUPS for a while. (And after some problems between developers where resolved, more recent versions of CUPS now also use the GPL Ghostscript again...)
最新的GPL Ghostscript版本位于: http://www.ghostscript.com/releases/
Newer GPL Ghostscript versions are here: http://www.ghostscript.com/releases/
此外,-o out.pdf
只是-dBATCH -dNOPAUSE -sOutputFile=outpdf
的简写.因此,您应该尝试一下. (-dNOPAUSE
部分使您不必在每次前进页面时都点击<return>
.).
Also, -o out.pdf
is only a shorthand for -dBATCH -dNOPAUSE -sOutputFile=outpdf
. So you should try this. (The -dNOPAUSE
part relieves you from hitting <return>
for every page advance....).
最后,不要指望由第三方 man gs
页面提供的所有文档.而是参考您使用的版本的原始Ghostscript文档,最重要的部分是:
Lastly, don't expect the full range of documentation being provided by a third party man gs
page. Rather refer to the original Ghostscript documentation for the version you use, the most important parts being:
-
当前开发部门:自述文件. htm + Use.htm + Readme.htm + Use.htm + Readme.htm + Use.htm +
current development branch: Readme.htm + Use.htm + Ps2pdf.htm- 9.00 release: Readme.htm + Use.htm + Ps2pdf.htm
- 8.71 release: Readme.htm + Use.htm + Ps2pdf.htm
更新:Ghostscript的源代码存储库已移至Git(而非Subversion).因此,以下链接已反复更改:
Update: Ghostscript has moved to Git (instead of Subversion) for their source code repository. Therefor the following links have changed, repeatedly:
-
当前开发分支: Use.htm + Readme.htm + Ps2pdf.htm
current development branch: Readme.htm + Use.htm + Ps2pdf.htm- current development branch: Readme.htm + Use.htm + Ps2pdf.htm
这篇关于如何在Linux中的postscript或pdf文件的每一页底部添加页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!