Retrieving refreshed page images from Visio Services 2013

Why would you want to retrieve page images from your Visio diagrams via Visio Services?  Visio Services will provide you with an image that you can incorporate into any application; WPF, Windows Phone, Windows 8, Apps for Office, etc. using two simple http requests…

First we need to request a specific diagram and page…


When we get the response for this first request we need to do two things:

  1. Parse the sequence id from the response
  2. Provide a cookie with our credentials so that Visio Services will refresh the image if it is data linked.  This step is optional if you choose to get an image that is not refreshed or if your diagram is not linked to data.

After we parse out the sequence id and setup our cookie, we can make the second request as follows…


Attached is an example that will show you how to retrieve images using this technique.

Here is an example of an image from a data linked diagram where I chose to not provide the refresh cookie…



Here is an example of an image from a data linked diagram where I chose to provide the refresh cookie in order to get a data refreshed image…




The attached code sample if fairly complete but there are two arguments in the URL that need some explaining that you will want to modify at runtime:


Specify the Page to retrieve

Visio diagrams can have many pages.  The P= argument in the URL for the first request is used to request a specific page in the diagram.

-1 = Page 1
-2 = Page 2
-3 = Page 3

I think you get the idea.

Specify the Image Quality

Visio Services provides multiple images based on the zoom level.  The I= argument in the URL for the second request is used to specify the quality of the image.

Image3 = High quality
Image2 = Medium quality
Image1 = Low quality