Convert Visio to HTML format

Exportieren Sie Visio bis HTML

This article explains how to export a Microsoft Visio diagram to HTML using Aspose.Diagram for Python via Java API.

Use the Diagram class constructor to read the diagram files and the Save method to export the diagram to any supported image format. Developers can save resultant HTML in the local storage or directly to a stream instance.

Das Bild unten zeigt aVSD Datei about to be saved to PNG format. You can use other diagram formats (VSDX, VSTM, VSTM, VSSX, VSS, VSSM, VDX, VST, VSTX, VDX, VTX or VSX) as well.

Geben Sie diagram ein.

todo: Bild_alt_Text

In order to export VSD diagram to HTML, perform the following steps:

  1. Erstellen Sie eine Instanz der Klasse Diagram.
  2. Call the Dagram class' Save method and set HTML as the output format.

Das folgende Bild zeigt die Ausgabedatei HTML.

Output HTML diagram.

todo: Bild_alt_Text

Save resultant HTML in the local storage

Die resultierende Datei kann gespeichert werden, indem ein vollständiger Pfad-String einschließlich des Dateinamens und der Erweiterung übergeben wird, z. B. @“c:\temp\MyOutput.html”.

Save Resultant HTML in Local Storage Programming Sample

import jpype
import asposediagram
jpype.startJVM()
from asposediagram.api import *
lic = License()
lic.setLicense("Aspose.Total.Product.Family.lic")
# call the diagram constructor to load diagram from a VSD file
diagram = Diagram("ExportToHTML.vsd")
# Save as HTML
diagram.save("ExportToHTML_Out.html", SaveFileFormat.HTML)
jpype.shutdownJVM()

Save resultant HTML in a stream instance

It is for use case to save the resultant HTML in a database or repository without storing it in the local storage. This feature also embeds other resultant resources of the HTML, e.g. fonts, CSS (containing the style information) and images. Since it saves a single HTML file into the stream instance.

Save Resultant HTML in a Stream Programming Sample

import jpype
import asposediagram
jpype.startJVM()
from asposediagram.api import *
lic = License()
lic.setLicense("Aspose.Total.Product.Family.lic")
# load diagram
diagram = Diagram("ExportToHTML.vsd")
# save resultant HTML directly to a stream
dstStream = java.io.ByteArrayOutputStream()
diagram.save(dstStream, SaveFileFormat.HTML)
# In you want to read the result into a Diagram object again, you need to get the
# data bytes and wrap into an input stream.
# srcStream = java.io.ByteArrayInputStream(dstStream.toByteArray())
jpype.shutdownJVM()