How to export a graph as PDF
Questions & AnswersSummary
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
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.