Converting Visio files in ASP.NET
page 1 of 5
Published: 18 Feb 2004
Unedited - Community Contributed
Abstract
This article explains how to convert a Visio file into a .jpg image. For this example, you will utilize Visio 2003.
by Jason N. Gaylord
Feedback
Average Rating: 
Views (Total / Last 10 Days): 49944/ 98

Overview

The other day I found myself in a bind. I needed to find a way to convert Visio files quickly to *.jpg format. So I began to research different ways of importing the Visio library. I wanted to perform this task by using just notepad and the command prompt. So I did so.

To perform this task, you'll need:

  • Visio 2003
  • .NET Framework 1.1
  • Account credentials with permission to run Visio 2003
  • Read/Write permissions to your "Output" folder (Unless importing to SQL)
Now that you have everything you'll need, let's begin.

View Entire Article

User Comments

Title: programmer   
Name: Mary
Date: 2009-11-09 10:43:43 AM
Comment:
HI,
I need to use asp.net to present visio documents on the intranet here at work. Most people do not have visio or visio viewer on their machines. Will this code convert and display the visio in jpg on the server these people?
Title: Having mutiple pages in one .vsd file   
Name: AJIT
Date: 2008-10-15 8:51:22 AM
Comment:
sir
i have multiple pages in one .vsd so i want to save all of them as .jpg

so pl help me
Title: code hangs at application.documents.open   
Name: mittu
Date: 2008-05-22 11:47:47 PM
Comment:
hi,
i have a asp.net code which exports to html.but the code hangs at application.document.open(vsd.file)before addon command
any help
Title: Asp.net   
Name: Haffees
Date: 2007-04-27 7:19:59 AM
Comment:
Which was imports function for RegistryKey
Title: Imports error   
Name: h12
Date: 2006-06-26 1:44:00 PM
Comment:
When importing the VisioDotNet, the compiler shows some error and also there is error in the Application that the compiler cannot resolved. What should I do in such case?
Title: Dialogue Holding Up Automation   
Name: Nate
Date: 2006-02-02 12:47:43 PM
Comment:
I ran into the problem where Visio would prompt for a Cross-Functional Conversion and it was holding up the automation. What I had to do was this to stop it from prompting:

I found a way to stop the dialogues for the Visio automation.

Tools->Options->Security

Disable: Enable Microsoft Visual Basic for Applications
Disable: Enable COM Add-ins
Disable: Enable Automation Events

Click Macro Security: Set to Very High

The dialogue is an add in OR an Automation Event. Either way I disabled what I could and it worked.

Nate
Title: C++ COM version   
Name: Subhash
Date: 2006-01-03 2:16:36 AM
Comment:
I am trying to load a vsd file and make changes to it and saving back to html
Can anyone please help me with C++ version in COM.

Subhash
Title: Re: 'Text' is not a member of 'System.Web.UI.HtmlControls.Html   
Name: Subhash
Date: 2005-12-05 4:32:22 AM
Comment:
Hey,

I reinstalled Visio 2003.. Which solved my problem with invalid access to memory location

Subhash
Title: Re: Argh!   
Name: Jason
Date: 2005-11-14 10:51:45 AM
Comment:
Sounds like your issues are a bit deeper. I have helped 2 others having an issue and it ended up being their PCs needed a reformat because VS.NET was corrupted. Also, make sure you have the following:

-Visio 2003
-.NET Framework 1.1
-Account credentials with permission to run Visio 2003
-Read/Write permissions to your "Output" folder (Unless importing to SQL)
Title: 'Text' is not a member of 'System.Web.UI.HtmlControls.Html   
Name: Subhash
Date: 2005-11-12 9:09:10 AM
Comment:
\
\
Title: Re: Argh!   
Name: Technohig
Date: 2005-08-05 10:16:19 AM
Comment:
DLL Hell. Dll was registered at assembly location for some reason. Had to reboot to safe mode to kill said dll. Now it is complaining that 'Text' is not a member of 'System.Web.UI.HtmlControls.HtmlInputFile'. Assuming I get this fixed and then it chokes at '"OutputFile" is not defined, can I assume the problem is at the asp:button line?
Title: Re: Argh!   
Name: Jason N. Gaylord
Date: 2005-08-03 1:21:02 PM
Comment:
The Utilities.Visio.dll file should go in the bin folder for your web application.
Title: Re: Argh!   
Name: Technohig
Date: 2005-08-03 12:48:20 PM
Comment:
Yes, Visio 2003; yes permissions out the wa-zoo. Doe the markup for the web.config file change when it is directed at a specific site, rather than the whole web server?
Title: RE: Argh!   
Name: Jason N. Gaylord
Date: 2005-08-02 3:15:50 PM
Comment:
Are you using Visio 2003? You must make sure that the web server that you are using this with has this installed. It needs to use the DLLs that are contained within Visio 2003
Title: Argh!   
Name: Technohig
Date: 2005-08-02 2:12:09 PM
Comment:
This would be great if it worked! I get a complilation error everytime I browse the website where convert.aspx is the default page--saying Utilities.Visio is not defined. Where does the Utilities.Visio dll go? (fails specifically at line: Dim doc As New Utilities.Visio)
Title: Continuing Interop Problems   
Name: Corey Alguire
Date: 2005-04-25 3:46:20 PM
Comment:
Well, I added the user I am impersonating to the local admin group. I also made sure that user plus Network Service and the anonymous users for IIS and ASPNET have access to the DCOM objects. So now I no longer get access denied errors or errors about registry keys. However, I still get the same Server execution error. It happens on the line that instantiates a new instance of the application. I can see from TaskManager and from entries in a File Monitor app I use that Visio is starting up. In fact, the instance is spawned and never closes because of the crash. I just don't have any idea why this is failing. *Deeply puzzled and very frustrated.*
Title: Re: Error Found!   
Name: Jason N. Gaylord
Date: 2005-04-18 4:17:50 PM
Comment:
I wrote this assuming that it would run as a web app running under an Admin account. If this isn't the case, you can add permissions to the registry key that it is having difficulty accessing. Have you tried that? Just be careful when dealing with the registry.
Title: Re: Error Found!   
Name: Corey
Date: 2005-04-14 5:43:10 PM
Comment:
I actually have had exactly the same problem. I seems to be related to the permissions of the user. If I use an administrator login, the application works fine. But if I use the local account I set up for the job (just a standard user account), I get the "Server Execution Failed" exception.

Checking the Application Event Log, I find entries about a missing registry key (which is not actually missing, but might be inaccessible) and about a failure of the Windows Installer. From the user's standpoint, the asp.net app just appears to hang. I am honestly stumped about how to make this work for me, though- I can't just leave it running with the admin credentials stored in plain text. And I don't want to run it under and admin account anyway.
Title: RE: Error Found !   
Name: Jason N. Gaylord
Date: 2005-03-03 12:01:36 PM
Comment:
Are you using Visio 2003? You must make sure that the web server that you are using this with has this installed. It needs to use the DLLs that are contained within Visio 2003. That error message is very vague and could be caused by not having Visio 2003 on the server or by not having the proper permissions.
Title: Error Found !   
Name: BD
Date: 2005-03-03 11:57:48 AM
Comment:
I got a problem like...(error at line 9)

=======================================================
Server execution failed
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Server execution failed

Source Error:


Line 7:
Line 8: Public Sub SaveFile(ByVal infile As String, ByVal outfile As String)
Line 9: Dim app As New VisioDotNet.Application
=========================================================
Please tell me how to correct this. Thank You.
Title: RE[4]: Terminate the Process   
Name: Aleks
Date: 2004-08-27 10:55:43 AM
Comment:
Jason, I found a way "around it", you can say. Here is the code that will output a multi-page visio to html:

public void SaveFile(string infile, string outfile)
{
Application app = new Application();

app.Documents.Open(infile);
app.Addons.get_ItemU("SaveAsWeb").Run("/quiet=True /target=" + outfile);
app.Quit();
}

A similar statement in VB will look something like this:

Application.Addons("SaveAsWeb").Run "/quiet=True /target=" + outfile

Thanks for all your help.
Title: RE[3]: Terminate the Process   
Name: Jason
Date: 2004-08-26 9:22:46 PM
Comment:
I haven't tried exporting to HTML. I'd almost assume that you can either loop through the pages or that there is an attribute somewhere. If I get a chance sometime soon, I'll look into it.
Title: RE[2]: Terminate the Process   
Name: Aleks A
Date: 2004-08-26 5:21:28 PM
Comment:
Yeah, that did the trick, Jason.

Any suggestions on exporting multipage visio documents? I think I have to iterate through the pages collection, the problem is, how would I combine all those pages into a single html document (eg export as html)? Any thoughts? When exporting to html from visio itself, it automatically assumes that all pages need to be exported, hence, it works perfectly, but only exports the active page using your method.
Title: RE: Terminate the Process   
Name: Jason
Date: 2004-08-20 11:45:04 PM
Comment:
I haven't tested this, but, I'm assuming if you open Visio and allow the macros to run every time, it shouldn't stall in this process above.
Title: Terminate the Process   
Name: Aleks
Date: 2004-08-20 4:33:07 PM
Comment:
Here is the C# version:

public void SaveFile(string infile, string outfile)
{
Application app = new Application();

app.Documents.Open(infile);
app.ActiveWindow.PageAsObj.Export(outfile);
app.ActiveWindow.Close();
app.Quit();
}

Make sure you quit the application, or you'll spawn new process every time!

Anyone know how to bypass the macro prompt in visio? I can't find it...

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-10-20 12:12:55 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search