I've got a need to display Office documents in a browser-based Silverlight application. The solution that I've got in place right now involves using Office Automation to convert the various Office docs to XPS, and then displaying the resulting XPS files in Silverlight with the FirstFloor Document Toolkit for Silverlight.
This works, but it's slow, and has a fair number of moving parts. Most notably, the Office Automation piece is particularly unstable, for all the known and obvious reasons.
The best alternative I can come up with is to purchase something like Aspose.Total to handle the document->XPS conversion piece. But Aspose is fairly expensive (at least $8K for our scenario), largely because it comes with a lot of functionality that I don't really need. I'll pay that if I have to, but before I do, I want to check to see if anyone else has any better ideas.
Suggestions on how to accomplish this? Basically, I need to allow users to upload Word/Excel/Powerpoint docs to a server, and display them (read-only is fine) in a browser-based Silverlight application. Any solutions out there that I've missed?
Edit: It looks like Electric Rain has a PPT-to-XAML converter that might be worth investigating for PPT files at least.
Edit: Another alternative to the FirstFloor Document Toolkit looks to be the PDFTron SilverDox product. It looks like its server component uses Office Automation, but once you get the doc into XPS, it looks like its client-side Silverlight viewer would work.
Rainbow PDF has server solution for $2000 http://rainbowpdf.com/server-based-solutions
:)
I had this issue, so I converted the Word Docs to PDF programatically. I now need to call the same name PDF file in the browser. (Doc1.docx to Doc1.pdf) You can use variables to call the documents. This is C# backend code that does the trick nicely. Also remember to add the reference to the Microsoft Word 12.0 Object Library. Call this method or make it a class. Then call the document after that.
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();
}
}
}