简体   繁体   English

将docx转换为postscript

[英]Convert docx to postscript

I need to convert a Word document (docx) to a postscript file so that I can use this postscript file to generate PDF using the Ghostscript command line tool. 我需要将Word文档(docx)转换为postscript文件,以便我可以使用此postscript文件使用Ghostscript命令行工具生成PDF。

How do I generate the postscript file from the docx? 如何从docx生成postscript文件?

I need to code using .NET/C#. 我需要使用.NET / C#进行编码。 I found about LaTeX which generates postscript but how do I make my Word file be used with LaTeX or any other tool to get the postscript generated? 我找到了关于生成postscript的LaTeX但是如何让我的Word文件与LaTeX或任何其他工具一起使用来生成postscript?

There are three main products I will mention that understand DOCX. 我将提到三种主要产品,了解DOCX。

The obvious one is MS Word. 显而易见的是MS Word。 It produces the definitive rendering of all DOCX files. 它生成所有DOCX文件的最终呈现。 Nothing is ever going to be exactly the same. 什么都不会完全一样。 By definition it is always correct. 根据定义,它始终是正确的。 However it is not really designed for automated conversion and getting it to do this kind of thing is fraught with difficulty. 然而,它并不是真正设计用于自动转换,并且让它做这种事情充满了困难。 On a legal level the EULA may confict with your chosen solution. 在法律层面上,EULA可能会与您选择的解决方案相冲突。

OpenOffice.org is a great product. OpenOffice.org是一款出色的产品。 The EULA is much more accomodating. EULA更容易适应。 The freeness is attractive. 自由是有吸引力的。 However, while it will produce a pretty good output for most DOCX documents it does not for all. 然而,虽然它会为大多数DOCX文档产生相当好的输出,但它并不是全部。 While it is similar to MS Word it is not the same and this is something you may notice, particularly for more complex documents. 虽然它与MS Word类似但它并不相同,这是您可能会注意到的,特别是对于更复杂的文档。 Probably more importantly, again it's not designed for automated conversions and trying to get it to do this can be fraught and tiresome. 可能更重要的是,它不是为自动转换而设计的,试图让它做到这一点可能是充满烦恼和烦人的。

WordGlue .NET (on which I work) is a native .NET library that understands DOCX. WordGlue .NET(我工作)是一个理解DOCX的本机.NET库。 It is designed specifically to produce output which is the same as MS Word. 它专门用于生成与MS Word相同的输出。 While I'm not going to say it is perfect (it's a big task) it is superior to OpenOffice.org in that it does actually attempt this as a specfic design decision. 虽然我不会说它是完美的(这是一项重大任务)但它优于OpenOffice.org,因为它确实将此作为一个特定的设计决策。 However probably the biggest advantage is that it is designed for high perfomance multi-threaded server side conversion. 然而,最大的优势可能是它专为高性能多线程服务器端转换而设计。 It's native .NET and thus low impact in terms of security. 它是原生.NET,因此在安全性方面影响很小。

Products like ABCpdf (on which I work) will integrate with these three applicatons to allow conversion direct to PDF. ABCpdf(我工作的)等产品将与这三个应用程序集成,以允许直接转换为PDF。 Why bother going via PostScript if you want PDF? 如果你想要PDF,为什么还要通过PostScript? However if you really want to save as PostScript you can do that too. 但是,如果你真的想保存为PostScript,你也可以这样做。

Or indeed you can write your own code to integrate with these products. 或者您确实可以编写自己的代码来与这些产品集成。 Just be aware of the caveats above regarding fraughtness and tiresomeness relating to MS Office and OpenOffice.org. 请注意上面关于MS Office和OpenOffice.org相关的充满烦躁和烦躁的警告。 To get these things working unattended requires an awful lot of attention. 要让这些东西无人看管,需要大量的关注。

You need to print it to a PostScript file, from an application which can read .docx files. 您需要从可以读取.docx文件的应用程序将其打印到PostScript文件。 Or you could just export direct to PDf from the app, as far as I know anything which reads .docx and can print, can also write a PDF file. 或者您可以直接从应用程序导出到PDf,据我所知,任何读取.docx并且可以打印的内容,也可以编写PDF文件。

If you have a windows computer you can use the commandline 如果您有Windows计算机,则可以使用命令行

"%ProgramFiles%\Windows NT\Accessories\wordpad.exe" /pt foobaar.docx "printerThatDumpsPS"

You can find file printers for postscript printing for free on the internet. 您可以在互联网上免费找到用于postscript打印的文件打印机。 Or if you have adobe pfdf, pdf exchange or any PS printer. 或者如果您有adobe pfdf,pdf exchange或任何PS打印机。 You can use c# to temporarily set the printers settings so that it does this for you. 您可以使用c#临时设置打印机设置,以便它为您执行此操作。

So for example using pdf exchange as follows, 所以例如使用pdf exchange如下,

"%ProgramFiles%\Windows NT\Accessories\wordpad.exe" /pt foobaar.docx "PDF-XChange Printer 2012"

Produces a pdf file without much of a trace anywhere what program was used, assuming pdf exchange was set to save file without asking. 假设pdf exchange设置为保存文件而不询问,则生成一个pdf文件,无需在任何程序使用的地方进行任何跟踪。

This produces a passable document but yeah it looses quiet many features. 这产生了一个可通行的文件,但它是安静的许多功能。 But it might be enough. 但这可能就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM