How to export a graph as PDF

Questions & Answers

Summary

This article describes the options for exporting a Graph to PDF in our .NET platform products
For a better user experience, please go to the integrated documentation viewer to read this article.

Description

Neither yFiles WPF nor yFiles.NET support PDF export out of the box. Therefore, you need to resort to external tools or third libraries to export the graph canvas to PDF.

Use a PDF printer

Most operating systems either provide a virtual PDF printer out of the box or let you install a third party solution that provides that capability.

Export to an intermediate vector format

yFiles WPF: Export to XPS

In yFiles WPF, you can export the Canvas to XPS which can then be programmatically converted to PDF by means of third party libraries (e.g. PDFSharp). Exporting to XPS is described in the yFiles WPF Developer's Guide. To avoid temporary files, you can export the XPS directly to a .NET MemoryStream

yFiles.NET: Export to EMF

Similarly, in yFiles.NET, you can export the Canvas to EMF which can then be programmatically converted to PDF by means of third party libraries (e.g. Foxit). Exporting to EMF is described in the yFiles.NET Developer's Guide. To avoid temporary files, you can export the EMF directly to a .NET MemoryStream

Platform independent

There are many third party tools that can convert XPS or EMF files to PDF. Most of them can also be used in a non-interactive batch workflow.

Create your own PDF export

Using a third party library, you can also create your own customized PDF export from scratch. Since none of these libraries provides an alternative rendering backend that can just serve as a drop-in replacement for the standard rendering backend, this would require you to manually iterate the graph structure and build suitable PDF objects from scratch.

Categories this article belongs to:
yFiles WPF > yFiles WPF Viewer > Input and Output > Exporting the Canvas's Content
yFiles.NET > yFiles.NET Viewer > Input and Output > Exporting the Canvas's Content
Applies to:
yFiles.NET: 2.2, 2.3, 2.4, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 6.0
yFiles WPF: 1.0, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 4.0
Keywords:
export - pdf - vector graphics