有没有办法将word文件的字节数组转换为pdf的字节数组?
问题描述:
有没有办法将word文件的字节数组转换为pdf的字节数组我提到我的系统中没有安装word。
我尝试了什么:
我试过
Is there any way to convert Byte array of word file to byte array of pdf I mentioning that I don't have word install in my system.
What I have tried:
I have tried with
Microsoft.Office.Interop.Word
但要使用这个我必须在我的系统中安装Word。
but to use this I have to install Word in my system.
答
你需要一个或两个库:
一个可以读取Word文件和可以创建PDF文件的文件,其中第一个输出的格式是第二个(如RTF或HTML)支持的格式或支持直接转换的单个库。
但请注意,结果可能与预期不符;特别是复杂的Word文档。
我不知道一个好的免费C#Word库,但有商业的,如 Aspose.Word 这也可以创建PDF文件。
在网上搜索c#word to pdf会告诉你这个问题已经被提出并回答:
使用Foxit将doc / docx文档转换为PDF读者 [ ^ ]
如何在C#中将word文档转换为pdf [ ^ ]
c# - 如何以编程方式将Word文件转换为PDF? - 堆栈溢出 [ ^ ]
You would need one or two libraries:
One that can read Word files and one that can create PDF files where the output from the first is in a format supported by the second (like RTF or HTML) or a single library that supports direct conversion.
But be aware that the results might not be as expected; especially with complex Word documents.
I don't know of a good free C# Word library but there are commercial ones like Aspose.Word which can also create PDF files.
Searching the web for "c# word to pdf" will show you that this has been asked and answered before:
Convert doc/docx Documents to PDF with Foxit Reader[^]
How to convert word document to pdf in C#[^]
c# - How do I convert Word files to PDF programmatically? - Stack Overflow[^]