Articles in this section
Category / Section

How to export the Diagram as a PDF in the WPF Diagram (SfDiagram)?

1 min read

WPF Diagram (SfDiagram) does not have the built-in support to convert the diagram to PDF file, but it can be achieved by exporting the diagram as an XPS file and then, convert the exported XPS file to PDF using the Syncfusion.XPS.XPSToPdfConverter.

Exporting XPS

To export the diagram as an XPS file, enable the IsSaveToXps property of the ExportSettings class and specify the file name with the “.xps” extension.

Exporting XPS to PDF

The XPS document can be converted into PDF file using the XPSToPdfConverter class of PDF library.


            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="100"/>
     <syncfusion:SfDiagram x:Name="diagram"  Grid.Column="0">
                    <syncfusion:NodeViewModel OffsetX="100" OffsetY="100" 
                                UnitHeight="100" UnitWidth="100"/>
                    <syncfusion:ConnectorViewModel SourcePoint="100,100" TargetPoint="200,200" />
    <Button x:Name="Export" Grid.Column="1" Click="Export _Click" Content="Export"/>



private void Export _Click(object sender, RoutedEventArgs e)
  diagram.ExportSettings = new ExportSettings()
    IsSaveToXps = true,
    FileName = "export.xps",
  (diagram.Info as IGraphInfo).Export();
  var converter = new XPSToPdfConverter { };
  var document = new PdfDocument();
  document = converter.Convert("export.xps");


View Sample in GitHub

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied