转换DOC/DOCX为PNG [英] Convert DOC / DOCX to PNG

查看:132
本文介绍了转换DOC/DOCX为PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个将doc/docx转换为png格式的Web服务.

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方专用库(如上述库)中,或者例如在

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