.NET HELP

C# PDF NuGet (How it Works for Developers)

In the modern world of digital documentation, handling PDF documents has become increasingly important. Whether it's converting HTML to PDF documents, PDF encryption, managing NuGet packages using the Package Manager Console in Visual Studio, or utilizing the .NET Standard 2.0 framework/.NET Core 2.0, developers need a robust and efficient PDF file library. This article will introduce IronPDF, a comprehensive .NET/Core PDF library compatible with .NET Core 2.0, .NET Framework 7, .NET 6.0, and other .NET platforms, and explore its features and benefits.

Introduction of NuGet

NuGet is the package manager for .NET developers, making it easy to manage and include libraries and packages in projects. It simplifies the process of finding, installing, and managing third-party libraries, ensuring version compatibility and streamlining development workflows. NuGet packages can be installed via Visual Studio or through the Package Manager Console.

IronPDF: C# PDF Library

C# PDF NuGet (How It Works For Developers): Figure 2 - IronPDF- Create a PDF

IronPDF is a powerful and easy-to-use .NET PDF library designed to facilitate the creation, modification, and conversion of PDFs. It is available as a NuGet package for IronPDF. It offers a wide range of functionalities, including HTML files to PDF conversion, editing PDF documents, and watermarking. IronPDF is compatible with .NET Core, .NET Framework 4.0+, and other .NET platforms, making it the ideal choice for developers working with PDF files in their projects.

Compatibility of IronPDF

IronPDF is a highly compatible and adaptable .NET PDF conversion library that seamlessly integrates with various .NET platforms. This broad compatibility ensures that developers can effortlessly incorporate IronPDF into their existing projects, regardless of the platform they are using.

C# PDF NuGet (How It Works For Developers): Figure 3 - Cross Platform

.NET Standard 2.0: As a .NET Standard 2.0 compliant library, IronPDF allows developers to create cross-platform applications targeting multiple .NET implementations. Its compatibility with .NET Standard 2.0 means that developers can leverage IronPDF's features in .NET Core, .NET Framework, and Xamarin projects, among others.

.NET Core 7.0 compatibility: IronPDF's compatibility with .NET Core 7.0 ensures that developers can utilize it in modern, high-performance applications. .NET Core is an open-source, cross-platform framework designed for creating cloud-based and containerized applications, and IronPDF's support for this platform ensures developers can leverage its capabilities in a wide range of scenarios.

.NET Framework 7.0: IronPDF is also compatible with the .NET Framework 7.0, allowing developers to integrate its powerful PDF functionalities into legacy projects built on this popular framework. As .NET Framework remains widely used in enterprise environments, IronPDF's compatibility with version 7.0 and newer ensures that developers can continue to maintain and enhance existing applications with ease.

Install with NuGet Package Manager

IronPDF is an essential .NET PDF library that simplifies working with PDF files and web pages in .NET applications. To install IronPDF on a Windows computer using the NuGet Package Manager, follow these steps within Visual Studio:

  1. Open Visual Studio and navigate to your desired project.
  2. Go to the "Tools" menu, then select "NuGet Package Manager," followed by "Package Manager Console." This will open the Package Manager Console window.
  3. In the console, enter the following command to install the package:

    Install-Package IronPdf
    Install-Package IronPdf
    SHELL
  4. Press "Enter" to execute the command, and Visual Studio will download and install the latest version of IronPDF, incorporating it into your project.

To stay informed about the latest version updates or service status of nuget.org, check the IronPDF Updates and Version Information or subscribe to release notifications. Version updates usually include new features, performance improvements, and bug fixes, ensuring that you're always using the most robust and efficient version of IronPDF.

IronPDF also offers specific NuGet packages for deployment on Linux and macOS. These packages are designed to simplify the process of deploying your application on non-Windows platforms.

Features of IronPDF

IronPDF boasts an array of features that cater to the diverse needs of developers working with PDF documents. These features include:

