首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Silverlight中显示Office文档

在Silverlight中显示Office文档
EN

Stack Overflow用户
提问于 2011-07-14 18:02:59
回答 2查看 4K关注 0票数 1

我需要在基于浏览器的Silverlight应用程序中显示Office文档。我现在找到的解决方案包括使用Office自动化将各种Office文档转换为XPS,然后使用Silverlight的FirstFloor文档工具包在Silverlight中显示产生的XPS文件。

这是工作的,但它是缓慢的,并有相当数量的移动部分。最值得注意的是,由于所有已知和明显的原因,Office自动化部分特别不稳定。

我能想到的最好的选择是购买像Aspose.Total这样的东西来处理文档->XPS转换部分。但是Aspose相当昂贵(在我们的场景中至少是8K美元),这很大程度上是因为它附带了很多我并不真正需要的功能。如果有必要的话,我会付钱的,但在此之前,我想看看是否还有其他人有更好的想法。

关于如何做到这一点的建议?基本上,我需要允许用户将Word/Excel/Powerpoint文档上传到服务器,并在基于浏览器的Silverlight应用程序中显示它们(只读很好)。有我错过的解决办法吗?

  • 编辑:看起来电雨有一个PPT转换器,至少值得对PPT文件进行调查。
  • 编辑: FirstFloor文档工具包的另一个替代方案看起来是PDFTron SilverDox产品。看起来它的服务器组件使用了Office自动化,但是一旦您将文档输入到XPS中,它的客户端Silverlight查看器就可以工作了。
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-07-14 21:38:49

彩虹PDF有2000美元http://rainbowpdf.com/server-based-solutions的服务器解决方案

:)

票数 1
EN

Stack Overflow用户

发布于 2011-10-13 12:02:55

我有这个问题,所以我用编程把Docs这个词转换成PDF格式。我现在需要在浏览器中调用相同的名称PDF文件。(Doc1.docx到Doc1.pdf)您可以使用变量来调用文档。这是C#后端代码,它很好地发挥了作用。还记得添加对Microsoft 12.0对象库的引用。调用此方法或使其成为类。然后再打电话给文档。

代码语言:javascript
复制
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.Office.Interop.Word;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ApplicationClass wordApplication = new ApplicationClass();
        Document wordDocument = null;

        object paramSourceDocPath = @"D:\Websites\Docs\Doc1.docx";
        object paramMissing = Type.Missing;
        string paramExportFilePath = @"D:\Websites\Docs\Doc1.pdf";
        WdExportFormat paramExportFormat = WdExportFormat.wdExportFormatPDF;

        bool paramOpenAfterExport = false;
        WdExportOptimizeFor paramExportOptimizeFor = WdExportOptimizeFor.wdExportOptimizeForPrint;
        WdExportRange paramExportRange = WdExportRange.wdExportAllDocument;

        int paramStartPage = 0;
        int paramEndPage = 0;
        WdExportItem paramExportItem = WdExportItem.wdExportDocumentContent;

        bool paramIncludeDocProps = true;
        bool paramKeepIRM = true;
        WdExportCreateBookmarks paramCreateBookmarks = WdExportCreateBookmarks.wdExportCreateWordBookmarks;

        bool paramDocStructureTags = true;
        bool paramBitmapMissingFonts = true;
        bool paramUseISO19005_1 = false;

        try
        {
            // Open the source document.
            wordDocument = wordApplication.Documents.Open(
                ref paramSourceDocPath,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing,
                ref paramMissing, 
                ref paramMissing,
                ref paramMissing);

            // Export it in the specified format.
            if (wordDocument != null)
                wordDocument.ExportAsFixedFormat(
                    paramExportFilePath, 
                    paramExportFormat,
                    paramOpenAfterExport,
                    paramExportOptimizeFor, 
                    paramExportRange,
                    paramStartPage,
                    paramEndPage, 
                    paramExportItem,
                    paramIncludeDocProps,
                    paramKeepIRM, 
                    paramCreateBookmarks,
                    paramDocStructureTags,
                    paramBitmapMissingFonts,
                    paramUseISO19005_1,
                    ref paramMissing);
        }
        catch (Exception ex)
        {
            // Respond to the error
        }
        finally
        {
            // Close and release the Document object.
            if (wordDocument != null)
            {
                wordDocument.Close(ref paramMissing, ref paramMissing, ref paramMissing);
                wordDocument = null;
            }

            // Quit Word and release the ApplicationClass object.
            if (wordApplication != null)
            {
                wordApplication.Quit(ref paramMissing, ref paramMissing, ref paramMissing);
                wordApplication = null;
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6697847

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档