views:

252

answers:

2

Hi all,

I’m in the design phase of a project at the moment and the client wants a desktop app they can use to view and annotate “any” type of document. I’ve been doing some research into the WPF document viewer and XPS documents and it seems like a perfect fit because using the XPS document writer, you can print anything to an xps document and easily view it in your WPF app. I’ve tested this with a few different document types (PDF, web pages, word documents, etc etc) and the results have been very impressive. I wanted to stay away from the Adobe PDF reviewing tool, because dealing with their APIs is likely to be difficult and I wanted to design an all-MS solution if possible.

Another major advantage of XPS is that we can use the WPF annotation framework (System.Windows.Annotations), but my problem is that this framework is a good start, but the client is going to want richer features that the framework doesn’t provide, like the following:

  • Ability to draw rectangles or ellipses around various portions of the document
  • Ability to draw on the document
  • Ability to add a sticky note to an image or anywhere they want on the document, without anchoring it to a specific portion of text
  • Display the author of the comment on the sticky note
  • Display a different colour sticky note for each
  • A button that will flag the note as high or low priority and change the colour of the not accordingly

Thanks for any advice you can offer.

--Mehar

A: 

You can accomplish all the above mentioned requirements with XPS documents and WPF.

You merely have to create an off-screen canvas (that the user can't see), load the existing XPS document. Then you can merely add whatever graphics/UI objects you need (rectangle, circle, bitmapeffects, text, etc.), and should be able to easily render your control overtop of the existing XPS document.

And you'll have the full rendering/UI power of WPF to draw whatever in the world you would need.

There will be some manual work to call InvalidateArrange() and InvalidateMeasure() on your canvas but it should be fairly straightforward.

My only other suggestion would be to use PDFs, since most normal civilians are used to those or provide some kind of import feature in your application. You can also look into the open source project of PDFSharp if you go the pdf route.

Jonathan.Peppers
A: 

Hmmm, this sounds familiar http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8ed381ad-21b6-4479-b9b2-b6317591e93a

If I was you I'd steer clear of customising the WPF Annotation framework as I have been down this path and it is high on the difficulty scale and requires reflection to get access to the properties you will need. If there's the possibility of providing this solution as a web app, then I would advise taking a look at First Floor software's Document toolkit: firstfloorsoftware.com/documenttoolkit/

This is an XPS viewer / converter / annotation framework in silverlight and runs completely in a web browser. I'm not affiliated with First Floor, but if this framework (and silverlight 3) had been available a year ago, then I definitely would have gone for it. It's not cheap, but would have been a lot cheaper than doing all the work in WPF.

If you do decide to pursue the WPF route, then Derek Melhorn's blog has some interesting stuff on it: blogs.msdn.com/mehlhorn/default.aspx

Ben Pink