You can create a static image representing the current diagram using the CreateImage method. The method returns an instance of the System.Drawing.Bitmap class. The following example shows how to export a diagram to a Png image file in response to pressing a button, using the SaveFileDialog control where the location is selected and the name of the image file is entered:
C# Copy Code |
---|
private void btnPngExport_Click(object sender, System.EventArgs e) |
Visual Basic Copy Code |
---|
Private Sub btnPngExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPngExport.Click |
The MindFusion.Diagramming.Export Namespace contains classes for exporting to Dxf, Pdf, Svg and Visio formats.
Add a reference to the MindFusion.Diagramming.Export.Dxf.dll to your project. Create a DxfExporter instance and call its Export method, specifying a Diagram object and a file path as arguments. Raster images can be used in DXF by referencing external image files. To export the images displayed in diagram elements, enable the ExportImages property. If your application supports the multiple-line text DXF entity - MTEXT, use the ExportTextAsMultiline property. The following example shows how to create a DxfExporter instance and export a diagram by performing the Export method passing the Diagram object and the file name entered in a SaveFileDialog.
C# Copy Code |
---|
MindFusion.Diagramming.Export.DxfExporter dxfExp = new MindFusion.Diagramming.Export.DxfExporter(); |
Add references to the MindFusion.Diagramming.Export.Pdf.dll and MindFusion.Pdf.dll assemblies to your project. Create a PdfExporter instance and call its Export method. Margins specifies the page margins for all pages in the document. If you need to set the page size and orientation, use the PageSize, and PageOrientation properties. The AutoScale property allows scaling the diagram to fit in one or more PDF pages. If invisible items should be displayed in the PDF, enable the InvisibleItems property. The following example shows how to export a diagram to a Pdf file in response to pressing a button event and using the SaveFileDialog control where the location is selected and the name of the Pdf file is entered:
C# Copy Code |
---|
private void button1_Click(object sender, EventArgs e) |
Visual Basic Copy Code |
---|
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click |
Add references to the MindFusion.Diagramming.Export.Svg.dll and MindFusion.Svg.dll assemblies to your project. Create an SvgExporter instance and call its Export method, passing a Diagram object and the full path to the .svg file as parameters. To export images displayed by diagram items to external files, enable the ExternalImages property.
C# Copy Code |
---|
MindFusion.Diagramming.Export.SvgExporter svgExp = new MindFusion.Diagramming.Export.SvgExporter(); |
Visual Basic Copy Code |
---|
Dim svgExp As MindFusion.Diagramming.Export.SvgExporter = _ |
Add a reference to the MindFusion.Diagramming.Export.Visio.dll to your project. The MindFusion.Diagramming ShapeNode objects are mapped to their closest Visio counterparts and TableNode objects are exported as groups of Visio shapes. MindFusion.Diagramming DiagramLink instances are exported as Visio connectors of a similar style. In addition, most of the attributes of diagram items such as text, text formatting, fill and line colors and styles are preserved.
The exporter object requires the VisioExport.vxt file to be present in the application's directory. This file contains an XML template data used by the component to generate Visio documents.
Create a new instance of the VisioExporter class. Call the Export method passing a Diagram object and the full path to the exported Visio .vdx file as parameters. The Visio page dimension and items size measure unit is set to the diagram's MeasureUnit.
To create Visio groups from the MindFusion.Diagramming groups, enable the CreateVisioGroups property. If a shape node that contains an image should be exported as a Visio group of a shape, picture and text objects, use the ExportImagesAsGroups property set to true by default. ExportInvisibleItems allows exporting of invisible items. If MindFusion.Diagramming TableNode objects should be exported as groups of Visio rectangular shapes, enable the ExportTablesAsGroups property.
The following example shows how to export a diagram to a Visio file in response to choosing a File > Export to > Visio menu item and using the SaveFileDialog control where the location is selected and the name of the Visio file is entered:
C# Copy Code |
---|
private void _menuItemExportVisio_Click(object sender, System.EventArgs e) |
Add a reference to the MindFusion.Diagramming.Export.Wmf.dll assembly to your project. Create a WmfExporter instance and call its Export method, passing a Diagram object and the full path to the .wmf file as parameters.
Add a reference to the MindFusion.Diagramming.Export.Swf.dll assembly to your project. Create an SwfExporter instance and call its Export method, passing a Diagram object and the full path to the .swf file as parameters.