Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active August 11, 2021 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/5ae21aefe19e33728280366226573cb8 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/5ae21aefe19e33728280366226573cb8 to your computer and use it in GitHub Desktop.
Print Visio Diagram Documents VSDX, DWGX, VSTX Programmatically in C#
// Load source Visio VSD or VSDX diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Call the print method to print whole Diagram using the default printer
diagram.Print();
public static void Print(Diagram diagram, string printerName, string jobName, bool isWait)
{
if (diagram == null)
throw new ArgumentNullException("document");
// Use Aspose.Diagram to convert the document to XPS and store in a memory stream.
MemoryStream stream = new MemoryStream();
diagram.Save(stream, SaveFileFormat.XPS);
stream.Position = 0;
// Send a Diagram document to a printer using the XpsPrint API
Print(stream, printerName, jobName, isWait);
}
// Load source Visio diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Call the print method to print whole Diagram using the printer name
diagram.Print("LaserJet1100");
// Load source Visio diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Call the print method to print whole Diagram using the printer name and set document name in the print job
diagram.Print("LaserJet1100", "Test Job");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment