Ghostscript的PDF总页数 [英] Ghostscript pdf total pages
问题描述
我使用的Ghostscript库API(从C#包装)从我的应用程序打印PDF文档。结果
随着 -dFirstPage 的'和'的 -dLastPage 的'要打印的参数,我可以选择网页的时间间隔,但如何对PDF格式的网页总数?
它是不是很漂亮,允许用户选择从2到10页的间隔时,让我说,PDF文档只有4页。结果
考虑到我使用的Ghostscript库通过* gsapi_init_with_args * API库调用。
I'm using Ghostscript library API (wrapping from C#) to print PDF documents from my application.
With the '-dFirstPage' and '-dLastPage' parameters i'm able to select page's interval to be printed, but how about the total number of PDF's pages?
It is not very nice to permit user to select a page interval from 2 to 10 when, let me say, the pdf document has only 4 pages.
Consider that i'm using Ghostscript library through the *gsapi_init_with_args* API library call.
先谢谢了。
推荐答案
Ghostscript的可以依靠和标准输出
显示的PDF文件的页数。命令行是
Ghostscript can count and display the number of pages of a PDF on stdout
. The commandline is
gswin32c ^
-q ^
-dNODISPLAY ^
-c "(input.pdf) (r) file runpdfbegin pdfpagecount = quit"
下面所有的 -c...
的东西是PostScript命令行片断(使用一些GS内部命令扩展)。而 input.pdf 的是PDF文件名(也可以像完整路径(C:/path/to/my.pdf)
)。
Here all the -c "..."
stuff is a PostScript commandline snippet (using a few GS internal command extensions). And input.pdf is the PDF filename (could also be a full path like (c:/path/to/my.pdf)
).
然而,为了更好,更快的工具这个样的工作是使用的XPDF公用事业 pdfinfo
(一部分,也可在Windows上)。
However, a better and faster tool for this kind of job would be to use pdfinfo
(part of the XPDF-utilities, also available on Windows).
更新:的
Update:
@ebyrob想知道如果一个人可以修改我的示例命令行,以便它也显示的单一操作的PDF文件。试试这个:
@ebyrob wants to know if one can modify my example command line so that it also displays the PDF in a single operation. Try this:
gswin32c ^
-q ^
-c "(input.pdf) (r) file runpdfbegin pdfpagecount =" ^
-f input.pdf
那么,它不是一个单一的操作 - 这是在一个单一的命令行只是两种不同的操作
Well, it's not a single operation -- it's just two different operations in a single commandline.
这篇关于Ghostscript的PDF总页数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!