We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to draw grid in PDF with conformance

Platform: WinForms |
Control: PDF |
Published Date: September 25, 2018 |
Last Revised Date: May 3, 2019

Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can draw grid in conformance PDF or PDF/A-1b using C# and VB.NET.

Steps to draw grid in PDF with the conformance

  1. Create a new C# console application project. Create new console application
  2. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your  .NET Framework applications from NuGet.org. Install nuget packages
  3. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Grid;
using System.Data;
using System.Drawing;

  

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Graphics
Imports Syncfusion.Pdf.Grid
Imports System.Data
Imports System.Drawing

 

  1. Use the following code snippet to draw grid or table in PDF/A-1b document.

C#

//Create a new PDF document
PdfDocument doc = new PdfDocument(PdfConformanceLevel.Pdf_A1B);
 
//Add a page
PdfPage page = doc.Pages.Add();
 
//Create a PdfGrid
PdfGrid pdfGrid = new PdfGrid();
pdfGrid.Style.Font = new PdfTrueTypeFont(new Font("Arial Unicode MS", 14), true);
 
//Create a DataTable
DataTable dataTable = new DataTable();
 
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
 
//Add rows to the DataTable
dataTable.Rows.Add(new object[] { "E01", "Mark" });
dataTable.Rows.Add(new object[] { "E02", "Chad" });
 
//Assign data source
pdfGrid.DataSource = dataTable;
 
//Draw grid to a page of the PDF document
pdfGrid.Draw(page, new PointF(10, 10));
 
//Save the document
doc.Save("Output.pdf");
 
//Close the document
doc.Close(true);

 

VB.NET

'Create a new PDF document
Dim doc As New PdfDocument(PdfConformanceLevel.Pdf_A1B)
 
'Add a page
Dim page As PdfPage = doc.Pages.Add()
 
'Create a PdfGrid
Dim pdfGrid As New PdfGrid()
pdfGrid.Style.Font = New PdfTrueTypeFont(New Font("Arial Unicode MS", 14), True)
 
'Create a DataTable
Dim dataTable As New DataTable()
 
'Add columns to the DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
 
'Add rows to the DataTable
dataTable.Rows.Add(New Object() {"E01", "Mark"})
dataTable.Rows.Add(New Object() {"E02", "Chad"})
 
'Assign data source
pdfGrid.DataSource = dataTable
 
'Draw grid to a page of the PDF document
pdfGrid.Draw(page, New PointF(10, 10))
 
'Save the document
doc.Save("Output.pdf")
 
'Close the document
doc.Close(True)

 

You can download the work sample from PdfGridConformanceSample.Zip

By executing the program, you will get the PDF document as follows. Screenshot of output PDF file

Take a moment to peruse the documentation, where you will find other options like drawing right-to-left text and multi-column text, consuming TrueType fonts, Standards fonts, CJK fonts. Also, the features like PDF form filling, extract text or images from PDF, protect PDF documents with code examples.

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

 

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile