Publishing Visio drawings as SVG

svg-004

In my post yesterday I showed how to publish Visio files as html image maps. That was one of the alternatives. Today I’ll present how to use SVG to achieve the same goal: publish Visio diagrams in SharePoint without having the Enterprise license. There are some alternatives:

  1. Show Visio diagrams as pdf files on SharePoint Pages
  2. Embed Visio diagrams as html image maps – Read more in my previous blog post
  3. Embed Visio diagrams as svg pictures – This blog post.
  4. Link to Visio files that are opened using Visio Web Viewer in a new browser tab.

SVG

SVG stands for scalable vector graphic, it is a xml-based format for defining images. It is supported in all modern browsers. Because SVG can be part of a page markup, it can be easily embedded into SharePoint.

Visio

In Visio you can save a drawing as SVG. Thanks to my smart colleague: Dan Saeden. So the process of exporting and embedding a drawing is almost the same as for an image map. An improvement is that you don’t have to update the html markup and you don’t need to upload or base64-encode any pictures. It’s all in the markup (DOM). See some screenshots below.

Advantages and Disanvantages

Compared to image maps and other methods, we get following advantages:

  1. It is scalable (not pixelish) – you can show it in a small screen, and a big screen.
  2. Only markup is needed (xml), no need for uploading images
  3. No additional bandwidth is required for downloading images to the browser
  4. No need for updating html structure, easier to explain how to do it.

There are also some disanvantages:

  1. Complex SVG files increase the DOM complexity and it may affect the performance in browser
  2. No support for older browsers: In IE8 it won’t work

svg-000

How to

Use your drawing of choice:

svg-001

Save it as an SVG file:

svg-002

Add a Script Editor Web Part to a page and paste the content of the svg file (open it in a text editor):

svg-003

That’s it:

svg-005

Summary

Visio files can be exported to many different formats. SVG is a great modern html standard for graphics that acts as a part of the DOM. It still requires a manual process of exporting and putting it on a SharePoint page, but it is a good way to make it modern, fast and even responsive (with some additional css). Editors don’t need to adjust the markup, only copy it.

Publishing Visio diagrams as html image maps

imagemap-014

I got a question from a customer: We have our processes defined in Visio, we don’t have SharePoint Enterprise CALs to use the Visio webpart. We have links in process maps. What can we do?

Well there are three ways to solve this business need:

  1. Find money for SharePoint Enterprise – Very expensive
  2. Show Visio diagrams as pdf files on SharePoint Pages – Expensive.
  3. Embed Visio diagrams as html image maps – Least expensive

If the business needs other features available only in Enterprise, just use the solution 1. Stop reading.

If you are looking for alternatives, then consider pdf and image maps. I have seen projects where pdf files were embedded in the SharePoint Pages. It required a pdf plugin in IE, a lot of time to make it look the same in different browsers and the scroll and fixed size was still there. It was expensive because of the development and configuration time.

In this blog post, I want to show the alternative number 3: embedding Visio diagrams as html image maps. This is only a Proof-of-concept so far.

Image Maps

Image maps are an old html fellow that can contain links on an image. Links can be connected to areas using coordinates. During a brainstorming session, we thought: what if we define image maps using Gimp or some other graphic tool. This manual procedure is not good when it is time to update the diagrams: it will require a lot of manual work to keep it up to date. So we need to be able to export a Visio diagram to an image map.

Visio

Actually Visio lets you export a diagram as an image map. All you need is to save it as as web page. Just to demonstrate I created a simple drawing:

imagemap-001

Then I added a hyperlink to a shape:

imagemap-002

Then I saved it as a web page:

imagemap-003

Getting the actual image map

The web page that Visio creates, is a frameset:

imagemap-004

So the actual content (the image map) is inside the _files folder:

imagemap-005

You can find the filename of the image map html by reading the main page (Process-Main.html in my case). Usually it is png_1.html (for the first Visio page):

imagemap-006

In the page where you want publish the process diagram, add a script editor webpart (or a content editor webpart):

imagemap-007

Edit snippet, as usual:

imagemap-008

Now you have to copy image tag and the map tag from the html:

imagemap-009

Paste it into the Script Editor:

imagemap-010

The image tag points to an image that is present in the same folder: png_1.png. We can upload it to a library and update the src attribute. In my case, to test it quickly, and because my image is not big, I’ll create a base64 string of that image using an online tool – dataurlmaker:

imagemap-011

Update the src attribute in the Script editor webpart:

imagemap-012

That’s it, now we have an image map, a drawing that has clickable elements with links to subprocesses:

imagemap-013

Summary

This is a proof-of-concept that I will share for publishing Visio drawings as html image maps. It works even in SharePoint Foundation (!). The publishing and republishing involves these three steps:

  1. Save a Visio file as a webpage (for new and updated files)
  2. Copy html parts to a SharePoint page
  3. Update the image reference

The steps are not aimed for end users. But given that you have clear instructions and guidelines how to publish drawings in SharePoint, even editors with basic knowledge about html can do it. This approach lets you keep Visio files as the source and update the process pages in SharePoint quite easy.

Next step

If this method works in a real environment, next step would be to create a tool for automatic conversion of Visio files to image maps.

SharePoint two way lookup field, strictly out of the box

Sometimes you forget that SharePoint can do things out of the box, and you immediately start to think about how to customize or buy third party products to solve issues.

I for example, wanted a two way lookup between two lists. In other words, if I added items from List A to a lookup of an item in List B, I would like to be able to see the relationship on items in both lists. When I got the advice to buy a third party product for this, I thought I’d just see if there were any other options, and of course there was!

By following the steps on this blog, all I needed to do was to edit the display form of List B, and insert the related list. To do this, just go to list settings -> Forms Web Parts -> Default Display Form.

formWebParts

You will be redirected to the display form in edit mode. Just click the web part zone and the insert tab will appear. Open it, click Related List and select the list in the drop down.

relatedList

This will add a list view web part to the form, which is pre-connected to the item opened in the display form. Next time you open up an item in the list, you will see the list view of the related items in the form. Of course you can do this on the new, and edit forms as well.

This approach doesn’t look very good however, and you won’t get the related items in a list view. But it’s cheap, and could suit customers who are very cost-aware (a nice way of saying cheap). And with a little JSLink magic you should be able to make it look a lot better with hardly any effort at all.

Struggling with Taxonomy in CSOM

The parts of the CSOM for updating Taxonomy fields are really cumbersome. I mean, look at this code, nicely provided by Vadim Gremyshev (@vgrem). To set a value in a taxonomy field we have to assemble a text representation, and adding a “fake” lookup id.

What is needed is a wrapper for handling Taxonomy fields. SPMeta2 and PnP don’t seem to have it yet.

Another issue that I have struggled with today was the missing Microsoft.SharePoint.Client.Taxonomy.dll. If you see this error (set customErrors=”Off” in the Web.config), then you have update the reference in the Visual Studio project:

missingtaxonomy-002

Open Properties for the reference called: Microsoft.SharePoint.Client.Taxonomy and ensure that Copy To Local is set to True:

missingtaxonomy-003

For some reason, this reference added through “App for SharePoint Web Toolkit” nuget package adds a reference to an assembly from your computers GAC.