Convert HTML to PDF in C#

IronPDF allows developers to easily convert HTML content, including CSS and JavaScript, to high-quality PDF files. The following code example demonstrates how to create a PDF from an HTML string using C# and no Adobe Acrobat:

using IronPdf;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("Hello World");

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

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("Hello World");

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

' Instantiate Renderer
Private renderer = New ChromePdfRenderer()

' Create a PDF from an HTML string using C#
Private pdf = renderer.RenderHtmlAsPdf("Hello World")

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

C# PDF NuGet (How It Works For Developers): Figure 4 - HTML to PDF Output

Edit PDF

With IronPDF, developers can edit PDF documents, add or remove pages, and manipulate the content within the documents. The following code example demonstrates how to split a PDF document into separate files based on page breaks:

using IronPdf;

// Define multi-page HTML content
const string html = @"Hello Iron
                      This is 1st Page

                      This is 2nd Page

                      This is 3rd Page";

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);

// Take the first page
var page1doc = pdf.CopyPage(0);
page1doc.SaveAs("Split1.pdf");

// Take the pages 2 & 3
var page23doc = pdf.CopyPages(1, 2);
page23doc.SaveAs("Split2.pdf");
using IronPdf;

// Define multi-page HTML content
const string html = @"Hello Iron
                      This is 1st Page

                      This is 2nd Page

                      This is 3rd Page";

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);

// Take the first page
var page1doc = pdf.CopyPage(0);
page1doc.SaveAs("Split1.pdf");

// Take the pages 2 & 3
var page23doc = pdf.CopyPages(1, 2);
page23doc.SaveAs("Split2.pdf");
Imports IronPdf

' Define multi-page HTML content
Private Const html As String = "Hello Iron
                      This is 1st Page

                      This is 2nd Page

                      This is 3rd Page"

Private renderer = New ChromePdfRenderer()
Private pdf = renderer.RenderHtmlAsPdf(html)

' Take the first page
Private page1doc = pdf.CopyPage(0)
page1doc.SaveAs("Split1.pdf")

' Take the pages 2 & 3
Dim page23doc = pdf.CopyPages(1, 2)
page23doc.SaveAs("Split2.pdf")
$vbLabelText   $csharpLabel

C# PDF NuGet (How It Works For Developers): Figure 5 - Split Output

Security of PDF documents

IronPDF offers robust PDF security features, including encryption, password protection, and digital signatures. The following code example demonstrates how to apply encryption and password protection to a PDF document:

using IronPdf;

// Load an existing PDF document
var pdf = PdfDocument.FromFile("input.pdf");

// Set encryption and password protection
pdf.Encrypt(PdfDocument.EncryptionAlgorithm.AES, 256, "ownerPassword", "userPassword");

// Save the encrypted PDF document
pdf.SaveAs("encrypted_output.pdf");
using IronPdf;

// Load an existing PDF document
var pdf = PdfDocument.FromFile("input.pdf");

// Set encryption and password protection
pdf.Encrypt(PdfDocument.EncryptionAlgorithm.AES, 256, "ownerPassword", "userPassword");

// Save the encrypted PDF document
pdf.SaveAs("encrypted_output.pdf");
Imports IronPdf

' Load an existing PDF document
Private pdf = PdfDocument.FromFile("input.pdf")

' Set encryption and password protection
pdf.Encrypt(PdfDocument.EncryptionAlgorithm.AES, 256, "ownerPassword", "userPassword")

' Save the encrypted PDF document
pdf.SaveAs("encrypted_output.pdf")
$vbLabelText   $csharpLabel

PDF Metadata

IronPDF enables developers to edit and manage the metadata of PDF documents, such as author, keywords, and modified date. The following code example demonstrates how to modify the metadata of an existing PDF:

using IronPdf;

// Open an Encrypted File, alternatively create a new PDF from HTML
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");

// Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = System.DateTime.Now;
using IronPdf;

