Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Manipulating PDFs using a programming language is quite difficult for developers, especially on a .NET platform. In this article, we will discuss how you can manage PDFs in C#.NET using several tools that will help you save a lot of productive time and energy. There are several elements to consider when displaying material from PDF files, and much more so when transferring content from other formats to PDF. The tools we will discuss are top-of-the-line products used in the industry by developers and Fortune 500 companies or organizations. The .NET tools that will provide solutions for your PDF problems in an instant are:
IronPDF is the ideal solution for converting HTML websites in .NET and .NET core development. It also does much more than just convert HTML, as it provides a wide variety of additional functions. IronPDF allows developers to create, alter, and extract PDF documents within .NET Core and framework projects. Using the IronPDF package, developers can easily generate or convert PDFs from HTML pages.
IronPDF is a .NET library that allows you to quickly create, read, and manipulate PDF files using only a few lines of code. You may import, move, and index content from existing PDF document storage into your content management and performance applications.
Users can now make images from PDFs as well as PDFs from photographs. Image extraction, support for various image extensions, and PDF printing are all included.
IronPDF also can encrypt PDFs with 128-bit encryption, password-protect PDFs, and digitally sign PDFs.
This functionality allows you to create PDFs from a variety of sources, including HTML, Web Forms, HTML Strings, MVC views, and URLs.
This IronPDF tool allows you to format PDFs in a variety of ways, including adding watermarks, adding pages, deleting pages, changing backgrounds and foregrounds, and much more. IronPDF, in a nutshell, does everything you could imagine doing with PDFs.
Embedded text from PDFs can often be extracted easily. If this doesn't work, however, it may well be because the text is "trapped" within a picture. To scan documents for visual text rather than plain text, use the IronOCR library.
When creating a PDF or adding to an existing PDF, headers and footers can be included. You may create a header and footer for each document page using the Print Options property. These parameters are available on the Chrome PDF Renderer object. This example runs in .NET Core console application.
IronPDF supports almost all operating systems and frameworks compatible with C#, such as:
PSPDFKit Library for .NET is a software development kit (SDK) for editing, filling out forms, redacting, and producing PDFs. It provides a robust API for rapidly adding PDF capability to any .NET application.
PSPDFKit is one of the most popular cross-platform tools for adding PDF compatibility to your app or website. For production use, PSPDFKit SDKs require a commercial license. One of the primary advantages of the PSPDFKit API is that it allows you to integrate various document manipulation methods in your PDF production workflow, such as:
PSPDFKit supports all of the most popular annotation tools:
Both reading and writing XFDF files are supported by the PSPDFKit .NET Library. ImportXfdf and ExportXfdf methods of the Document class can be used to conduct these tasks.
The PSPDFKit .NET Library makes it easy to convert a PDF to an image. To guarantee compatibility and efficiency, PSPDFKit uses native .NET standard features.
The Document Editor may be used to combine many documents into a single unified document.
Remove information that is sensitive, confidential, or privileged by permanently eliminating personal information from PDF documents, in line with GDPR and other privacy rules.
Annotations and bookmarks are stored in a separate JSON file using Instant JSON. This implies that a PDF file will only need to be transmitted once, with any modifications being placed as an overlay to the original PDF.
In this article, we will use a new console application to generate PDF documents.
Open the Visual Studio software and go to the File menu. Select "new project" and then select console application.
Enter the project name and select the path in the appropriate text box. Then, click the Create button. Select the required .NET framework, as in the screenshot below:
The Visual Studio project will now generate the structure for the selected application.
In the next section, we will add the IronPDF and PSPDFKit libraries to the project.
The IronPDF library can be downloaded and installed in four different ways. These are:
The Visual Studio software provides the NuGet Package Manager option to install the package directly to the solution. The below screenshot shows how to open the NuGet Package Manager.
Once the Package Manager GUI opens, search for the keyword "IronPDF" in the Browse section, as in the below screenshot:
We need to select the IronPDF option in the search results and install the package.
Install-Package IronPdf
The IronPDF package will now be installed in the current project.
The third way is to download the NuGet package directly from the IronPDF NuGet Gallery web page.
Visit the IronPDF Download Page to download the latest package directly from the website. After the download, follow the steps below to add the package to the project.
There are four ways to obtain and install the PSPDFKit library. These are as follows:
Developers can easily integrate PSPDFKit using the NuGet package manager. An example of how to do so is below.
After clicking on NuGet Package Manager in tools, a new window will appear with the search bar. Search for PSPDFKit. A list will appear.
In the above image, we can see the list of the related packages from the search. Next, select the desired PSPDFKit option and install the package.
Install-Package PSPDFKit.NET -Version 1.4.1
The package will now be installed in the current project.
The third way is to download the NuGet package directly from the PSPDFKit's NuGet Gallery page.
Instead of downloading the package locally using NuGet, you may use a configuration file to reference the package at a specific location. This is useful in cases in which you have machines that share resources on a network.
nuget.config
file in the same directory as your .NET Application.<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="PSPDFKitSource" value="path\to\directoryContainingNupkg" />
</packageSources>
</configuration>
There may be a need to attach some necessary documentation to a PDF file. In this topic, we will discuss how to merge two or more PDFs using both .NET platforms.
IronPDF's IronPdf.PdfDocument.Merge
class makes it easy to combine two or more PDF documents in C#.NET by using simple and easy-to-understand code.
using IronPdf;
var html_a = @"<p> [PDF_A] </p>
<p> [PDF_A] 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> [PDF_A] 2nd Page</p>";
var Renderer = new IronPdf.ChromePdfRenderer();
using var pdfdoc_a = Renderer.RenderHtmlAsPdf(html_a);
using var pdfdoc_b = Renderer.RenderHtmlAsPdf(html_b);
using var merged = IronPdf.PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
merged.SaveAs("Merged.pdf");
using IronPdf;
var html_a = @"<p> [PDF_A] </p>
<p> [PDF_A] 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> [PDF_A] 2nd Page</p>";
var Renderer = new IronPdf.ChromePdfRenderer();
using var pdfdoc_a = Renderer.RenderHtmlAsPdf(html_a);
using var pdfdoc_b = Renderer.RenderHtmlAsPdf(html_b);
using var merged = IronPdf.PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
merged.SaveAs("Merged.pdf");
Imports IronPdf
Private html_a = "<p> [PDF_A] </p>
<p> [PDF_A] 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> [PDF_A] 2nd Page</p>"
Private Renderer = New IronPdf.ChromePdfRenderer()
Private pdfdoc_a = Renderer.RenderHtmlAsPdf(html_a)
Private pdfdoc_b = Renderer.RenderHtmlAsPdf(html_b)
Private merged = IronPdf.PdfDocument.Merge(pdfdoc_a, pdfdoc_b)
merged.SaveAs("Merged.pdf")
The accompanying code demonstrates how to use the PSPDFKit Document Editor to merge two or more PDFs.
using PSPDFKit;
using PSPDFKit.Providers;
namespace PdfEditing
{
public sealed class Program
{
public static void Main(string [] args)
{
var documentEditor = new DocumentEditor();
documentEditor.ImportDocument(0, DocumentEditor.IndexPosition.BeforeIndex, new FileDataProvider("Assets/dog.pdf"));
documentEditor.ImportDocument(0, DocumentEditor.IndexPosition.BeforeIndex, new FileDataProvider("Assets/cat.pdf"));
documentEditor.SaveDocument(new FileDataProvider("dogCatPair.pdf"));
}
}
}
using PSPDFKit;
using PSPDFKit.Providers;
namespace PdfEditing
{
public sealed class Program
{
public static void Main(string [] args)
{
var documentEditor = new DocumentEditor();
documentEditor.ImportDocument(0, DocumentEditor.IndexPosition.BeforeIndex, new FileDataProvider("Assets/dog.pdf"));
documentEditor.ImportDocument(0, DocumentEditor.IndexPosition.BeforeIndex, new FileDataProvider("Assets/cat.pdf"));
documentEditor.SaveDocument(new FileDataProvider("dogCatPair.pdf"));
}
}
}
Imports PSPDFKit
Imports PSPDFKit.Providers
Namespace PdfEditing
Public NotInheritable Class Program
Public Shared Sub Main(ByVal args() As String)
Dim documentEditor As New DocumentEditor()
documentEditor.ImportDocument(0, DocumentEditor.IndexPosition.BeforeIndex, New FileDataProvider("Assets/dog.pdf"))
documentEditor.ImportDocument(0, DocumentEditor.IndexPosition.BeforeIndex, New FileDataProvider("Assets/cat.pdf"))
documentEditor.SaveDocument(New FileDataProvider("dogCatPair.pdf"))
End Sub
End Class
End Namespace
An annotation is a comment or remark that is added to a text to explain or criticize a specific area of it. In this topic, we will discuss how to add annotations in PDFs using .NET.
PDF annotations allow you to add "sticky note" style comments to PDF documents. The IronPdf.PdfDocument.AddTextAnnotation
method and PdfDocument.TextAnnotation
class allow annotations to be added programmatically. Coloring, size, opacity, icons, and editing are among the advanced text annotation options provided.
// PM> Install-Package IronPdf
using IronPdf;
using PdfDocument Pdf = PdfDocument.FromFile("existing.pdf");
var Annotation = new IronPdf.Annotations.TextAnnotation()
{
Title = "This is the major title",
Subject = "This is a subtitle",
Contents = "This is the long 'sticky note' comment content...",
Icon = IronPdf.Annotations.TextAnnotation.AnnotationIcon.Help,
Opacity = 0.9,
Printable = false,
Hidden = false,
OpenByDefault = true,
ReadOnly = false,
Rotateable = true
};
Pdf.AddTextAnnotation(Annotation, 1, 150, 250);
Pdf.SaveAs("existing.pdf");
// PM> Install-Package IronPdf
using IronPdf;
using PdfDocument Pdf = PdfDocument.FromFile("existing.pdf");
var Annotation = new IronPdf.Annotations.TextAnnotation()
{
Title = "This is the major title",
Subject = "This is a subtitle",
Contents = "This is the long 'sticky note' comment content...",
Icon = IronPdf.Annotations.TextAnnotation.AnnotationIcon.Help,
Opacity = 0.9,
Printable = false,
Hidden = false,
OpenByDefault = true,
ReadOnly = false,
Rotateable = true
};
Pdf.AddTextAnnotation(Annotation, 1, 150, 250);
Pdf.SaveAs("existing.pdf");
' PM> Install-Package IronPdf
Imports IronPdf
Private PdfDocument As using
Private Annotation = New IronPdf.Annotations.TextAnnotation() With {
.Title = "This is the major title",
.Subject = "This is a subtitle",
.Contents = "This is the long 'sticky note' comment content...",
.Icon = IronPdf.Annotations.TextAnnotation.AnnotationIcon.Help,
.Opacity = 0.9,
.Printable = False,
.Hidden = False,
.OpenByDefault = True,
.ReadOnly = False,
.Rotateable = True
}
Pdf.AddTextAnnotation(Annotation, 1, 150, 250)
Pdf.SaveAs("existing.pdf")
For describing PDF annotations, PSPDFKit for .NET provides a JSON-based API. This gives you a lot of freedom when it comes to dealing with annotations since you may have handmade annotations in your code or a JSON file that you import as needed.
using Newtonsoft.Json.Linq;
using PSPDFKit;
using PSPDFKit.Providers;
namespace Annotations
{
public sealed class Program
{
public static void Main(string [] args)
{
var Provider = new FileDataProvider("document.pdf");
var documentpdf = new Document(Provider);
var aProvider = document.GetAnnotationProvider();
var textAnJson = new JObject
{
{ "text", "Hello from PSPDFKit" },
{ "bbox", new JArray(10, 10, 400, 400) },
{ "creatorName", "Will" },
{ "type", "pspdfkit/text" },
{ "updatedAt", "2021-01-01T00:00:00Z" },
{ "v", 1 }
};
annotationProvider.AddAnnotationJson(textAnJson);
document.Save(new DocumentSaveOptions())
}
}
}
using Newtonsoft.Json.Linq;
using PSPDFKit;
using PSPDFKit.Providers;
namespace Annotations
{
public sealed class Program
{
public static void Main(string [] args)
{
var Provider = new FileDataProvider("document.pdf");
var documentpdf = new Document(Provider);
var aProvider = document.GetAnnotationProvider();
var textAnJson = new JObject
{
{ "text", "Hello from PSPDFKit" },
{ "bbox", new JArray(10, 10, 400, 400) },
{ "creatorName", "Will" },
{ "type", "pspdfkit/text" },
{ "updatedAt", "2021-01-01T00:00:00Z" },
{ "v", 1 }
};
annotationProvider.AddAnnotationJson(textAnJson);
document.Save(new DocumentSaveOptions())
}
}
}
Imports Newtonsoft.Json.Linq
Imports PSPDFKit
Imports PSPDFKit.Providers
Namespace Annotations
Public NotInheritable Class Program
Public Shared Sub Main(ByVal args() As String)
Dim Provider = New FileDataProvider("document.pdf")
Dim documentpdf = New Document(Provider)
Dim aProvider = document.GetAnnotationProvider()
Dim textAnJson = New JObject From {
{ "text", "Hello from PSPDFKit" },
{ "bbox", New JArray(10, 10, 400, 400) },
{ "creatorName", "Will" },
{ "type", "pspdfkit/text" },
{ "updatedAt", "2021-01-01T00:00:00Z" },
{ "v", 1 }
}
annotationProvider.AddAnnotationJson(textAnJson)
document.Save(New DocumentSaveOptions())
End Sub
End Class
End Namespace
IronPDF offers a free developer license. IronPDF also offers a unique pricing structure: the basic bundle starts at $749 with no additional costs. It is also possible to redistribute SaaS and OEM products. A 30-day money-back guarantee, a year of software support and upgrades, dev/staging/production validity, and a perpetual license are included with all licenses (one-time purchase). Learn about IronPDF licensing details to explore IronPDF's available licenses and pricing structures.
PSPDFKit offers five types of licenses for the productivity workflows it has developed. It has a free license for up to 100 documents per month; for anything above that number, you will need to purchase one of the following packages:
This PSPDFKit Pricing Page details PSPDFKit's complete price structure.
IronPDF does not convert HTML to PDF from a remote server. Instead, it starts an instance of a real standard-compliant browser behind the scenes (without any additional software needing to be installed). The HTML is rendered in a vector format that is suitable for commercial printing to the highest standards. As a consequence, you get a crisp, high-quality PDF. The IronPDF website provides information on licenses and prices.
PSPDFKit is a fully-featured PDF SDK that supports all platforms, including PC, MAC, Android Apps, and IOS. It assists with transitioning, annotating, signing, filling, converting, and editing PDF files. PSPDFKit is the most widely used cross-platform solution for integrating PDF support into your app or website.
Both IronPDF and PSPDFKit require commercial licenses for production use. IronPDF offers a lifetime license, whereas PSPDFKit offers monthly and yearly packages. IronPDF licenses are developer-centric. Its pricing model is structured on the number of developers using the product and their work locations. PSPDFKit licenses are document-centric, being structured around the number of PDF documents processed per month. In terms of costs, using PSPDFKit incurs recurring expenses. On the other hand, IronPDF provides lifetime licensing with no recurring costs.
Both IronPDF and PSPDFKit are industry-leading frameworks based on similar technologies that offer the same basic PDF-processing features. Code written using IronPDF tends to be more succinct and compact. Code written with PSPDFKit code is equally understandable, but a bit more complex in structure.
Iron Software is offering a five-tool bundle for the price of just two. The tools on offer are:
To learn more about the bundled tools, please visit IronSuite's official page.
9 .NET API products for your office documents