This is a mirror of official site: http://jasper-net.blogspot.com/

PDF for Silverlight: Leveraging the Power of Silverlight to View PDF Documents and Forms

| Wednesday, January 19, 2011
Leveraging the Power of Silverlight to View PDF documents and Forms (Updated for Silverlight 3 and 4)

Using Microsoft Silverlight, developers can provide their users with content-rich web applications which can now include complex graphics and better interaction with users. Amyuni PDF for Silverlight provides the ability to display high quality PDF documents that are easily readable by users, compared to displaying documents as Jpeg images.

In this paper, we will show you:

How to use the Amyuni PDF components to dynamically view PDF documents within a Silverlight control
How to create a Silverlight 3 control to display and interact with PDF documents.
How to use the same control for viewing PDF, XPS or any type of document
Now that PDF has become the standard format for document storage and form processing in most corporations, your Silverlight applications can benefit from the ability to natively serve PDF documents and forms.

Requirements (Server Side)

The server-side code that converts the document into XAML and builds the ZIP package is very straight-forward (built into a HttpHandler)  and uses the Amyuni PDF Creator .NET:

Requirements (Client Side)

Any web browser running on any operating system with the Silverlight control versions 3.0 or higher. The sample PDFSilverlightControl will be automatically downloaded to the client by the Silverlight framework. No additional components need to be downloaded or run on the client PC.

Implementation

At first glance, viewing PDF documents within a Silverlight control looked like a 15-minute job. It would be sufficient to convert the PDF document into an XPS, which is a derivative of XAML, feed the XPS to the Silverlight control, add some bells and whistles and we were done. Converting a PDF, or any document for that matter, into an XPS can easily be achieved with the Amyuni PDF Creator; all that was needed is a way to feed the XPS into the Silverlight control. We were, however, faced with a number of challenges:

  1. Silverlight supports reading only a single XAML file. There is no mechanism by which one can feed multiple pages separately, nor is there a way to feed all the resources such as images and fonts used by that page. Silverlight provides no neat way of packaging a document the same way PDF and XPS do but requires all bits and pieces of a document to be created separately on the server and downloaded programmatically using the calling application. This precludes the ability to dynamically stream a document from a server to a client, which is a basic requirement of most applications.

Read more: Codeproject

Posted via email from .NET Info

0 comments: