基于Microsoft Word模板生成PDF文档

时间:2022-03-10 21:09:54

I need to take a Word document that is a template of sorts...collect user input to populate specific fields in that template..then generate a PDF file that includes the completed template as well as a few other document types. Does anyone have a good suggestion on a component to achieve this? Preferably one that does not require Microsoft Office to be installed on the web server.

我需要一个Word文档,这是一个类别的模板...收集用户输入以填充该模板中的特定字段..然后生成一个PDF文件,其中包括已完成的模板以及一些其他文档类型。有没有人对组件有一个很好的建议来实现这个目标?优选地,不需要在Web服务器上安装Microsoft Office。

7 个解决方案

#1


6  

Try Aspose Words for .net. From their website: "Aspose.Words enables .NET and Java applications to read, modify and write Word® documents without utilizing Microsoft Word." Utilizing Aspose Words with Aspose PDF permits you to output to PDF.

尝试.net的Aspose Words。从他们的网站:“Aspose.Words使.NET和Java应用程序能够在不使用Microsoft Word的情况下读取,修改和编写Word®文档。”使用Aspose Word和Aspose PDF可以输出到PDF。

One thing you do NOT want to do is install MS Word on your production server. Loading those objects is SLOW and EATS memory. You won't be able to use the CutePDF Writer unless you also install MS Word on the server. Yeck.

您不想做的一件事是在生产服务器上安装MS Word。加载这些对象是SLOW和EATS内存。除非您还在服务器上安装MS Word,否则您将无法使用CutePDF Writer。 Yeck。

#2


0  

Is there a reason to use Word? If you start with a PDF with Form fields, you can either allow the user to fill out the fields, or do it programatically with iTextSharp's PDF stamper.

是否有理由使用Word?如果您从带有表单字段的PDF开始,您可以允许用户填写字段,或者使用iTextSharp的PDF压模以编程方式进行编程。

If you need to use MSOffice 2000/2003 components programmatically, you can try Office Web Components. They do need to be installed on the server, but can be used by .NET and Com apps to interact with office file types. More info here...http://en.wikipedia.org/wiki/Office_Web_Components

如果需要以编程方式使用MSOffice 2000/2003组件,则可以尝试使用Office Web Components。它们确实需要安装在服务器上,但.NET和Com应用程序可以使用它们与office文件类型进行交互。更多信息,请访问... http://en.wikipedia.org/wiki/Office_Web_Components

If you dig about on an office CD you should find the OWC installer for your version. I haven't worked with 2007, but I assume there is something similar available.

如果你在办公室CD上挖掘,你应该找到你的版本的OWC安装程序。我没有和2007年合作,但我认为有类似的东西可用。

iTextSharp and OWC are no-cost, check the licensing for more details.

iTextSharp和OWC是免费的,请查看许可以获取更多详细信息。

#3


0  

Hmmm...You might be able to employ CutePDF printer in a creative way to solve this problem. Essentially, it takes anything that can be fed through a standard print driver and makes a PDF out of it. It's free.

嗯......您可以以创造性的方式使用CutePDF打印机来解决这个问题。从本质上讲,它需要通过标准打印驱动程序提供的任何内容,并从中生成PDF。免费。

#4


0  

Try using The Apache POI API to populate the fields. It can get into Word documents and access their elements.

尝试使用Apache POI API填充字段。它可以进入Word文档并访问其元素。

As for the Word -> PDF step, I'd also recommend evaluating the Aspose solution. It may even be able to perform both steps. Its not free, however.

至于Word - > PDF步骤,我还建议您评估Aspose解决方案。它甚至可以执行这两个步骤。然而,它不是免费的。

#5


0  

My first thought for a "doc template" + merge to pdf solution would be to start with open office formats. - the odt file (open document template) is xml-based - so you could even use perl, to do the merge, then call writer's doc 2 pdf (I have no idea if they have an API, but one could find out in less than a day - even if one had to examine the source.)

我对“doc模板”+合并到pdf解决方案的第一个想法是从开放式办公室格式开始。 - odt文件(打开文档模板)是基于xml的 - 所以你甚至可以使用perl来进行合并,然后调用writer的doc 2 pdf(我不知道他们是否有API,但是可以找到更少的比一天 - 即使必须检查来源。)

and converting your "word" dot to a writer odt file is just a "file save as" operation in OoWriter.

