Welcome to MSDN Blogs Sign in | Join | Help

Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Earlier this week I was asked about an update to my SimpleSilverlightXpsViewer sample for the newly released Silverlight 2 Beta 2. (Background reading: Introductory Post, Beta 1 Update.) I spent a bit of time on this just now and migrating SimpleSilverlightXpsViewer to Beta 2 was very straightforward.

SimpleSilverlightXpsViewer Application

I've updated the SimpleSilverlightXpsViewer demonstration page and also the source code download, so you can try things out in your browser and/or download the code to see how it works!

Notes:

  • A project reference to System.Net needed to be added in order for WebClient to resolve properly. (This is covered in the "Breaking Changes" document.)
  • DependencyObject.SetValue no longer seems to automatically convert the type of its value parameter, so there were three places I changed an int to a double for consistency with the underlying DependencyProperty type (ex: "0"->"0.0").
  • The "disappearing page border" issue that showed up in Beta 1 still seems to be present in Beta 2, so I worked around it by changing the "pageGraphic" from a Rectangle[Fill/Stroke] to a Border[BorderBrush]+Grid[Background]. A web search turned up a couple of customer reports of this behavior for Shapes (Path, Rectangle, etc.), so it should be fixed for the final release of Silverlight.
  • I discovered and fixed a bug with the math behind the zoom slider that could cause problems when the browser window was made very small. (This bug was unrelated to Beta 2.)

SimpleSilverlightXpsViewer is a fun project that really seems to resonate with people; folks have told me all kinds of neat ideas they had while playing around with it. In fact, if all goes well, there just might be a cool, practical, relevant use of SimpleSilverlightXpsViewer that I'll be able to share sometime soon... :)

Published Friday, June 13, 2008 12:35 AM by Delay
Filed under:

Comments

# Silverlight Cream for June 13, 2008 -- #299

Friday, June 13, 2008 9:07 PM by Community Blogs

14 posts in the last 24 hours! -- Silverlight Girl with "Bumble Beegger", Piotr Puszkiewicz

# Silverlight XPS olvasó

Saturday, June 14, 2008 11:07 AM by VBandi

Az XPS ugye a Microsoft PDF-e, ha egy mondatban akarjuk megfogalmazni. Itt van egy  Silverlight

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Wednesday, July 02, 2008 4:04 PM by samcov

Can we simply use XPS files saved from Word 2007 with this code?

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Wednesday, July 02, 2008 5:41 PM by Delay

samcov,

I believe that Word 2007 XPS documents do not work by default. I touch on this briefly in the "Introductory Post" I link to above where I first announced the XPS Viewer sample. Basically, the sample supports only the file structure that the XPS Printer Driver outputs because that's what I had to work with. Any variations on the XPS internal document structure would likely require some changes to the code to support. I don't recall exactly whether Word 2007 documents are the same, but I think I remember checking and finding them different.

Hope this helps!

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Thursday, July 03, 2008 5:11 PM by samcov

I tried to create the file using the XPS document writer, but it only outputs a XPS file, and not the additional files you seem to get.

I'm not sure how you created the printer files.

Sam...

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Thursday, July 03, 2008 6:00 PM by Delay

samcov,

FYI, with the Beta 2 version of the XPS Viewer sample, it is necessary to extract only the font (*.odttf) files and place them alongside the XPS file.

A good workflow (that includes re-ZIPping the XPS files which is often necessary) goes something like: get content you want to view in an application, print it to the XPS Printer Driver, save that output as file Intro.XPS, rename it to Intro.XPS.zip, extract all files to \Intro directory with Windows or other ZIP tool, delete Intro.XPS.zip, create new Intro.XPS.zip file from \Intro directory with Windows or other ZIP tool, rename Intro.XPS.zip to Intro.XPS, copy all *.odttf files from under \Intro to the same location as the new Intro.XPS file, copy Intro.XPS and *.odttf to the \Intro.XPS subdirectory that is part of the XPS Viewer Sample (replacing the existing Intro.XPS file and fonts), run XPS Viewer Sample - and you should see your content instead of the default Intro page.

It's that "easy"! :)

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Tuesday, July 08, 2008 3:17 AM by samcov

I thought I posted this, but it hasn't appeared.

Anyway, it worked EXACTLY as you outlined it... Thanks!

It appears that re-zipping is crutial for some reason.

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Monday, July 14, 2008 9:20 AM by jidizhiguang

