Nevron Open Vision Documentation
Chart / Export / Chart PDF Export
In This Topic
    Chart PDF Export
    In This Topic

    The NChartPdfExporter can be used to export a chart to PDF.

     Saving with a Dialog

    The following code shows how to display the default PDF export dialog provided by NOV:

    Showing the default PDF Export dialog
    Copy Code
    NChartPdfExporter imageExporter = new NChartPdfExporter(chartView.Content);
    imageExporter.ShowDialog(DisplayWindow, true);
    

    The following code shows a save PDF file dialog, which allows the user to export the chart to the selected PDF file:

    Exporting to a file selected from a Save File dialog
    Copy Code
    NChartPdfExporter pdfExporter = new NChartPdfExporter(chartView.Content);
    pdfExporter.SaveAsPdf();
    
     Saving to File or Stream

    To export a chart to PDF and save it directly to a file, without showing a save file dialog, you should use the SaveToFile method. Note that the saving to file is an asynchronous (async) operation, so if you are interested in its completion, you should call the Then method of the promise it returns and handle the completion of the export in the passed delegate. The following is a code example:

    Exporting a chart to a PDF file
    Copy Code
    NChartPdfExporter pdfExporter = new NChartPdfExporter(chartView.Content);
    pdfExporter.SaveToFileAsync("C:\\ExportedChart.pdf").Then(
        delegate (NUndefined ud)
        {
            // Export to PDF completed
        }
    );
    
    Exporting a chart to an arbitrary file works only on non-sandboxed platforms like WinForms, WPF and Xamarin.Mac.

    To export a chart to a PDF stream, use the SaveToStream method. Unlike the SaveToFile method, the SaveToStream method runs synchronously and blocks code execution until it completes. Exporting charts to PDF is useful when you wish to generate PDF documents in-memory instead of saving them to the disc. The following code snippet shows how to export a chart to a stream:

    Exporting a chart to a PDF stream
    Copy Code
    NDrawingPdfExporter pdfExporter = new NDrawingPdfExporter(chartView.Content);
    pdfExporter.SaveToStream(stream);

     

    See Also