【问题标题】:Displaying Office documents in Silverlight在 Silverlight 中显示 Office 文档
【发布时间】:2012-01-01 13:35:38
【问题描述】:

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

这行得通,但速度很慢,并且有很多活动部件。最值得注意的是,由于所有已知和明显的原因,办公自动化部分特别不稳定。

我能想到的最佳选择是购买类似Aspose.Total 的东西来处理文档->XPS 转换片。但是 Aspose 相当昂贵(我们的场景至少要 8000 美元),主要是因为它带有很多我并不真正需要的功能。如果需要,我会付钱,但在我付钱之前,我想看看其他人是否有更好的想法。

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

  • 编辑:看起来Electric Rain 有一个 PPT-to-XAML 转换器,至少对于 PPT 文件可能值得研究。

  • 编辑:FirstFloor Document Toolkit 的另一个替代品看起来是PDFTron SilverDox 产品。看起来它的服务器组件使用了 Office 自动化,但是一旦你将文档导入 XPS,它的客户端 Silverlight 查看器似乎就可以工作了。

【问题讨论】:

  • 为什么不直接将这些文档转换为图像。这样做服务器端应该不会太难。
  • 静态图像可能就足够了——但据我所知,这样做的唯一选项与转换为 XPS 的选项基本相同,即进入 Office 自动化或使用 Aspose。我想知道是否还有其他选择。
  • 我确信存在更多可以将办公文档转换为图像(而不是 XPS)的提供商。例如,Rainbow PDF 有 $2000 的服务器解决方案rainbowpdf.com/server-based-solutions
  • VeryDoc doc2any.exe 实际上似乎在幕后使用 Office 自动化。 (这是我看过的其中之一。)但我以前没有见过 RainbowPDF 选项。我会调查的。谢谢! (如果你把它移到下面,我会把它标记为答案。)

标签: silverlight ms-office xps


【解决方案1】:

Rainbow PDF 有服务器解决方案,售价 2000 美元http://rainbowpdf.com/server-based-solutions

:)

【讨论】:

    【解决方案2】:

    我遇到了这个问题,所以我以编程方式将 Word Docs 转换为 PDF。我现在需要在浏览器中调用同名的 PDF 文件。 (Doc1.docx to Doc1.pdf) 可以使用变量来调用文档。这是一个很好的 C# 后端代码。还记得添加对 Microsoft Word 12.0 对象库的引用。调用此方法或使其成为一个类。然后调用文档。

    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();
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 2012-03-25
      • 1970-01-01
      • 2015-02-05
      • 1970-01-01
      • 1970-01-01
      • 2020-01-23
      相关资源
      最近更新 更多