It works fine in IIS5.1,but in IIS 6.0 an IIS 7.0 the font does not display, and a downloaderror #4001 occured,Why?

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Monday, July 14, 2008 1:04 PM by Delay

jidizhiguang,

I'll guess that your IIS 6 and 7 configuration is such that *.odttf is not a supported file type for download. You can verify this by trying to download a .odttf file directly from a browser. I expect it to work for your IIS 5.1, but fail from 6 and 7. You should be able to easily fix this by adding *.odttf as a supported file type for download for your IIS 6 and 7 installs.

Hope this helps!

# Smaller is better! [A simple step to shrink the download size of Silverlight 2 applications]

Thursday, July 17, 2008 1:50 AM by Delay's Blog

When putting content on the web, it's important to get that content to the user as quickly as possible.

# Read about Silverlight in XPS

Tuesday, July 29, 2008 5:29 PM by Silverlight: Laurence Moroney's Blog

del.icio.us Tags: Silverlight       Technorati Tags: Silverlight       

# Read a Silverlight book - with Silverlight! [SimpleSilverlightXpsViewer adaptation by Laurence Moroney]

Wednesday, July 30, 2008 2:11 AM by Delay's Blog

At the bottom of the post on migrating SimpleSilverlightXpsViewer to Silverlight Beta 2 , I hinted at

# Everything is a link in the chain

Wednesday, July 30, 2008 6:05 PM by Adrian Ford on XPS et cetera

Or maybe everything is in a cycle... Develop XPS , awesome fixed format document and print stream format

# Read about Silverlight… in Silverlight

Tuesday, August 05, 2008 10:55 AM by Me about things...

Laurence Moroney just published a blog post in which he adapted David Anson's XPS Viewer for Silverlight

# Read about Silverlight… in Silverlight

Tuesday, August 05, 2008 10:55 AM by Me about things...

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Wednesday, August 06, 2008 3:55 AM by hjpavelka

I convertet some pdf files to xps with the XPS Document writer.

However, If I unzip and re-zip them they stop working! I did not change any content.

Even the regular viewer can not display them anymore - it displays an exception:

System.ArgumentException: The document does not contain a valid FixedDocumentSequence.

at

MS.Internal.Documents.DigitalSignatureProvider..ctor(Package package)

what is the issue here?

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Wednesday, August 06, 2008 1:10 PM by Delay

hjpavelka,

Something about how you're rezipping the files seems to be going wrong. What I'm guessing is happening is that the file structure is getting changed when you re-zip - possibly the addition of another directory level at the root, or the absence of the subdirectories. You probably want to compare the contents of the XAP.zip files before and after the re-ZIP process to be sure they're structurally identical. The syntax and default behavior of various ZIP tools is fairly different, so you may need to check the documentation for your particular tool to find out just what settings are needed.

Hope this helps!

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Monday, September 15, 2008 6:00 AM by mrtmrcn

i try to open my xps file

create a folder named : Step1.xps

i use print out in Step1.xps folder and named :Step1.xps

extract the fonts ant put it on Step1.xps folder but that's give me an error :XML_MissingRoot

# re: Proof-of-concept Silverlight XPS reader comes to Beta 2 [SimpleSilverlightXpsViewer sample updated for Silverlight 2 Beta 2!]

Monday, September 15, 2008 1:19 PM by Delay

mrtmrcn,

Every time I've gotten a problem report like this so far, it has been solved by re-ZIPping the XPS file. Please see the notes in the post and the comments above for details on how to re-ZIP. If that doesn't work, then something about the XML structure of your file seems to be unusual. The next thing would be to check that the file was generated with the XPS Printer Driver because other techniques are known to produce different file structures that aren't recognized by the sample application.

Hope this helps!

# Roadblock in the way of migrating the proof-of-concept Silverlight XPS reader [SimpleSilverlightXpsViewer sample does not work on Silverlight 2 RTW]

Saturday, October 18, 2008 3:07 AM by Delay's Blog

Since the public release of Microsoft Silverlight 2 , I've gotten a few internal and external requests

# Fix for Simple XPS Silverlight Viewer for Silverlight 2

Monday, November 24, 2008 12:28 AM by Li Chen's Weblog

Fix for Simple XPS Silverlight Viewer for Silverlight 2

Anonymous comments are disabled
 
Page view tracker