如何使用 GhostScript 将带有书签的 WORD 文档转换为 PDF?
我正在使用 vb.net 和 Ghostscript 以编程方式将 WORD 文档转换为 PDF。我遇到问题的这个 Word 文档有指向外部 URL 的超链接,也有指向文档内书签的超链接。当文档转换为 PDF 时,外部 URL 可以工作,但书签的链接却不能。
我一直在寻找一种解决方案来让这些书签在输出 PDF 上工作,但没有任何运气。希望有人已经做到了这一点并可以分享解决方案。
I'm converting WORD docs to PDF programmatically using vb.net and ghostscript. This word doc I’m having problems with has hyperlinks to external URLs and also hyperlinks to bookmarks within the document. When the doc is converted to PDF the external URLs work but the links to the bookmarks do not.
I have searched for a solution to get these bookmarks to work on the output PDF but haven’t had any luck. Hopefully someone has done this and can share the solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Ghostscript 仅处理 PDF 或 PostScript 作为输入,有兄弟产品也可以处理 XPS 和 PCL,但它们都不处理 Word .doc 文件。因此,您必须将 Word 文件转换为其他文件。
我猜测您正在使用 Windows PostScript 打印机驱动程序转换为 PostScript 并将其传递给 GS(可能通过 RedMon 端口监视器)以转换为 PDF。
现在,PostScript 不支持超链接、书签或查看应用程序的任何其他用具,因为它旨在作为打印语言。为了克服这个问题,Adobe 引入了一个扩展,即 pdfmark 运算符,它可用于创建此类信息。注意此扩展仅支持转换为 PDF。
因此,为了插入这些内容,您需要在 PostScript 中创建 pdfmarks。如果您从 Word 进行打印,这意味着您在打印时必须将 PostScript 插入到文件中。为此目的有一个“传递”机制。
因此,您需要做的是在 Word 中创建适当的 Visual Basic 脚本,该脚本在打印文档时插入相关的 pdfmark。这就是 Word 的 Adobe 插件(很久以前被称为 PDFMaker)的工作原理。
Ghostscript only handles PDF or PostScript as an input, there are sibling products to handle XPS and PCL as well but none of them handle Word .doc files. So you must be converting the Word file into something else.
I'll hazard a guess that you are using the Windows PostScript printer driver to convert to PostScript and passing that to GS (possibly via the RedMon Port Monitor) to convert into PDF.
Now PostScript doesn't support hyperlinks, bookmarks, or any of the other paraphernalia of a viewing application, since its intended as a print language. To overcome this Adobe introduced an extension, the pdfmark operator, which can be used to create this kind of information. NOTE this is an extension which is only supported for conversion to PDF.
So, in order to get these inserted, you need to create pdfmarks in the PostScript. If you are printing from Word, this means that you have to insert PostScript into the file when printing. There is a 'pass through' mechanism for this purpose.
So what you need to do is create the appropriate Visual Basic script in Word which inserts the relevant pdfmarks when the document is printed. This is how the Adobe plug-in for Word (which used to be called PDFMaker a long time ago) works.
看看这个工具。
它确实维护书签和超链接。
http://www.transcom.de/transcom/en/2004_pdf-t -maker.htm
Have a look at this tool.
It does maintain bookmarks and hyperlinks.
http://www.transcom.de/transcom/en/2004_pdf-t-maker.htm