Thursday, August 21, 2008

TIFF and XPS

XPS 1.0 spec, page 35: "If the TIFF image contains multiple image file directories (IFDs), consumers MUST use only the first IFD and ignore all others [M2.27]. "

How I got there:

My application uses a reporting engine to generate reports. We need to wrap the individual pages of these reports in WPF content and later save them to an XPS document.

Because the reporting engine we're using doesn't render to WPF visuals yet, we're rendering to an in-memory, multipage TIFF image. The individual pages of this report are wrapped in WPF content, and then, as I said, eventually written to disk as XPS.

Problem was, I noticed that when they were read back in, all of my pages were displaying the same report page. My thought was that the WPF APIs would handle the references behind the scene. I get the correct visuals on the screen, but after the XPS writing, I find that pages 2-n have the same report visual.

I had to crack open the XPS and see what image resource it was using for all these pages. It turned out to be only the first page of the multipage TIFF.

"If the TIFF image contains multiple image file directories (IFDs), consumers MUST use only the first IFD and ignore all others [M2.27]. "

Wednesday, August 13, 2008

VisualsToXpsDocument Class

Here's another helpful class that I just found out about:

VisualsToXpsDocument lets you convert WPF visuals to XPS in batch mode.

Friday, August 1, 2008

View XPS Structure in Visual Studio

If you install Microsoft Visual Studio Tools for the Office System Power Tools, you'll get the ability to examine XPS files in Visual Studio like so.

Download here. All you need for this functionality is the VSTO_PT.exe install.







Microsoft XPS Samples

After several days of rage and cursing Microsoft for their lack of documentation and responsiveness in regards to XPS APIs and the shortcomings of the System.Windows.Documents and related namespaces, I finally found their samples on MSDN:

http://msdn.microsoft.com/en-us/library/ms771612.aspx

I have no idea why it took me so long to find it, other than tunnel-vision on my part and a lack of sufficient links for it to turn up in my searches. So let this post be another link.