并将“word”点转换为writer odt文件只是OoWriter中的“文件另存为”操作。

#6


0  

If you use Aspose.Words, then your input document/template can be in one of the several supported formats including DOC, DOCX.

如果您使用Aspose.Words,那么您的输入文档/模板可以是几种支持的格式之一,包括DOC,DOCX。

Then you can insert data into the document in a number of ways. You can use bookmarks in a document and just set their text. Or better yet use the reporting engine we provide. It allows to use standard MS Word MERGEFIELD fields plus adds capabilities for repeating regions and even nested. E.g. you can design an invoice (with parent/child data) template in MS Word and then populate from a .NET DataSet in one line of code.

然后,您可以通过多种方式将数据插入到文档中。您可以在文档中使用书签,只需设置文本即可。或者更好地使用我们提供的报告引擎。它允许使用标准MS Word MERGEFIELD字段,并添加重复区域甚至嵌套的功能。例如。您可以在MS Word中设计发票(带有父/子数据)模板,然后在一行代码中从.NET DataSet填充。

Also, you only need Aspose.Words to produce PDF (a year ago you needed both Aspose.Words and Aspose.Pdf). You can also easily save the exactly the same looking document to DOC, DOC, DOCX and a few other formats.

此外,您只需要Aspose.Words来生成PDF(一年前您需要Aspose.Words和Aspose.Pdf)。您还可以轻松地将完全相同的文档保存为DOC,DOC,DOCX和其他一些格式。

I'm on the Aspose.Words dev team.

我在Aspose.Words开发团队。

#7


0  

Have a look at the Muhimbi PDF Converter Web Services. It runs on Windows as a service, but can be accessed from any non-Windows web services capable environment including Java and .NET.

看看Muhimbi PDF Converter Web Services。它作为服务在Windows上运行,但可以从任何非Windows Web服务环境(包括Java和.NET)访问。

Although this solutions requires MS-Office to be installed on a server (not necessarily the same server as your application), it is very robust and provides perfect conversion fidelity.

虽然这种解决方案要求MS-Office安装在服务器上(不一定与您的应用程序相同),但它非常强大并且提供了完美的转换保真度。

To generate or Modify MS-Word files I recommend using the free Open XML SDK for Microsoft Office. Eric White maintains a really good Blog about it.

要生成或修改MS-Word文件,我建议使用免费的Open XML SDK for Microsoft Office。 Eric White维护着一个非常好的博客。

Disclaimer, I worked on this product. Having said that, it works great.

免责声明,我参与了这个产品。话虽如此,它的效果很好。

#1


6  

Try Aspose Words for .net. From their website: "Aspose.Words enables .NET and Java applications to read, modify and write Word® documents without utilizing Microsoft Word." Utilizing Aspose Words with Aspose PDF permits you to output to PDF.

尝试.net的Aspose Words。从他们的网站:“Aspose.Words使.NET和Java应用程序能够在不使用Microsoft Word的情况下读取,修改和编写Word®文档。”使用Aspose Word和Aspose PDF可以输出到PDF。

One thing you do NOT want to do is install MS Word on your production server. Loading those objects is SLOW and EATS memory. You won't be able to use the CutePDF Writer unless you also install MS Word on the server. Yeck.

您不想做的一件事是在生产服务器上安装MS Word。加载这些对象是SLOW和EATS内存。除非您还在服务器上安装MS Word,否则您将无法使用CutePDF Writer。 Yeck。

#2


0  

Is there a reason to use Word? If you start with a PDF with Form fields, you can either allow the user to fill out the fields, or do it programatically with iTextSharp's PDF stamper.

是否有理由使用Word?如果您从带有表单字段的PDF开始,您可以允许用户填写字段,或者使用iTextSharp的PDF压模以编程方式进行编程。

If you need to use MSOffice 2000/2003 components programmatically, you can try Office Web Components. They do need to be installed on the server, but can be used by .NET and Com apps to interact with office file types. More info here...http://en.wikipedia.org/wiki/Office_Web_Components

如果需要以编程方式使用MSOffice 2000/2003组件,则可以尝试使用Office Web Components。它们确实需要安装在服务器上,但.NET和Com应用程序可以使用它们与office文件类型进行交互。更多信息,请访问... http://en.wikipedia.org/wiki/Office_Web_Components

If you dig about on an office CD you should find the OWC installer for your version. I haven't worked with 2007, but I assume there is something similar available.

