.NET Core PDF Library

IronPDF is available for Microsoft Windows .NET framework 4.x, as well as a recent release for .NET Core 3.1, .NET 6 & 5.

IronPDF for .NET Core is available through the Nuget Package manager: Package Name Pdf.Core

The current .NET Core release supports Linux, Unix and macOS client operating systems as well as mono. A future release will support Xamarin mobile environments.

Existing and new customers receive free upgrades to the .NET Core build of IronPDF within their existing Support & Upgrade coverage. This is provided with every commercial license. This ensures your investment in IronPDF is Future Proofed.

Existing customers who wish to extend expired support & update cover can purchase an extension here.

You can download the software product from this link.

An Introduction to .NET Core

The .NET Core is an open-source, general-purpose development platform maintained by Microsoft, the .NET Foundation, and community contributors. The software consists of a general-purpose class library called Framework Class Library (FCL) and a just-in-time compiler called RyuJIT. The FFL provides a set of APIs that the programmer can use to write their software. It also includes a runtime that supports the execution of these applications on operating systems supported by the CoreCLR project. The .NET Core 3.0 is the latest version. This version comes with significant updates that are very handy for the developers.

This article will overview a PDF library that we can use to generate awesome PDF files and modify existing files without the hassle of installing multiple libraries in the dot net core program.

IronPDF: A .NET PDF Library

IronPDF is a C# PDF library that can be used in net core projects. It provides all the necessary APIs to manipulate PDF documents straightforwardly and intuitively. There are other PDF-generating libraries on the market, but this library has been designed as simply as possible to avoid confusion.

The main goal of this project is to provide a PDF library for .NET applications. It comes with many useful features, such as generating PDF files from HTML strings, converting PDFs to other formats, manipulating existing PDF documents, and generating PDF files directly from net core projects. We can use the IronPDF library to print PDF files with just a few lines. IronPDF can be used as a PDF converter. It can create multi-page spread tables using its accessible functions.

IronPDF uses HTML strings to specify the desired appearance of a PDF document. It then converts this string into an intermediate file compiled into the final PDF document. The result is a standard-compliant, 100% free PDF library explicitly designed for C# developers. IronPDF is cross-platform supported. You can use the IronPDF library on Windows, Linux, and macOS.

The latest version of IronPDF is very flexible. It supports .NET 5 and .NET 6 frameworks with full compatibility that allows developers to quickly work with the latest technology. It also works with the older .NET core versions and the latest 3.x version for better performance. So, .NET developers can work with complete compatibility and flexibility while working with the IronPDF library in their dot net core and .NET projects.

Let's begin using the IronPDF library in our project.

Create C# Project

We will use the Visual Studio 2022 version for creating our .NET project. The latest version of Visual Studio is strongly recommended for a smooth user experience. We can also use the IronPDF library in a dot net core project. It depends on the user, because installing and using IronPDF is identical for every .NET framework. Follow the steps below to create a project in Visual Studio 2022.

  • Start Visual Studio 2022.

  • Click on "Create a new project".
  • Search for "Console" in the search field, and select "Console App C#" from the search results.
  • After that, configure the project name according to your requirement.
  • After that, select the .NET framework 6.0 from the dropdown list. This is recommended. Next, click on the Create button.

The project will now be created. You can also use existing dot net core projects with IronPDF. First, you need to install the library. We will take a look at how we can install the library in the next section.

Installation of the IronPDF Library

We can install the IronPDF library from the console. Simply write the following line of code in the console and hit Enter.

Install-Package IronPdf -Version 2022.6.6115

The latest version of IronPDF supports .NET Framework 6.0 and the .NET core 3.x version, the latest version. You can get more information on the IronPDF website and the IronPDF NuGet website.

After installation, you will be able to use it in your .NET project. For more details about installation, visit the IronPDF website.

In the next section, we will look at code examples to see how we can use the IronPDF library's functions.

Code Example

A web page for PDF files

using IronPdf;

var Renderer = new IronPdf.ChromePdfRenderer();
//Choose Screen or Print CSS media
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen;

//Set the width of the responsive virtual browser window in pixels
Renderer.RenderingOptions.ViewPortWidth = 1280;
Renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A2;

var PDF = Renderer.RenderUrlAsPdf("https://www.amazon.com/");
PDF.SaveAs("Amazon.pdf");
using IronPdf;

var Renderer = new IronPdf.ChromePdfRenderer();
//Choose Screen or Print CSS media
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen;

//Set the width of the responsive virtual browser window in pixels
Renderer.RenderingOptions.ViewPortWidth = 1280;
Renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A2;

