Articles in this section
Category / Section

How to create PDF in .NET Core 3.1

4 mins read

The Syncfusion Essential® PDF is a feature-rich and high-performance .NET Core PDF library that is used to create, read, and edit PDF documents programmatically without Adobe dependencies. Using this library, you can create a PDF document in NET Core 3.1.

Steps to create a PDF document programmatically in NET Core 3.1

1. Create a new C# console application project.

Create a new console application

2. Install the Syncfusion.PDF.Core NuGet package as a reference to your .NET Core Framework application from NuGet.org.

Install the nuget packages

3. Install the System.Drawing.Common NuGet package as a reference to your application.

Install drawing nuget packages

4. Include the following namespaces in the Program.cs file.

C#

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

 

5. The following code example shows how to create a PDF document using C#.

C#

//Create a new PDF document.
 
PdfDocument document = new PdfDocument();
 
// Set the page size.
 
document.PageSettings.Size = PdfPageSize.A4;
 
//Add a page to the document.
 
PdfPage page = document.Pages.Add();
 
//Create PDF graphics for the page.
 
PdfGraphics graphics = page.Graphics;
 
//Set the font.
 
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
 
//Draw the text.
 
graphics.DrawString("Hello World!!!", font, PdfBrushes.Black, new PointF(0, 0));
 
//Save the document.
 
FileStream fileStream = new FileStream("Sample.pdf", FileMode.Create, FileAccess.ReadWrite);
 
//Save and close the PDF document
document.Save(fileStream);
document.Close(true);

 

A complete working sample can be downloaded from CreatePDF.zip.

By executing the program, you will get the PDF document as follows.

output document screenshot.

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

Refer to here to explore a rich set of Syncfusion Essential® PDF features.

An online sample link to generate a Hello world PDF document.

Note:

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

 

See Also:

https://www.syncfusion.com/kb/9137/how-to-create-a-pdf-file-in-asp-net-core

https://www.syncfusion.com/kb/10189/how-to-create-pdf-in-docker-container

https://www.syncfusion.com/kb/10188/how-to-create-pdf-in-azure-website

https://www.syncfusion.com/kb/10780/how-to-create-pdf-in-azure-using-c

 

Note:

A new version of Essential Studio® for ASP.NET is available. Versions prior to the release of Essential Studio® 2014, Volume 2 will now be referred to as classic versions. The new ASP.NET suite is powered by Essential Studio for JavaScript, providing client-side rendering of HTML5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.

The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio® for ASP.NET. Although Syncfusion® will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.

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 or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied