将 DOC/DOCX 转换为 PNG [英] Convert DOC / DOCX to PNG
问题描述
我正在尝试创建一个将 doc/docx 转换为 png 格式的网络服务.
I am trying to create a web service that will convert a doc/docx to png format.
我似乎遇到的问题是我找不到任何库或接近它的东西来满足我的需要,考虑到我正在寻找免费的东西而不是依赖于 Office 的东西(运行应用程序的服务器没有安装了 Office).
The problem I seem to have is I can't find any library or something close to it that will do what I need, considering I am looking for something free and not Office dependent (the server where the app will run does not have Office installed).
有什么可以帮助我获得这个吗?或者我必须在使用依赖于办公室的东西(比如 Interop - 顺便说一句,我读到的东西在服务器上使用真的很糟糕)或不是免费的东西之间做出选择?
Is there anything that can help me in obtaining this? Or must I choose between using something office dependant (like Interop - which btw I read is really bad to be used on server) or something that isn't free?
谢谢
推荐答案
是的,这种复杂的文件类型转换通常是 在专业/第 3 方库中很好地实施(如前面提到的),或者,例如,在 DevExpress 文档自动化:
Yes, such complex file types conversions are usually well implemented in the specialized / 3-rd party libraries (like in the aforementioned one), or, for example, in the DevExpress Document Automation:
using System;
using System.Drawing.Imaging;
using System.IO;
using DevExpress.XtraPrinting;
using DevExpress.XtraRichEdit;
using(MemoryStream streamWithWordFileContent = new MemoryStream()) {
//Populate the streamWithWordFileContent object with your DOC / DOCX file content
RichEditDocumentServer richContentConverter = new RichEditDocumentServer();
richContentConverter.LoadDocument(streamWithWordFileContent, DocumentFormat.Doc);
//Save
PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
pcl.Component = richContentConverter;
pcl.CreateDocument();
ImageExportOptions options = new ImageExportOptions(ImageFormat.Png);
//Paging
//options.ExportMode = ImageExportMode.SingleFilePageByPage;
//options.PageRange = "1";
pcl.ExportToImage(MapPath(@"~/DocumentAsImageOnDisk.png"), options);
}
这篇关于将 DOC/DOCX 转换为 PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!