var PDF = Renderer.RenderUrlAsPdf("https://www.amazon.com/");
PDF.SaveAs("Amazon.pdf");
Imports IronPdf

Private Renderer = New IronPdf.ChromePdfRenderer()
'Choose Screen or Print CSS media
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen

'Set the width of the responsive virtual browser window in pixels
Renderer.RenderingOptions.ViewPortWidth = 1280
Renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A2

Dim PDF = Renderer.RenderUrlAsPdf("https://www.amazon.com/")
PDF.SaveAs("Amazon.pdf")
VB   C#

In this example, we convert a complex website UI to PDF — we transform the Amazon website into a PDF file. First, we set the Media Type to the Screen. After that, we set the viewport width. And finally, we set the paper size of our output PDF. Page size is a significant factor with PDF files. Lastly, we render the URL to PDF, and in the parameter, we give the URL of Amazon.

Output

Simple PDF Creation

using IronPdf;
// Instantiate Renderer
var Renderer = new IronPdf.ChromePdfRenderer();

// Create a PDF from a HTML string using C#
using var pdf = Renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");

// Export to a file or Stream
pdf.SaveAs("output.pdf");

/****** Advanced Example with HTML Assets ******/
// Load external html assets: images, css and javascript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
using var myAdvancedPdf = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");

pdf.SaveAs("html-with-assets.pdf");
using IronPdf;
// Instantiate Renderer
var Renderer = new IronPdf.ChromePdfRenderer();

// Create a PDF from a HTML string using C#
using var pdf = Renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");

// Export to a file or Stream
pdf.SaveAs("output.pdf");

/****** Advanced Example with HTML Assets ******/
// Load external html assets: images, css and javascript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
using var myAdvancedPdf = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");

pdf.SaveAs("html-with-assets.pdf");
Imports IronPdf
' Instantiate Renderer
Private Renderer = New IronPdf.ChromePdfRenderer()

' Create a PDF from a HTML string using C#
Private pdf = Renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")

' Export to a file or Stream
pdf.SaveAs("output.pdf")

'''**** Advanced Example with HTML Assets *****
' Load external html assets: images, css and javascript.
' An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
Dim myAdvancedPdf = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")

pdf.SaveAs("html-with-assets.pdf")
VB   C#

In the above example, we use the HTML-to-PDF functionality of IronPDF. First of all, we have to import IronPDF to our project. We write "using IronPDF;" at the top of the program file to use it in our project.

We use ChromeRenderer for web support. Then we use the RenderHtmlAsPdf function for converting HTML strings to PDF files. In function parameter, we provide HTML string. You can also use images in your PDF document by setting the base path of images. After that, we use the SaveAs function to save the PDF file on our machine. You can choose simple HTML like the above and incorporate CSS, images, and JavaScript.

Output

Headers & Footers

Renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a coverpage  will be appended
Renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
Renderer.RenderingOptions.TextHeader.CenterText = "{url}";
Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica;
Renderer.RenderingOptions.TextHeader.FontSize = 12;
Renderer.RenderingOptions.FirstPageNumber = 1; // use 2 if a coverpage  will be appended
Renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
Renderer.RenderingOptions.TextHeader.CenterText = "{url}";
Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica;
Renderer.RenderingOptions.TextHeader.FontSize = 12;
Renderer.RenderingOptions.FirstPageNumber = 1 ' use 2 if a coverpage  will be appended
Renderer.RenderingOptions.TextHeader.DrawDividerLine = True
Renderer.RenderingOptions.TextHeader.CenterText = "{url}"
Renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica
Renderer.RenderingOptions.TextHeader.FontSize = 12
VB   C#

The above example demonstrates how to set headers and footers in our PDF file. IronPDF supports repeating headers in our document. IronPDF gives TextHeader and TextFooter properties to set the multiple properties of text, such as fonts, text position, etc. We can also convert HTML files to PDF files. It is all straightforward with IronPDF. We can also merge PDF files, perform webpage-to-PDF, enable automatic page numeration, and make digital signatures using IronPDF. Further, it produces PDF files of minimal file size.

Summary

IronPDF is a complete PDF library that supports all the latest versions of dot net core and .NET frameworks. IronPDF is based on a business model that offers a secure way to create and edit business documents using the IronPDF library. Its advanced features enable the user to create dynamic and creative PDF documents in dot net core projects.

The free version of IronPDF is entirely free for developers. You can use it for development purposes for free with a watermark. There is also the option to try the 30-day free trial for production testing.

You can also currently buy the suite of five Iron Software packages for the price of just two. Get more information from the IronPDF website.