How do I convert Word files to PDF programmaticall

2018-12-31 06:49发布

I have found several open-source/freeware programs that allow you to convert .doc files to .pdf files, but they're all of the application/printer driver variety, with no SDK attached.

I have found several programs that do have an SDK allowing you to convert .doc files to .pdf files, but they're all of the proprietary type, $2,000 a license or thereabouts.

Does anyone know of any clean, inexpensive (preferably free) programmatic solution to my problem, using C# or VB.NET?

Thanks!

15条回答
回忆,回不去的记忆
2楼-- · 2018-12-31 07:45

I do this as part of a release process - convert a Word Doc to PDF.

http://www.suodenjoki.dk/us/productions/articles/word2pdf.htm and http://www.oooforum.org/forum/viewtopic.phtml?t=3772&highlight=pdf+form

not exactly programmatically, but may help you.

查看更多
人气声优
3楼-- · 2018-12-31 07:46

I used ABCpdf which is a programmatic option and wasn't too expensive, $300/license. It works with either OpenOffice, or falls back to Word if OpenOffice isn't available. The setup was a bit tricky with the OpenOffice COM permissions, but it was definitely worth outsourcing that part of the app.

查看更多
骚的不知所云
4楼-- · 2018-12-31 07:46

As long as you have Word 2010 or later installed you can use DocTo which provides a commandline application to do this.

查看更多
泪湿衣
5楼-- · 2018-12-31 07:48

Microsoft PDF add-in for word seems to be the best solution for now but you should take into consideration that it does not convert all word documents correctly to pdf and in some cases you will see huge difference between the word and the output pdf. Unfortunately I couldn't find any api that would convert all word documents correctly. The only solution I found to ensure the conversion was 100% correct was by converting the documents through a printer driver. The downside is that documents are queued and converted one by one, but you can be sure the resulted pdf is exactly the same as word document layout. I personally preferred using UDC (Universal document converter) and installed Foxit Reader(free version) on server too then printed the documents by starting a "Process" and setting its Verb property to "print". You can also use FileSystemWatcher to set a signal when the conversion has completed.

查看更多
妖精总统
6楼-- · 2018-12-31 07:50
其实,你不懂
7楼-- · 2018-12-31 07:51

I have used iTextSharp to generate PDFs before. It's an open source port of iText from the Java world and is pretty powerful.

I haven't explicitly done a Word to PDF conversion, but I have programmatically created and manipulated PDFs with it.

Here is another link to to the project.

查看更多
登录 后发表回答