Export the Diagram to PDF
Syncfusion® WinForms Diagram supports converting a diagram into PDF format using the Syncfusion® PDF.Base DLL. Initially, you need to create an empty PDF document and add pages to the created document.
Required Dll:
Syncfusion.Pdf.Base
The below code snippet is used to convert the Diagram into PDF format.
[C#]
// Creation of PDF document
Syncfusion.Pdf.PdfDocument pdfdoc = new Syncfusion.Pdf.PdfDocument();
// Adds pages to the created PDF document
pdfdoc.Pages.Add();
// Creation of PDF image
PdfImage pdfImage = Syncfusion.Pdf.Graphics.PdfImage.FromImage(this.diagram1.ExportDiagramAsImage(false));
// Placing the diagram
pdfdoc.Pages[0].Graphics.DrawImage(pdfImage, new PointF(0F, 0F), pdfdoc.Pages[0].GetClientSize());
// Saving the PDF file
pdfdoc.Save("Diagram.pdf");
[VB]
' Creation of PDF document
Dim pdfdoc As New Syncfusion.Pdf.PdfDocument()
' Adds pages to the created PDF document
pdfdoc.Pages.Add()
' Creation of PDF image
Dim pdfImage As PdfImage = Syncfusion.Pdf.Graphics.PdfImage.FromImage(Me.diagram1.ExportDiagramAsImage(False))
' Placing the diagram
pdfdoc.Pages(0).Graphics.DrawImage(pdfImage, New PointF(0F, 0F), pdfdoc.Pages(0).GetClientSize())
' Saving the PDF file
pdfdoc.Save("Diagram.pdf")
Please refer the below attached sample.
Conclusion
I hope you enjoyed learning about exporting a diagram to PDF.
You can refer to the WinForms Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!