Nevron Open Vision Documentation
Diagram / File Formats / Export / Visio Export
In This Topic
    Visio Export
    In This Topic

    NOV Diagram lets you easily save your drawing documents to Visio Drawings in VSDX format.

     Save to File or Stream Directly

    To save directly to a Visio Drawing file call any of the SaveToLocalFile or SaveToStream methods of the drawing view, for example:

    Save to a Visio Drawing file
    Copy Code
    drawingView.SaveToLocalFile(@"C:\VisioDrawing.vsdx");
    

    You can also use the SaveToFileAsync method. As its name shows the SaveToFileAsync method is asynchronous. If you want to be notified when it has finished saving the Visio drawing to file, call the Then method of the promise it returns and add a delegate like this:

    Save to Visio Drawing file and get notified when completed
    Copy Code
    drawingView.SaveToFileAsync("C:\\VisioDrawing.vsdx").Then(
         delegate (bool success)
         {
             // Export to Visio completed
         }
     );
    

    The SaveToStream method is synchornious and blocks execution until it completes.

    Save to Visio Drawing stream
    Copy Code
    drawingView.SaveToStream(stream, NDrawingFormat.Visio);
    

    If you want to save a drawing document that is not placed in a drawing view to a file or stream use the NDrawingFormat.Visio.SaveToFileAsync or the NDrawingFormat.Visio.SaveToStream methods.

    To export NOV Diagram libraries as Visio stencils, use the same methods of the NLibraryView and the NLibraryFormat.Visio file format.

    To customize the Visio drawing export process you can pass an NVisioDrawingSaveSettings instance to the Save method. It contains the following properties:

    • CompressionLevel - the compression level to apply when creating the VSDX file/stream. By default set to BestCompression.
    • EmbedPreview - determines whether to embed a preview (in EMF format) of the document in the generated Visio package. By default set to true. If you are after maximum performance, set this property to false to instruct the Visio exporter not to generate and embed a preview of the document in the resulting Visio package.
    Using Visio Drawing save settings
    Copy Code
    NVisioDrawingSaveSettings visioSaveSettings = new NVisioDrawingSaveSettings();
    visioSaveSettings.CompressionLevel = ENCompressionLevel.BestSpeed;
    visioSaveSettings.EmbedPreview = false;
    drawingView.SaveToLocalFile(@"C:\VisioDrawing.vsdx", NDrawingFormat.Visio, visioSaveSettings);
    

    The example above configures the Visio Drawing export for maximum performance by setting the CompressionLevel to BestSpeed and disabling the generation and embedding of document preview in the resulting Visio package.

     Show Save File Dialog

    To show the standard Save File dialog with "Visio Drawing" file type selected by default, use the following overload of the SaveToFile method:

    Save File dialog with Visio Drawing selected by default
    Copy Code
    drawingView.SaveAsAsync(NDrawingFormat.Visio);
    

    To show a Save File dialog with only "Visio Drawing" as a file type, then you should get and execute the export to Visio command action:

    Save File dialog with only Visio Drawing file type
    Copy Code
    NCommandAction exportToVisioAction = drawingView.Commander.GetCommandAction(NDrawingView.ExportToVisioDrawingCommand);
    exportToVisioAction.Execute(drawingView, NCommand.EmptyParameter);
    

     

    See Also