SciChart WPF 2D Charts > Advanced 2D Charting Topics > Screenshots, Printing and Export to XPS
Screenshots, Printing and Export to XPS

SciChart features a number of ways to export the chart to bitmap, print or vector format.

Export to BitmapSource

SciChart supports export to BitmapSource (in memory bitmap). To screenshot the current chart on screen and get a bitmap in memory, call the following code:

Export to BitmapSource
Copy Code
// Assumes the SciChartSurface is on screen and currently visible
// What you see is what will be exported
BitmapSource bitmap = sciChartSurface.ExportToBitmapSource();

The  WPF BitmapSource type can be loaded into an Image on screen, or saved to file, or copied to clipboard.

 

Export to BitmapSource at Specific Size

SciChart supports exporting to BitmapSource (in-memory bitmap) at a specific resolution and size. This method can be used to create a larger or higher resolution image than the chart currently on screen.

To do this, please use the following code:

Exporting a Bitmap at Specific Resolution
Copy Code
// When true, enables higher resolution XamlRenderSurface as an intermediary. 
// Available in the SDK and Enterprise versions only
bool useXamlRenderSurface = false; 

// When not null, exports to the size defined. When null, exports to the current size. 
Size? exportedSize = null;

// Export to BitmapSource at size 
var bitmapSource = surface.ExportToBitmapSource(useXamlRenderSurface, exportdSize);
NOTE: If you experience problems in the output image when exporting at size, please see the article Troubleshooting and Caveats and Exporting Chart Images. This covers the problems you might see when using flag useXamlRenderSurface=true or exportedSize!=null and potential workarounds.

 

Copying the Chart to Clipboard

To copy the current chart visual to clipboard, first you need to export to BitmapSource, then set the image on the Clipboard. For instance:

Copying the Chart to Clipboard
Copy Code
private void CopyToClipboard()
{
   // SciChartSurface natively exports to in-memory bitmap-source
   var bmp = customUserControl.SciChartSurface.ExportToBitmapSource();
   Clipboard.SetImage(bmp);
}

 

Export to Png/Jpeg/Bmp File

SciChart supports exporting to file, with PNG, JPEG or BMP formats. To save the current chart visual to file, call the following code:

Export to Png/Jpeg/Bmp File
Copy Code
// When true, enables higher resolution XamlRenderSurface as an intermediary. 
// Available in the SDK and Enterprise versions only
bool useXamlRenderSurface = false; 


// When not null, exports to the size defined. When null, exports to the current size. 
Size? exportedSize = null;

// Assumes the SciChartSurface is on screen and currently visible
// What you see is what will be exported to file
sciChartSurface.ExportToFile(string filename, ExportType.Png, useXamlRenderSurface, exportedSize);
NOTE: If you experience problems in the output image when exporting at size, please see the article Troubleshooting and Caveats and Exporting Chart Images. This covers the problems you might see when using flag useXamlRenderSurface=true or exportedSize!=null and potential workarounds.

 

 

Export to XPS File

In the SDK and Enterprise versions of SciChart, the chart supports exporting to XPS File (scalable vector). To save the chart to an XPS file, call the following code:

Export to Png/Jpeg/Bmp File
Copy Code
// When true, enables higher resolution XamlRenderSurface as an intermediary. 
// Available in the SDK and Enterprise versions only
bool useXamlRenderSurface = false; 

// When not null, exports to the size defined. When null, exports to the current size. 
Size? exportedSize = null;

// Assumes the SciChartSurface is on screen and currently visible
// What you see is what will be exported to file
sciChartSurface.ExportToFile(string filename, ExportType.Xps, useXamlRenderSurface, exportedSize);
NOTE: If you experience problems in the output image, please see the article Troubleshooting and Caveats and Exporting Chart Images. This covers the problems you might see when using flag ExportType.Xps, useXamlRenderSurface=true or exportedSize and potential workarounds.

 

 

Printing to PDF / Printer / XPS

SciChart supports printing (shows a Print Dialog). The following code prints the current chart visual to a printer specified by the user. You can print to PDF or XPS by choosing a PDF writer or Microsoft XPS writer as the current printer.

Printing to PDF / Printer / XPS
Copy Code
// Assumes the SciChartSurface is on screen and currently visible
// What you see is what will be printed
// This method will show a print dialog
sciChartSurface.Print(string description = null);