// Open an Encrypted File, alternatively create a new PDF from HTML
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");

// Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = System.DateTime.Now;
Imports System
Imports IronPdf

' Open an Encrypted File, alternatively create a new PDF from HTML
Private pdf = PdfDocument.FromFile("encrypted.pdf", "password")

' Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto"
pdf.MetaData.Keywords = "SEO, Friendly"
pdf.MetaData.ModifiedDate = DateTime.Now
$vbLabelText   $csharpLabel

Watermark

IronPDF allows developers to add watermarks to their PDF documents for security and branding. The following code example demonstrates how to stamp a watermark onto a new or existing PDF:

using IronPdf;

// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();

var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("SAMPLE", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
using IronPdf;

// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();

var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("SAMPLE", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
Imports IronPdf

' Stamps a Watermark onto a new or existing PDF
Private renderer = New ChromePdfRenderer()

Private pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
pdf.ApplyWatermark("SAMPLE", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
pdf.SaveAs("C:\Path\To\Watermarked.pdf")
$vbLabelText   $csharpLabel

C# PDF NuGet (How It Works For Developers): Figure 6 - Watermark Output

Conclusion

IronPDF is a versatile and powerful .NET library that simplifies the process of working with PDF documents in .NET projects. With its extensive features, such as HTML to PDF conversion, PDF modification, security, metadata management, and watermarking, IronPDF is an invaluable asset for developers looking to enhance their applications and improve productivity. Compatible with .NET Standard 2.0, .NET Core 7.0, and .NET Framework 7.0, IronPDF can be easily integrated into existing projects through NuGet, making it a must-have tool for developers working with PDF files.

IronPDF offers a free trial of IronPDF, which allows users to test out its features and functionality before committing to a purchase. After the trial period, users can choose to purchase a license for IronPDF, which starts at a certain price. The pricing for IronPDF depends on the type of license and the number of developers using the software.

Frequently Asked Questions

What is IronPDF?

IronPDF is a .NET PDF library that allows developers to create, modify, and convert PDF documents. It is available as a NuGet package and is compatible with various .NET platforms.

How do I install IronPDF using NuGet?

To install IronPDF using NuGet, open Visual Studio, go to 'NuGet Package Manager' in the Tools menu, select 'Package Manager Console', and enter the command 'Install-Package IronPdf' in the console.

What platforms is IronPDF compatible with?

IronPDF is compatible with .NET Core, .NET Framework 4.0+, .NET Standard 2.0, .NET Core 7.0, and .NET Framework 7.0, among others.

Can IronPDF convert HTML to PDF?

Yes, IronPDF can convert HTML content, including CSS and JavaScript, into high-quality PDF files using C#.

Does IronPDF support PDF encryption?

Yes, IronPDF offers robust PDF security features, including encryption, password protection, and digital signatures.

How can I edit PDF metadata using IronPDF?

IronPDF allows you to edit and manage PDF metadata such as author, keywords, and modified date using C#.

Can I add watermarks to PDFs with IronPDF?

Yes, IronPDF provides functionality to add watermarks to PDF documents, which can be used for security and branding purposes.

Is there a free trial for IronPDF?

IronPDF offers a free trial that allows users to test its features and functionality before purchasing a license.

What are some use cases for IronPDF?

IronPDF can be used for HTML to PDF conversion, editing PDF documents, adding watermarks, and securing PDFs, making it useful for developers working on .NET applications that require PDF functionalities.

How can I stay informed about IronPDF updates?

You can check the IronPDF Updates and Version Information on the NuGet website or subscribe to release notifications to stay informed about the latest updates.

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of all products is growing daily, as he finds new ways to support customers. He enjoys how collaborative life is at Iron Software, with team members from across the company bringing their varied experience to contribute to effective, innovative solutions. When Chipego is away from his desk, he can often be found enjoying a good book or playing football.
< PREVIOUS
How to use .NET Fiddle in C#
NEXT >
Razor Components : How it Works for Developers