Nevron Open Vision Documentation
Drawing Vector Image Exporter

The NDrawingVectorImageExporter lets you export the content of the active page (or portions of it) to a vector image in the SVG file format.

Saving with Dialog

The following code shows a save image file dialog that allows the user to create a vector image (in SVG format) from the active page content:

Saving with an Image Export dialog
Copy Code
NDrawingVectorImageExporter imageExporter = new NDrawingVectorImageExporter(drawingView.Document);
imageExporter.SaveAsImage(drawingView.ActivePage.Bounds, NRaster.DefaultResolution);

If you want to directly show a File Save dialog with a specific vector image format selected by default you can pass the file extension of the desired file format to the SaveAsImage method:

Saving with a File Save dialog
Copy Code
NDrawingVectorImageExporter imageExporter = new NDrawingVectorImageExporter(m_DrawingDocument);
imageExporter.SaveAsImage("svg");
Saving to File or Stream

To save the exported image directly to a file or a stream, you should use the SaveToFile or SaveToStream methods respectively. If you want to save the image to an SVG stream, you can use directly the method SaveToStreamAsSvg. The following piece of code exports the active page of a drawing document to a file:

Saving to file
Copy Code
NDrawingVectorImageExporter imageExporter = new NDrawingVectorImageExporter(drawingView.Document);
imageExporter.SaveToFile(@"C:\MyImage.svg", drawingView.ActivePage.Bounds, NRaster.DefaultResolution);

You can use any of SaveToStreamAs... methods to save to any of the following vector image formats, for example:

Generating Vector Image

To generate an SVG document on the fly without saving it, you should use the CreateSvg method:

Generating image
Copy Code
NDrawingVectorImageExporter imageExporter = new NDrawingVectorImageExporter(drawingView.Document);
NSvgDocument svgDocument = imageExporter.CreateSvg(drawingView.ActivePage.Bounds, NRaster.DefaultResolution);

You can use the other Create... methods to create EMF and DXF documents, too.

Copying to Clipboard

To copy the image to the clipboard, you should use the CopyToClipboard method:

Generating image
Copy Code
NDrawingVectorImageExporter imageExporter = new NDrawingVectorImageExporter(drawingView.Document);
imageExporter.CopyToClipboard(drawingView.ActivePage.Bounds, NRaster.DefaultResolution);

The CopyToClipboard method of the drawing vector image exporter will export the selected portion of drawing document's active page to SVG and will put the source code of the generated SVG to the clipboard.

See Also
Send Feedback