最初我在这里问如何实现在命令行下将某个文本文档转换为PDF,有人提到用a2ps加上ps2pdf(可惜不支持中文):
http://www.linux-ren.org/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=3447&forum=21
也就是这样:
a2ps -o - input.txt | ps2pdf - output.pdf
当时试了一下,挺不错,而且默认就可以将一个普通的文本文件做成A4大小的样子,挺漂亮!
当时用的系统是Everest Linux 0.2吧,今天在0.5上又想起这个事,用同样的方法试了一下,生成的纸张大小是letter,很纳闷……
分开执行:
a2ps -o input.ps input.txt (得到ps文件看上很正常,就是A4大小,其实如果是为了打印这样就可以了)
ps2pdf input.ps output.pdf (得到的PDF文件就不正常了,纸张大小是letter)
于是我想应该是ps2pdf的问题了,试着man ps2pdf,看上去没有什么纸张设定选项的说明,不过看上去ps2pdf应该是Ghostscrīpt项目的一部分,试着man gs,看到这样的一段:
To select a specific paper size, use the command line switch -sPAPERSIZE=<paper_size> for instance -sPAPERSIZE=a4 or -sPAPERSIZE=legal
于是试着这样做:ps2pdf
-sPAPERSIZE=a4 input.ps output.pdf
果然OK了,昏倒,为什么ps2pdf有时竟然不认ps文件的纸张大小,只管生成letter那样的呢?后来在网上又搜了一下,看到这里:http://www2.maths.ox.ac.uk/~whittaker/utotd/
其中有如下一段:
----------------------------------------------------------------------
PAPER SIZE CHANGED TO LETTER WITH PS2PDF
The scrīpt ps2pdf which converts postscrīpt files to pdf, appears to
sometimes ignore the paper size of the underlying file and create a
pdf with the US Letter size. To fix this for A4 documents, use:
ps2pdf -sPAPERSIZE=a4 foo.ps
The papersize option is from ghostscrīpt (see 'man gs' for
details). You can also set A4 as the default size by setting the
following environment variable:
GS_OPTIONS='-sPAPERSIZE=a4'
---------------------------------------------------------------------
看来也有别人遇到过。
另外,中文网页上好多讨论ps2pdf的都是和LaTex有关的,那个没有研究过,
在学校时就觉得LaTex一定是个高级优雅的东西,可以将一些学术文章排版做得那么漂亮。
呵呵,抽空一定要了解一下。