Category / Section
Export the Diagram to PDF
2 mins read
Syncfusion® WinForms Diagram has the support to convert the Diagram into PDF format using the Syncfusion® PDF.Base Dll. Initially need to create an Empty Pdf document and add pages for 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 for 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 for 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.