Home > Code > C# > How to Control Export of Hidden Visio Pages to PDF HTML Image & Other Formats using .NET

How to Control Export of Hidden Visio Pages to PDF HTML Image & Other Formats using .NET

by sher azam   on Apr 27, 2016   Category: C#   |  Views: 426    |  Points: 25   |  Gold 


This tutorial shows how .NET developers can Control the Export of Hidden Visio Pages on Saving inside .NET applications inside their .NET applications. Aspose.Diagram for .NET API allows developers to include or exclude hidden Visio pages on saving diagram to PDF, HTML, Image (PNG, JPEG, GIF), SVG, and XPS files. Even they may hide Visio pages using Aspose.Diagram API because it's option is already available through the cell UIVisibility in the page ShapeSheet. Aspose.Diagram for .NET API has the Page class that represents a Visio drawing page. The PageSheet property exposed by the Page class also exposes the page properties. The {{UIVisibility }}field of the page properties allows to hide the page. Developers can then use ExportHiddenPage property which is added in the SVGSaveOptions, XPSSaveOptions, ImageSaveOptions, HTMLSaveOptions and PdfSaveOptions classes. These examples show how to:

• Set the Export Option for PDF.
• Set the Export Option for HTML.
• Set the Export Option for Image.
• Set the Export Option for SVG.
• Set the Export Option for XPS.

Set the Export Option for PDF


// [C# Code Sample]

string dataDir = @"c:\temp\";
// load an existing Visio
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// get a particular page
Page page = diagram.Pages.GetPage("Page-2");
// set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.False;

// initialize PDF save options
PdfSaveOptions options = new PdfSaveOptions();
// set export option of hidden Visio pages
options.ExportHiddenPage = false;

//Save the Visio diagram
diagram.Save(dataDir + "Output.pdf", options);

// [VB.NET Code Sample]

Dim dataDir As String = "c:\temp\"
' load an existing Visio
Dim diagram As New Diagram(dataDir & Convert.ToString("Drawing1.vsdx"))
' get a particular page
Dim page As Page = diagram.Pages.GetPage("Page-2")
' set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.[False]

' initialize PDF save options
Dim options As New PdfSaveOptions()
' set export option of hidden Visio pages
options.ExportHiddenPage = False

'Save the Visio diagram
diagram.Save(dataDir & Convert.ToString("Output.pdf"), options)

Set the Export Option for HTML

// [C# Code Sample]

string dataDir = @"c:\temp\";
// load an existing Visio
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// get a particular page
Page page = diagram.Pages.GetPage("Page-2");
// set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.False;

// initialize PDF save options
HTMLSaveOptions options = new HTMLSaveOptions();
// set export option of hidden Visio pages
options.ExportHiddenPage = false;

//Save the Visio diagram
diagram.Save(dataDir + "Output.html", options);

// [VB.NET Code Sample]

Dim dataDir As String = "c:\temp\"
' load an existing Visio
Dim diagram As New Diagram(dataDir & Convert.ToString("Drawing1.vsdx"))
' get a particular page
Dim page As Page = diagram.Pages.GetPage("Page-2")
' set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.[False]

' initialize PDF save options
Dim options As New HTMLSaveOptions()
' set export option of hidden Visio pages
options.ExportHiddenPage = False

'Save the Visio diagram
diagram.Save(dataDir & Convert.ToString("Output.html"), options)


Set the Export Option for Image

// [C# Code Sample]

string dataDir = @"c:\temp\";
// load an existing Visio
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// get a particular page
Page page = diagram.Pages.GetPage("Page-2");
// set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.False;

// initialize PDF save options
ImageSaveOptions options = new ImageSaveOptions(SaveFileFormat.JPEG);
// set export option of hidden Visio pages
options.ExportHiddenPage = false;

//Save the Visio diagram
diagram.Save(dataDir + "Output.jpeg", options);

// [VB.NET Code Sample]

Dim dataDir As String = "c:\temp\"
' load an existing Visio
Dim diagram As New Diagram(dataDir & Convert.ToString("Drawing1.vsdx"))
' get a particular page
Dim page As Page = diagram.Pages.GetPage("Page-2")
' set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.[False]

' initialize PDF save options
Dim options As New ImageSaveOptions(SaveFileFormat.JPEG)
' set export option of hidden Visio pages
options.ExportHiddenPage = False

'Save the Visio diagram
diagram.Save(dataDir & Convert.ToString("Output.jpeg"), options)


Set the Export Option for SVG

// [C# Code Sample]

string dataDir = @"c:\temp\";
// load an existing Visio
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// get a particular page
Page page = diagram.Pages.GetPage("Page-2");
// set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.False;

// initialize PDF save options
SVGSaveOptions options = new SVGSaveOptions();
// set export option of hidden Visio pages
options.ExportHiddenPage = false;

//Save the Visio diagram
diagram.Save(dataDir + "Output.svg", options);


// [VB.NET Code Sample]

Dim dataDir As String = "c:\temp\"
' load an existing Visio
Dim diagram As New Diagram(dataDir & Convert.ToString("Drawing1.vsdx"))
' get a particular page
Dim page As Page = diagram.Pages.GetPage("Page-2")
' set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.[False]

' initialize PDF save options
Dim options As New SVGSaveOptions()
' set export option of hidden Visio pages
options.ExportHiddenPage = False

'Save the Visio diagram
diagram.Save(dataDir & Convert.ToString("Output.svg"), options)


Set the Export Option for XPS

// [C# Code Sample]

string dataDir = @"c:\temp\";
// load an existing Visio
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// get a particular page
Page page = diagram.Pages.GetPage("Page-2");
// set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.False;

// initialize PDF save options
XPSSaveOptions options = new XPSSaveOptions();
// set export option of hidden Visio pages
options.ExportHiddenPage = false;

//Save the Visio diagram

diagram.Save(dataDir + "Output.xps", options);

// [VB.NET Code Sample]

Dim dataDir As String = "c:\temp\"
' load an existing Visio
Dim diagram As New Diagram(dataDir & Convert.ToString("Drawing1.vsdx"))
' get a particular page
Dim page As Page = diagram.Pages.GetPage("Page-2")
' set Visio page visiblity
page.PageSheet.PageProps.UIVisibility.Value = BOOL.[False]

' initialize PDF save options
Dim options As New XPSSaveOptions()
' set export option of hidden Visio pages
options.ExportHiddenPage = False

'Save the Visio diagram
diagram.Save(dataDir & Convert.ToString("Output.xps"), options)



Overview: Aspose.Diagram for .NET

Aspose.Diagram is a class library for working with MS Visio files & is a pure .NET alternate for MS Visio Object Model. It enables developers to work with VSD & VDX files on ASP.NET web applications, web services & Windows applications. It makes use of the advanced functionality of Visio's services to manipulate Visio docs on a server. Developer can open files & manipulate the elements of the diagram, from lines and fills, to more complex elements, and then export to native Visio formats or XML.

More about Aspose.Diagram for .NET

- Homepage of Aspose.Diagram for .NET: http://www.aspose.com/.net/diagram-component.aspx

-Download Aspose.Diagram for .NET: http://www.aspose.com/community/files/51/.net-components/aspose.diagram-for-.net/default.aspx



Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts