Visio in XPS and Interesting Microsoft Office Labs Projects

For the past two years, I have been adding XAML-based projects to my collection, alongside the normal Visio libraries and automation code that I normally produce.  The reason is quite simple : both environments have the ability of linking vector graphics and data together in an exciting, interactive and controllable way.  There is a certain smartness to both with the ability to binding data to graphical appearance.  XAML seems to be present in all of Microsoft’s graphic products, in the form of WPF, Silverlight .and Xps.  Now, we know that there are great things to come viz-a-viz Visio and XAML in the next version, and there is Saveen Reddy,s excellent Visio Export to XAML project on CodePlex (http://visioexporttoxaml.codeplex.com/), but most people do not realise that Xps is XAML, but compressed.

So, if you have Visio 2007, then you can save a document in Xps format ( see http://office.microsoft.com/en-gb/visio/HA100649931033.aspx).

image

This should open in your browser, like this:

image

However, Microsoft have a standalone Xps viewer available for free download as part of the Xps Essentials Pack ( http://blogs.msdn.com/xps/ ).

The XPS Viewer EP includes a thumbnail viewer, which will create an interactive canvas, in which you can select which page to zoom into.

image

The Xps Viewer EP also includes a document outliner, but this reveals a bug in the Xps file exported from Visio when you click on a page.

image

Fortunately, it is possible to fix this error.

image

The error can be traced to the Documents1StructureDocStructure.struct file:

<DocumentStructure
xmlns="
http://schemas.microsoft.com/xps/2005/06/documentstructure">
<DocumentStructure.Outline>
  <DocumentOutline xml:lang="en-US">
   <OutlineEntry OutlineLevel="1" Description="NetworkTopology.vsd"  OutlineTarget="../FixedDoc.fdoc#1"/>
   <OutlineEntry OutlineLevel="2" Description="Topology"  OutlineTarget="../FixedDoc.fdoc#1"/>
   <OutlineEntry OutlineLevel="2" Description="Row 1 Rack 1"  OutlineTarget="../FixedDoc.fdoc#2"/>
   <OutlineEntry OutlineLevel="2" Description="Row 1 Rack 2"  OutlineTarget="../FixedDoc.fdoc#3"/>
  </DocumentOutline>
</DocumentStructure.Outline>
<Story StoryName="MainStory">
  <StoryFragmentReference Page="1"/>
  <StoryFragmentReference Page="2"/>
  <StoryFragmentReference Page="3"/>
</Story>
</DocumentStructure>

which should become:


<DocumentStructure xmlns="
http://schemas.microsoft.com/xps/2005/06/documentstructure" xmlns:c="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:b="http://schemas.bvisual.net/xps/" c:Ignorable="b">
<DocumentStructure.Outline>
  <DocumentOutline xml:lang="en-US">
   <OutlineEntry OutlineLevel="1" Description="NetworkTopology.vsd" OutlineTarget="../FixedDoc.fdoc#PG_0" />
   <OutlineEntry OutlineLevel="2" Description="Topology" OutlineTarget="../FixedDoc.fdoc#PG_0" />
   <OutlineEntry OutlineLevel="2" Description="Row 1 Rack 1" OutlineTarget="../FixedDoc.fdoc#PG_4" />
   <OutlineEntry OutlineLevel="2" Description="Row 1 Rack 2" OutlineTarget="../FixedDoc.fdoc#PG_5" />
  </DocumentOutline>
</DocumentStructure.Outline>
<Story StoryName="MainStory">
  <StoryFragmentReference Page="1" />
  <StoryFragmentReference Page="2" />
  <StoryFragmentReference Page="3" />
</Story>
</DocumentStructure>

Note the amended OutlineTarget attributes

… and to the Documents1FixedDoc.fdoc file:

<FixedDocument xmlns="http://schemas.microsoft.com/xps/2005/06">
<PageContent Source="Pages/1.fpage"></PageContent>
<PageContent Source="Pages/2.fpage"></PageContent>
<PageContent Source="Pages/3.fpage"></PageContent>
</FixedDocument>

should become :


<FixedDocument xmlns="
http://schemas.microsoft.com/xps/2005/06">
<PageContent Source="Pages/1.fpage" Width="1124" Height="795">
<PageContent.LinkTargets><LinkTarget Name="PG_0" /></PageContent.LinkTargets></PageContent>
<PageContent Source="Pages/2.fpage" Width="1124" Height="795">
<PageContent.LinkTargets><LinkTarget Name="PG_4" /></PageContent.LinkTargets></PageContent>
<PageContent Source="Pages/3.fpage" Width="1124" Height="795">
<PageContent.LinkTargets><LinkTarget Name="PG_5" /></PageContent.LinkTargets></PageContent>
</FixedDocument>

Note the added LinkTarget elements.

It is possible to go further, and to include significant shapes as named XAML elements in the XPS file, which means that you can expand the pages in the XPS viewer to list the shapes:

image

In fact, you can encapsulate the shape data (custom properties) as hidden elements in the Xps document, so that you could have your own viewer (say, WPF or Silverlight) that accesses the hidden elements.

In this way, Xps documents can become portable data diagrams, and they can be ready to print … unlike the Save As Web from Visio.

Now, the reason why I got back on to this subject recently was some great add-ons for OneNote and PowerPoint which (I think) use Xps in a manner similar to the Xps Viewer:

Canvas for OneNote – http://www.officelabs.com/projects/canvasforonenote/Pages/default.aspx

pptPlex – http://www.officelabs.com/projects/pptPlex/Pages/default.aspx

So, this is a public call for Microsoft Office Labs to consider a similar tool for Visio!  It would be really cool … and useful!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

davecra.wordpress.com/

Microsoft Office Development, and more...

PowerShell.Amsterdam

Automate, Accelerate, Accurate

johnvisiomvp

Life with Visio and other Microsoft Toys!

Title (Required)

Windows Server Essentials Tips & Tricks

Nilsandrey's Weblog

Just another WordPress.com weblog

Things that Should be Easy

Every so often (too often in the IT industry) I encounter things that should have been very easy to do but turned out to be far too complicated. My favorite topics include SharePoint, .Net development, and software architecture, especially distributed systems.

Visio Guy

Shapes, Stencils, Drawings Templates, Tutorials, Tips & Developer Info for Microsoft Visio

Hannes's Virtual Earth

Tips & Tricks around Mapping and Cloud Computing

Pluralsight blog

be smart, be clear, be visual ...

%d bloggers like this: