PDF Viewer from Lightswitch

Feb 19, 2012 at 3:24 PM

Many of my PDF documents do not render, but some do.  This is displayed by the viewer when it can't render a document:

Failed to Render Page
 
Failed to load package part '1.fpage'
Description: An exception occurred during the rendering of this page. Please review the stacktrace for more information about the error.
Exception Details:FirstFloor.Documents.IO.XpsClientException: Failed to load package part '1.fpage' ---> System.Collections.Generic.KeyNotFoundException: Resources   at FirstFloor.Documents.Pdf.DictionaryObject.Get[T](String key)   at FirstFloor.Documents.Pdf.PageParserContext.Create(DictionaryObject pageObject, XmlWriter writer, LoadSettings settings)   at FirstFloor.Documents.Pdf.PageParser.Parse(DictionaryObject pageObject, LoadSettings settings)   at FirstFloor.Documents.Pdf.PdfParser.ParsePage(Int32 pageNumber, LoadSettings settings)   at FirstFloor.Documents.Pdf.PdfDocument.GetPageXaml(Int32 pageNumber, LoadSettings settings)   at FirstFloor.Documents.Pdf.PdfDocumentReader.GetPageXaml(Int32 pageNumber)   at FirstFloor.Documents.IO.MemoryPackageReader.(Int32 )   at FirstFloor.Documents.IO.MemoryPackageReader.CreatePartRequest(Uri partUri)   at FirstFloor.Documents.IO.XpsClient.(IPackageReader , Uri , Boolean )   at FirstFloor.Documents.IO.XpsClient.(IPackageReader , Uri , Boolean , Boolean )   --- End of inner exception stack trace ---   at FirstFloor.Documents.IO.XpsClient.(IPackageReader , Uri , Boolean , Boolean )   at FirstFloor.Documents.IO.XpsClient.(XpsPartBase , Boolean , Boolean )   at FirstFloor.Documents.IO.XpsClient.(XpsPartBase , Boolean )   at ..(XpsClient , PageContent , LoadFixedPageSettings )   at FirstFloor.Documents.IO.XpsClient.(PageContent , LoadFixedPageSettings )

Feb 20, 2012 at 1:00 AM

One thing I have noticed is if you build the application with SL 4 and a users has the 5.+ runtime installed, the pdf package reader does not work consistently. But if the runtimes match, the package reader works perfectly (minus a couple extreme cases with odd pdf's).

 

if the clients runtime folder looks like this: C:\Program Files (x86)\Microsoft Silverlight\4.1.10111.0

and you built it with SL 4, then your all good.

, but if it looks like : C:\Program Files (x86)\Microsoft Silverlight\5.?+++

then the client must revert to the 4.1.10111.0 runtime by uninstalling, and reinstalling.

 

But that was just my experience.

 

 

Coordinator
Feb 20, 2012 at 11:55 AM

The open source PDF engine of Document Toolkit only implements parts of the PDF specification. Correct rendering of PDF documents is not guaranteed, and there is no workaround for this. The PDF engine works best with PDF documents that contain embedded OpenType fonts. The Microsoft Office Save-As-PDF add-in does create such documents.

PDF rendering is not related to Silverlight 4 or 5. The NuGet packages contains versions for both SL4 and 5.


- Koen