如果你在办公室CD上挖掘,你应该找到你的版本的OWC安装程序。我没有和2007年合作,但我认为有类似的东西可用。

iTextSharp and OWC are no-cost, check the licensing for more details.

iTextSharp和OWC是免费的,请查看许可以获取更多详细信息。

#3


0  

Hmmm...You might be able to employ CutePDF printer in a creative way to solve this problem. Essentially, it takes anything that can be fed through a standard print driver and makes a PDF out of it. It's free.

嗯......您可以以创造性的方式使用CutePDF打印机来解决这个问题。从本质上讲,它需要通过标准打印驱动程序提供的任何内容,并从中生成PDF。免费。

#4


0  

Try using The Apache POI API to populate the fields. It can get into Word documents and access their elements.

尝试使用Apache POI API填充字段。它可以进入Word文档并访问其元素。

As for the Word -> PDF step, I'd also recommend evaluating the Aspose solution. It may even be able to perform both steps. Its not free, however.

至于Word - > PDF步骤,我还建议您评估Aspose解决方案。它甚至可以执行这两个步骤。然而,它不是免费的。

#5


0  

My first thought for a "doc template" + merge to pdf solution would be to start with open office formats. - the odt file (open document template) is xml-based - so you could even use perl, to do the merge, then call writer's doc 2 pdf (I have no idea if they have an API, but one could find out in less than a day - even if one had to examine the source.)

我对“doc模板”+合并到pdf解决方案的第一个想法是从开放式办公室格式开始。 - odt文件(打开文档模板)是基于xml的 - 所以你甚至可以使用perl来进行合并,然后调用writer的doc 2 pdf(我不知道他们是否有API,但是可以找到更少的比一天 - 即使必须检查来源。)

and converting your "word" dot to a writer odt file is just a "file save as" operation in OoWriter.

并将“word”点转换为writer odt文件只是OoWriter中的“文件另存为”操作。

#6


0  

If you use Aspose.Words, then your input document/template can be in one of the several supported formats including DOC, DOCX.

如果您使用Aspose.Words,那么您的输入文档/模板可以是几种支持的格式之一,包括DOC,DOCX。

Then you can insert data into the document in a number of ways. You can use bookmarks in a document and just set their text. Or better yet use the reporting engine we provide. It allows to use standard MS Word MERGEFIELD fields plus adds capabilities for repeating regions and even nested. E.g. you can design an invoice (with parent/child data) template in MS Word and then populate from a .NET DataSet in one line of code.

然后,您可以通过多种方式将数据插入到文档中。您可以在文档中使用书签,只需设置文本即可。或者更好地使用我们提供的报告引擎。它允许使用标准MS Word MERGEFIELD字段,并添加重复区域甚至嵌套的功能。例如。您可以在MS Word中设计发票(带有父/子数据)模板,然后在一行代码中从.NET DataSet填充。

Also, you only need Aspose.Words to produce PDF (a year ago you needed both Aspose.Words and Aspose.Pdf). You can also easily save the exactly the same looking document to DOC, DOC, DOCX and a few other formats.

此外,您只需要Aspose.Words来生成PDF(一年前您需要Aspose.Words和Aspose.Pdf)。您还可以轻松地将完全相同的文档保存为DOC,DOC,DOCX和其他一些格式。

I'm on the Aspose.Words dev team.

我在Aspose.Words开发团队。

#7


0  

Have a look at the Muhimbi PDF Converter Web Services. It runs on Windows as a service, but can be accessed from any non-Windows web services capable environment including Java and .NET.

看看Muhimbi PDF Converter Web Services。它作为服务在Windows上运行,但可以从任何非Windows Web服务环境(包括Java和.NET)访问。

Although this solutions requires MS-Office to be installed on a server (not necessarily the same server as your application), it is very robust and provides perfect conversion fidelity.

虽然这种解决方案要求MS-Office安装在服务器上(不一定与您的应用程序相同),但它非常强大并且提供了完美的转换保真度。

To generate or Modify MS-Word files I recommend using the free Open XML SDK for Microsoft Office. Eric White maintains a really good Blog about it.

要生成或修改MS-Word文件,我建议使用免费的Open XML SDK for Microsoft Office。 Eric White维护着一个非常好的博客。

Disclaimer, I worked on this product. Having said that, it works great.

免责声明,我参与了这个产品。话虽如此,它的效果很好。