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 ( https://www.openhub.net/p/VisioExportToXAML ), 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.
This should open in your browser, like this:
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.
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.
Fortunately, it is possible to fix this error.
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:
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 – https://www.microsoft.com/en-us/microsoft-365/blog/2009/03/02/canvas-onenote-new-concept-test-officelabs-team/
pptPlex – https://www.microsoft.com/en-us/download/details.aspx?id=28558
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