A Comparison Between IronPDF & Apryse C#
1. Introduction
As C# developers, dealing with PDFs is a common part of our job, especially when building applications that need to generate, edit, or display documents. That's why having a good PDF library is crucial. These libraries save us time and hassle by providing built-in functions for complex tasks like converting documents, editing text, and handling images within PDFs. Without them, we'd have to write all that code from scratch, which is not only time-consuming but also prone to errors.
In this comparison, we're looking at two popular PDF libraries: IronPDF and Apryse C#. IronPDF is known for its robust features that make working with PDFs in a .NET environment a breeze, from converting HTML to PDF to advanced document editing. Apryse C#, on the other hand, offers a streamlined approach to PDF manipulation, focusing on ease of use and efficiency. We'll dive into the specifics of what each library offers to help you decide which one might be the best fit for your project.
2. Apryse C#
Apryse C# is a comprehensive PDF library for .NET applications, designed to streamline the process of PDF manipulation within C# environments. It was previously known as PDFTron SDK. Its broad range of features and tools makes it an invaluable asset for developers looking to handle PDFs with precision and ease.
2.1 Key Features
- Easy Integration with .NET Projects: Apryse C# offers seamless integration with .NET, including ASP.NET Core and traditional .NET Framework applications. This ensures developers can incorporate PDF functionalities directly into their projects without extensive setup or configuration.
- Document Creation and Editing: Developers can create PDFs from scratch or edit existing ones using Apryse C#. This includes adding text, images, and forms, and even manipulating PDF pages—such as reordering, merging, or splitting documents—directly within their applications.
- HTML to PDF Conversion: With Apryse C#, converting HTML content to PDF format is straightforward. This feature is particularly useful for generating invoices, reports, and other documents from web pages or HTML templates.
- Extensive Support for Form Fields: Apryse C# provides robust support for PDF form fields, allowing developers to create, edit, and fill PDF forms programmatically. This is ideal for automating the generation of filled forms based on user input or external data sources.
- Text and Content Extraction: The library enables the extraction of text and other content from PDF documents. This feature is essential for applications that need to analyze or process the information contained in PDFs, such as search tools or content management systems.
- Security and Encryption: Apryse C# offers comprehensive security features, including the ability to encrypt PDF documents, set permissions, and manage digital signatures. This ensures that sensitive documents are protected and meet compliance standards.
- Advanced PDF Features: Developers can leverage advanced PDF features such as annotations, bookmarks, and hyperlinks, enhancing the interactivity and usability of their PDF documents. This allows for the creation of more dynamic and user-friendly PDFs.
3. IronPDF C#
IronPDF stands out as a versatile and powerful PDF library tailored for .NET developers. It simplifies the complex process of PDF manipulation, allowing for the creation, editing, and conversion of PDF documents directly within C# applications. IronPDF is available in different programming languages like Java, Python, and C#. IronPDF is designed to cater to a wide range of PDF processing needs, making it a go-to solution for developers seeking efficiency and reliability.
3.1 Key Features
- Seamless .NET Integration: IronPDF ensures easy integration with .NET projects, supporting both .NET Framework and .NET Core, including ASP.NET projects. This compatibility facilitates the incorporation of PDF functionalities into applications without the need for complex setups.
- HTML to PDF Conversion: One of the standout features of IronPDF is its ability to convert HTML to PDF. This feature enables developers to transform web pages or HTML strings into high-quality PDF documents, ideal for generating reports, receipts, and other documentation from HTML templates.
- Advanced PDF Editing: With IronPDF, developers have the power to edit PDF documents extensively. This includes adding text, images, and vector graphics, as well as modifying existing content within PDF files. IronPDF provides a comprehensive suite of editing tools to customize PDFs according to specific requirements.
- PDF Form Handling: IronPDF offers robust support for working with PDF forms. It allows for the creation and editing of form fields, as well as filling out forms programmatically. This is particularly useful for automating document workflows and data entry processes.
- Content Extraction: The library excels in extracting text, images, and even metadata from PDF documents. This functionality supports a range of applications, from content analysis to data migration projects, enabling developers to retrieve and utilize PDF content effectively.
- Document Security: IronPDF provides comprehensive security features, including support for password protection, encryption, and the management of PDF document permissions. This ensures that sensitive information remains secure and that document access is controlled.
- Performance and Scalability: Designed with performance in mind, IronPDF is optimized for speed and scalability, making it suitable for processing large volumes of PDF documents or handling high-demand applications without compromising on performance.
- Comprehensive Documentation and Support: IronPDF is backed by extensive documentation and a responsive support team. This ensures that developers have access to the resources and assistance they need to effectively implement and troubleshoot PDF functionalities within their projects.
- Compatibility with Various PDF Standards: IronPDF C# supports a wide range of PDF standards, ensuring that documents are compatible with different viewers and meet industry specifications. This includes support for PDF/A for archival purposes, PDF/UA for accessibility, and more.
4. Create a C# Console Application
Creating a console application in Visual Studio is a straightforward process that lays the foundation for any .NET development project, including those involving PDF manipulations with libraries like IronPDF or Apryse C#. Here's how to get started:
4.1 Launch Visual Studio
Open Visual Studio on your computer. If you haven’t installed Visual Studio yet, download and install it from the official Microsoft website, choosing a version that suits your needs.
4.2 Create a New Project
Once Visual Studio is open, select the "Create a new project" option from the initial dashboard.
4.3 Choose Project Type
In the "Create a new project" window, you’ll see a variety of project templates. Type "Console" in the search box or find the "Console Application" template from the list. Make sure to select the template specific to C#, not another language.
4.4 Configure Your Project
After selecting the "Console Application" template, click the "Next" button. You'll be prompted to configure your new project:
- Project Name: Enter a name for your project.
- Location: Choose where you want to save your project on your computer.
- Solution Name: By default, this matches your project name, but you can change it if you like.
- Framework: Select the .NET version you wish to use. For most purposes, the latest version is recommended unless you have specific requirements.
4.5 Create the Project
After configuring your project settings, click the "Create" button. Visual Studio will set up a new console application project with a default Program.cs file.
4.6 Explore the Project Structure
Take a moment to explore the generated project structure in the Solution Explorer pane. You’ll primarily work with the Program.cs file for a console application, which is where you’ll write your C# code.
5. Install IronPDF Library
Integrating the IronPDF library into your .NET project allows you to leverage its comprehensive PDF manipulation capabilities. There are several methods to install IronPDF, ensuring flexibility based on your preferred workflow or development environment setup.
5.1 Using the NuGet Package Manager
The NuGet Package Manager in Visual Studio provides a user-friendly interface for managing libraries and dependencies.
- Open your project in Visual Studio.
- Navigate to the Solution Explorer, right-click on your project, and select "Manage NuGet Packages."
- Click on the "Browse" tab and search for "IronPdf."
- Find IronPDF in the search results, select it, and click "Install." Visual Studio will handle the rest, adding IronPDF to your project.
5.2 Using the Visual Studio Command Line
For those who prefer using the command line, the Package Manager Console in Visual Studio offers a direct way to install packages.
- Open Visual Studio and go to your project.
- Navigate to Tools > NuGet Package Manager > Package Manager Console.
- In the console, type the following command and press Enter:
Install-Package IronPdf
This command will download and install the latest version of IronPDF into your project.
5.3 Direct Download from the NuGet Webpage
If you prefer to manually download the package before integrating it into your project, you can do so from the NuGet website.
- Visit the NuGet website and search for "IronPdf."
- On the IronPdf package page, find the "Download Package" link and click it to download the .nupkg file.
- Once downloaded, you can add the package to your project manually. In Visual Studio, navigate to the Solution Explorer, right-click on your project, and choose "Add > Reference." Navigate to the location of the downloaded .nupkg file, select it, and add it to your project.
Each of these methods will successfully integrate IronPDF into your .NET project, allowing you to start utilizing its powerful PDF processing features.
6. Install Apryse C#
To integrate Apryse C# into your C# project, you have a few options depending on whether you're working with .NET Framework or .NET Core, as well as your development environment preferences. Below are generalized steps based on information from Apryse documentation and setup guides:
6.1 For .NET Framework
- Download the Apryse SDK for Windows: You'll need to visit the Apryse SDK for Windows page to download the SDK suitable for .NET Framework applications.
- Extract the SDK: After downloading, extract the SDK to a known location on your system.
- Obtain an Apryse Trial Key: Register on the Apryse platform to get a trial key, which you'll use to activate the SDK's trial features.
- Set Up Your Project: In Visual Studio, create a new .NET Framework console application. Then, add the Lib folder from the extracted SDK to your project directory.
- Add References: Right-click on References in your project, choose "Add Reference," and navigate to the Lib folder where you've copied PDFNetLoader.dll and the appropriate PDFNet.dll for your architecture (x86 or x64). Make sure to set PDFNet.dll's "Copy Local" property to false.
- Configure App.config: Ensure that your App.config file has the loadFromRemoteSources setting enabled to true.
There are sample folders in the SDK. You can open and run these sample solutions directly.
7. IronPDF Advanced Features
7.1 HTML to PDF Conversion
IronPDF excels in converting HTML to PDF documents. This feature is crucial for web applications needing to generate reports, invoices, or snapshots of web pages as PDF files. The library accurately renders HTML, CSS, and JavaScript, capturing the layout and styles of web content in the generated PDF.
7.1.1 HTML String To PDF
Converting an HTML string directly to a PDF allows for dynamic PDF creation from HTML content generated within your application or stored in a variable. This is particularly useful for generating customized reports, receipts, or documents based on user input or application data.
using IronPdf;
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Define a simple HTML string to convert to PDF
string htmlContent = @"
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>My PDF</title>
<style>
body {
font-family: Arial, sans-serif;
}
h1 {
color: #333;
text-align: center;
}
p {
color: #666;
text-align: justify;
}
</style>
</head>
<body>
<h1>Welcome to My PDF</h1>
<p>This is a sample paragraph demonstrating how to create a PDF from HTML using IronPdf in C#.</p>
<p>You can add more content here as needed.</p>
</body>
</html>";
// Render the HTML string as a PDF
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
// Save the resulting PDF to a file
pdf.SaveAs("output.pdf");
using IronPdf;
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Define a simple HTML string to convert to PDF
string htmlContent = @"
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>My PDF</title>
<style>
body {
font-family: Arial, sans-serif;
}
h1 {
color: #333;
text-align: center;
}
p {
color: #666;
text-align: justify;
}
</style>
</head>
<body>
<h1>Welcome to My PDF</h1>
<p>This is a sample paragraph demonstrating how to create a PDF from HTML using IronPdf in C#.</p>
<p>You can add more content here as needed.</p>
</body>
</html>";
// Render the HTML string as a PDF
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
// Save the resulting PDF to a file
pdf.SaveAs("output.pdf");
Imports IronPdf
' Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here"
' Instantiate a PDF renderer
Dim renderer = New ChromePdfRenderer()
' Define a simple HTML string to convert to PDF
Dim htmlContent As String = "
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>My PDF</title>
<style>
body {
font-family: Arial, sans-serif;
}
h1 {
color: #333;
text-align: center;
}
p {
color: #666;
text-align: justify;
}
</style>
</head>
<body>
<h1>Welcome to My PDF</h1>
<p>This is a sample paragraph demonstrating how to create a PDF from HTML using IronPdf in C#.</p>
<p>You can add more content here as needed.</p>
</body>
</html>"
' Render the HTML string as a PDF
Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
' Save the resulting PDF to a file
pdf.SaveAs("output.pdf")
7.1.2 HTML File To PDF
When you have an HTML file stored on disk, IronPDF can convert this file into a PDF document. This method is ideal for converting existing HTML documents, templates, or reports that are saved as files in your project or on your server.
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Render the HTML file as a PDF
var pdf = renderer.RenderHtmlFileAsPdf("invoice.html");
// Save the resulting PDF to a file
pdf.SaveAs("file.pdf");
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Render the HTML file as a PDF
var pdf = renderer.RenderHtmlFileAsPdf("invoice.html");
// Save the resulting PDF to a file
pdf.SaveAs("file.pdf");
Imports IronPdf
' Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here"
' Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate a PDF renderer
Dim renderer = New ChromePdfRenderer()
' Render the HTML file as a PDF
Dim pdf = renderer.RenderHtmlFileAsPdf("invoice.html")
' Save the resulting PDF to a file
pdf.SaveAs("file.pdf")
7.1.3 URL To PDF
IronPDF can convert a live webpage into a PDF document by providing the URL. This feature is extremely useful for capturing the current state of a webpage, including complex layouts, CSS, and JavaScript-generated content.
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Render the URL as a PDF
var pdf = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework");
// Save the resulting PDF to a file
pdf.SaveAs("url.pdf");
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Render the URL as a PDF
var pdf = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework");
// Save the resulting PDF to a file
pdf.SaveAs("url.pdf");
Imports IronPdf
' Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here"
' Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate a PDF renderer
Dim renderer = New ChromePdfRenderer()
' Render the URL as a PDF
Dim pdf = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/download/dotnet-framework")
' Save the resulting PDF to a file
pdf.SaveAs("url.pdf")
7.2 PDF Merging and Splitting
With IronPDF, combining multiple PDF documents into a single file or dividing a PDF into several smaller documents is straightforward. This functionality is essential for document management systems where organizing and structuring PDF content is necessary.
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Define HTML content for two PDFs to merge
var htmlA = @"
<h1>PDF A</h1>
<p>This is the content of PDF A.</p>
<p>This is the first page of PDF A.</p>
<div style='page-break-after: always;'></div>
<p>This is the second page of PDF A.</p>";
var htmlB = @"
<h1>PDF B</h1>
<p>This is the content of PDF B.</p>
<p>This is the first page of PDF B.</p>
<div style='page-break-after: always;'></div>
<p>This is the second page of PDF B.</p>";
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Render the HTML content as separate PDF documents
var pdfDocA = renderer.RenderHtmlAsPdf(htmlA);
var pdfDocB = renderer.RenderHtmlAsPdf(htmlB);
// Merge the two PDFs into one
var mergedPdf = PdfDocument.Merge(pdfDocA, pdfDocB);
// Save the merged PDF to a file
mergedPdf.SaveAs("Merged.pdf");
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Define HTML content for two PDFs to merge
var htmlA = @"
<h1>PDF A</h1>
<p>This is the content of PDF A.</p>
<p>This is the first page of PDF A.</p>
<div style='page-break-after: always;'></div>
<p>This is the second page of PDF A.</p>";
var htmlB = @"
<h1>PDF B</h1>
<p>This is the content of PDF B.</p>
<p>This is the first page of PDF B.</p>
<div style='page-break-after: always;'></div>
<p>This is the second page of PDF B.</p>";
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Render the HTML content as separate PDF documents
var pdfDocA = renderer.RenderHtmlAsPdf(htmlA);
var pdfDocB = renderer.RenderHtmlAsPdf(htmlB);
// Merge the two PDFs into one
var mergedPdf = PdfDocument.Merge(pdfDocA, pdfDocB);
// Save the merged PDF to a file
mergedPdf.SaveAs("Merged.pdf");
Imports IronPdf
' Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here"
' Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Define HTML content for two PDFs to merge
Dim htmlA = "
<h1>PDF A</h1>
<p>This is the content of PDF A.</p>
<p>This is the first page of PDF A.</p>
<div style='page-break-after: always;'></div>
<p>This is the second page of PDF A.</p>"
Dim htmlB = "
<h1>PDF B</h1>
<p>This is the content of PDF B.</p>
<p>This is the first page of PDF B.</p>
<div style='page-break-after: always;'></div>
<p>This is the second page of PDF B.</p>"
' Instantiate a PDF renderer
Dim renderer = New ChromePdfRenderer()
' Render the HTML content as separate PDF documents
Dim pdfDocA = renderer.RenderHtmlAsPdf(htmlA)
Dim pdfDocB = renderer.RenderHtmlAsPdf(htmlB)
' Merge the two PDFs into one
Dim mergedPdf = PdfDocument.Merge(pdfDocA, pdfDocB)
' Save the merged PDF to a file
mergedPdf.SaveAs("Merged.pdf")
7.3 Adding Watermarks
IronPDF allows you to add watermarks to PDF pages, which is useful for branding or marking documents as confidential. This feature supports both text and image watermarks, providing flexibility in how watermarks are applied and displayed.
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Render a URL as a PDF
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
// Apply a watermark to the PDF
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
// Save the watermarked PDF to a file
pdf.SaveAs("Watermarked.pdf");
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
// Render a URL as a PDF
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
// Apply a watermark to the PDF
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
// Save the watermarked PDF to a file
pdf.SaveAs("Watermarked.pdf");
Imports IronPdf
' Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here"
' Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate a PDF renderer
Dim renderer = New ChromePdfRenderer()
' Render a URL as a PDF
Dim pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
' Apply a watermark to the PDF
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
' Save the watermarked PDF to a file
pdf.SaveAs("Watermarked.pdf")
7.4 PDF Forms
IronPDF supports working with interactive PDF forms. It enables the creation, filling, and submission of PDF forms programmatically. This is particularly useful for applications that need to automate form processing or integrate form data collection into their workflows.
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Define HTML content with form elements
const string formHtml = @"
<html>
<body>
<h2>Employee Information Form</h2>
<form>
First name: <br>
Last name: <br>
<br>
<p>Please select your department:</p>
<select name='department'>
<option value='HR'>HR</option>
<option value='Finance'>Finance</option>
<option value='IT'>IT</option>
<option value='Marketing'>Marketing</option>
</select>
<br>
<br>
<p>Please select your employment status:</p>
<label for='fulltime'>Full-time</label> <br>
<label for='parttime'>Part-time</label> <br>
<br>
<p>Please select your skills:</p>
<label for='skill1'> Programming</label><br>
<label for='skill2'> Design</label><br>
<label for='skill3'> Marketing</label><br>
</form>
</body>
</html>";
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
// Render the HTML form content as a PDF
renderer.RenderHtmlAsPdf(formHtml).SaveAs("EmployeeInfoForm.pdf");
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Define HTML content with form elements
const string formHtml = @"
<html>
<body>
<h2>Employee Information Form</h2>
<form>
First name: <br>
Last name: <br>
<br>
<p>Please select your department:</p>
<select name='department'>
<option value='HR'>HR</option>
<option value='Finance'>Finance</option>
<option value='IT'>IT</option>
<option value='Marketing'>Marketing</option>
</select>
<br>
<br>
<p>Please select your employment status:</p>
<label for='fulltime'>Full-time</label> <br>
<label for='parttime'>Part-time</label> <br>
<br>
<p>Please select your skills:</p>
<label for='skill1'> Programming</label><br>
<label for='skill2'> Design</label><br>
<label for='skill3'> Marketing</label><br>
</form>
</body>
</html>";
// Instantiate a PDF renderer
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
// Render the HTML form content as a PDF
renderer.RenderHtmlAsPdf(formHtml).SaveAs("EmployeeInfoForm.pdf");
Imports IronPdf
' Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here"
' Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Define HTML content with form elements
Const formHtml As String = "
<html>
<body>
<h2>Employee Information Form</h2>
<form>
First name: <br>
Last name: <br>
<br>
<p>Please select your department:</p>
<select name='department'>
<option value='HR'>HR</option>
<option value='Finance'>Finance</option>
<option value='IT'>IT</option>
<option value='Marketing'>Marketing</option>
</select>
<br>
<br>
<p>Please select your employment status:</p>
<label for='fulltime'>Full-time</label> <br>
<label for='parttime'>Part-time</label> <br>
<br>
<p>Please select your skills:</p>
<label for='skill1'> Programming</label><br>
<label for='skill2'> Design</label><br>
<label for='skill3'> Marketing</label><br>
</form>
</body>
</html>"
' Instantiate a PDF renderer
Dim renderer = New ChromePdfRenderer()
renderer.RenderingOptions.CreatePdfFormsFromHtml = True
' Render the HTML form content as a PDF
renderer.RenderHtmlAsPdf(formHtml).SaveAs("EmployeeInfoForm.pdf")
7.5 Security and Encryption
IronPDF provides features to secure PDF documents, including the ability to encrypt PDF files, set permissions, and add digital signatures. This ensures that sensitive information in PDF documents is protected and that document integrity is maintained.
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Load an existing PDF file
var pdf = PdfDocument.FromFile("invoice.pdf");
// Set document security settings
pdf.SecuritySettings.OwnerPassword = "top-secret"; // Password to edit the PDF
pdf.SecuritySettings.UserPassword = "sharable"; // Password to open the PDF
// Save the secured PDF to a file
pdf.SaveAs("secured.pdf");
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Load an existing PDF file
var pdf = PdfDocument.FromFile("invoice.pdf");
// Set document security settings
pdf.SecuritySettings.OwnerPassword = "top-secret"; // Password to edit the PDF
pdf.SecuritySettings.UserPassword = "sharable"; // Password to open the PDF
// Save the secured PDF to a file
pdf.SaveAs("secured.pdf");
Imports IronPdf
' Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here"
' Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Load an existing PDF file
Dim pdf = PdfDocument.FromFile("invoice.pdf")
' Set document security settings
pdf.SecuritySettings.OwnerPassword = "top-secret" ' Password to edit the PDF
pdf.SecuritySettings.UserPassword = "sharable" ' Password to open the PDF
' Save the secured PDF to a file
pdf.SaveAs("secured.pdf")
7.6 Advanced PDF Editing
IronPDF goes beyond basic PDF editing by offering advanced editing capabilities. This includes adding headers and footers, customizing page layout and design, and embedding images and fonts. These features allow for dynamic PDF generation and customization according to specific application requirements.
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate a PDF renderer
var renderer = new IronPdf.ChromePdfRenderer();
// Define multi-page HTML content with page breaks
var multiPageHtml = @"
<p> This is 1st Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 2nd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 3rd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 4th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 5th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 6th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 7th Page</p>";
// Render the HTML content as a PDF
var pdfDoc = renderer.RenderHtmlAsPdf(multiPageHtml);
// Create a header for the first page only
var firstPageHeader = new HtmlHeaderFooter();
firstPageHeader.HtmlFragment = "This is the First Page Header";
pdfDoc.AddHtmlHeaders(firstPageHeader, 1);
// Save the resulting PDF with headers to a file
pdfDoc.SaveAs("PagesWithHeaders.pdf");
using IronPdf;
// Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here";
// Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate a PDF renderer
var renderer = new IronPdf.ChromePdfRenderer();
// Define multi-page HTML content with page breaks
var multiPageHtml = @"
<p> This is 1st Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 2nd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 3rd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 4th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 5th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 6th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 7th Page</p>";
// Render the HTML content as a PDF
var pdfDoc = renderer.RenderHtmlAsPdf(multiPageHtml);
// Create a header for the first page only
var firstPageHeader = new HtmlHeaderFooter();
firstPageHeader.HtmlFragment = "This is the First Page Header";
pdfDoc.AddHtmlHeaders(firstPageHeader, 1);
// Save the resulting PDF with headers to a file
pdfDoc.SaveAs("PagesWithHeaders.pdf");
Imports IronPdf
' Set your IronPDF license key
IronPdf.License.LicenseKey = "License-Key goes here"
' Secure the server environment to disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate a PDF renderer
Dim renderer = New IronPdf.ChromePdfRenderer()
' Define multi-page HTML content with page breaks
Dim multiPageHtml = "
<p> This is 1st Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 2nd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 3rd Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 4th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 5th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 6th Page</p>
<div style = 'page-break-after: always;' ></div>
<p> This is 7th Page</p>"
' Render the HTML content as a PDF
Dim pdfDoc = renderer.RenderHtmlAsPdf(multiPageHtml)
' Create a header for the first page only
Dim firstPageHeader = New HtmlHeaderFooter()
firstPageHeader.HtmlFragment = "This is the First Page Header"
pdfDoc.AddHtmlHeaders(firstPageHeader, 1)
' Save the resulting PDF with headers to a file
pdfDoc.SaveAs("PagesWithHeaders.pdf")
8. Apryse C# Advanced Features
8.1 PDF Annotation and Markup
Apryse C# enables developers to add annotations and markup to PDF documents programmatically. This includes text annotations, highlights, underlines, and shapes, which are essential for document review processes or adding supplementary information to PDFs.
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library with your license key
PDFNet.Initialize("License");
// Open an existing PDF document
using (PDFDoc doc = new PDFDoc("input.pdf"))
{
// Access the first page of the document
Page page = doc.GetPage(1);
// Create a text annotation on the document
Text txt = Text.Create(doc, new Rect(10, 20, 30, 40));
txt.SetIcon("UserIcon");
txt.SetContents("It's an annotation!");
page.AnnotPushBack(txt);
// Save the modified document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library with your license key
PDFNet.Initialize("License");
// Open an existing PDF document
using (PDFDoc doc = new PDFDoc("input.pdf"))
{
// Access the first page of the document
Page page = doc.GetPage(1);
// Create a text annotation on the document
Text txt = Text.Create(doc, new Rect(10, 20, 30, 40));
txt.SetIcon("UserIcon");
txt.SetContents("It's an annotation!");
page.AnnotPushBack(txt);
// Save the modified document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF
Friend Class Program
Shared Sub Main()
' Initialize the PDFNet library with your license key
PDFNet.Initialize("License")
' Open an existing PDF document
Using doc As New PDFDoc("input.pdf")
' Access the first page of the document
Dim page As Page = doc.GetPage(1)
' Create a text annotation on the document
Dim txt As Text = Text.Create(doc, New Rect(10, 20, 30, 40))
txt.SetIcon("UserIcon")
txt.SetContents("It's an annotation!")
page.AnnotPushBack(txt)
' Save the modified document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
End Using
End Sub
End Class
8.2 Document Conversion
With Apryse C#, developers can convert various document formats to PDF, including Office documents, images, and HTML. This feature is vital for applications that require uniform document formats for archiving, sharing, or displaying.
using pdftron;
using pdftron.PDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library
PDFNet.Initialize();
// Create a new PDF document
PDFDoc pdfdoc = new PDFDoc();
// Convert a Word document to PDF and add it to the PDF document
Convert.ToPdf(pdfdoc, "input.docx");
// Save the newly created PDF document
pdfdoc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
using pdftron;
using pdftron.PDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library
PDFNet.Initialize();
// Create a new PDF document
PDFDoc pdfdoc = new PDFDoc();
// Convert a Word document to PDF and add it to the PDF document
Convert.ToPdf(pdfdoc, "input.docx");
// Save the newly created PDF document
pdfdoc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
Imports pdftron
Imports pdftron.PDF
Friend Class Program
Shared Sub Main()
' Initialize the PDFNet library
PDFNet.Initialize()
' Create a new PDF document
Dim pdfdoc As New PDFDoc()
' Convert a Word document to PDF and add it to the PDF document
Convert.ToPdf(pdfdoc, "input.docx")
' Save the newly created PDF document
pdfdoc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
End Sub
End Class
8.3 Content Extraction and Analysis
Apryse C# excels in extracting text, images, and other content from PDF documents. This capability is crucial for content analysis, data extraction, and information retrieval applications, enabling the processing of PDF content for various purposes.
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library
PDFNet.Initialize();
// Open an existing PDF document
using (PDFDoc doc = new PDFDoc("input.pdf"))
{
// Iterate through each page of the document
PageIterator itr = doc.GetPageIterator();
for (; itr.HasNext(); itr.Next())
{
Page page = itr.Current();
// Extract text from the page
TextExtractor txt = new TextExtractor();
txt.Begin(page);
// Print the extracted text to the console
Console.WriteLine(txt.GetAsText());
}
}
}
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library
PDFNet.Initialize();
// Open an existing PDF document
using (PDFDoc doc = new PDFDoc("input.pdf"))
{
// Iterate through each page of the document
PageIterator itr = doc.GetPageIterator();
for (; itr.HasNext(); itr.Next())
{
Page page = itr.Current();
// Extract text from the page
TextExtractor txt = new TextExtractor();
txt.Begin(page);
// Print the extracted text to the console
Console.WriteLine(txt.GetAsText());
}
}
}
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF
Friend Class Program
Shared Sub Main()
' Initialize the PDFNet library
PDFNet.Initialize()
' Open an existing PDF document
Using doc As New PDFDoc("input.pdf")
' Iterate through each page of the document
Dim itr As PageIterator = doc.GetPageIterator()
Do While itr.HasNext()
Dim page As Page = itr.Current()
' Extract text from the page
Dim txt As New TextExtractor()
txt.Begin(page)
' Print the extracted text to the console
Console.WriteLine(txt.GetAsText())
itr.Next()
Loop
End Using
End Sub
End Class
8.4 Security and Encryption
Apryse C# provides comprehensive tools for securing PDF documents. Developers can apply password protection, encrypt documents, and manage user permissions, ensuring that sensitive information is safeguarded.
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library
PDFNet.Initialize();
// Open an existing PDF document
using (PDFDoc doc = new PDFDoc("input.pdf"))
{
// Initialize the security handler
doc.InitSecurityHandler();
// Create a new security handler
SecurityHandler newHandler = new SecurityHandler();
// Set the user password for the document
newHandler.ChangeUserPassword("new_password");
// Grant permission to print the document
newHandler.SetPermission(SecurityHandler.Permission.e_print, true);
// Apply the security handler to the document
doc.SetSecurityHandler(newHandler);
// Save the secured document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
}
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library
PDFNet.Initialize();
// Open an existing PDF document
using (PDFDoc doc = new PDFDoc("input.pdf"))
{
// Initialize the security handler
doc.InitSecurityHandler();
// Create a new security handler
SecurityHandler newHandler = new SecurityHandler();
// Set the user password for the document
newHandler.ChangeUserPassword("new_password");
// Grant permission to print the document
newHandler.SetPermission(SecurityHandler.Permission.e_print, true);
// Apply the security handler to the document
doc.SetSecurityHandler(newHandler);
// Save the secured document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
}
Imports pdftron
Imports pdftron.SDF
Imports pdftron.PDF
Friend Class Program
Shared Sub Main()
' Initialize the PDFNet library
PDFNet.Initialize()
' Open an existing PDF document
Using doc As New PDFDoc("input.pdf")
' Initialize the security handler
doc.InitSecurityHandler()
' Create a new security handler
Dim newHandler As New SecurityHandler()
' Set the user password for the document
newHandler.ChangeUserPassword("new_password")
' Grant permission to print the document
newHandler.SetPermission(SecurityHandler.Permission.e_print, True)
' Apply the security handler to the document
doc.SetSecurityHandler(newHandler)
' Save the secured document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
End Using
End Sub
End Class
8.5 Redaction
Apryse C# also supports redacting sensitive information from PDF documents, an essential feature for compliance and privacy concerns. This allows developers to permanently remove or obscure text and images within a PDF.
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library
PDFNet.Initialize();
// Open an existing PDF document
using (PDFDoc doc = new PDFDoc("input.pdf"))
{
// Define redaction areas on specific pages
Redactor.Redaction[] redactions = {
new Redactor.Redaction(1, new Rect(100, 100, 200, 200), false, "redacted"),
};
// Apply redactions to the document
Redactor.Redact(doc, redactions);
// Save the redacted document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;
class Program
{
static void Main()
{
// Initialize the PDFNet library
PDFNet.Initialize();
// Open an existing PDF document
using (PDFDoc doc = new PDFDoc("input.pdf"))
{
// Define redaction areas on specific pages
Redactor.Redaction[] redactions = {
new Redactor.Redaction(1, new Rect(100, 100, 200, 200), false, "redacted"),
};
// Apply redactions to the document
Redactor.Redact(doc, redactions);
// Save the redacted document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF
Friend Class Program
Shared Sub Main()
' Initialize the PDFNet library
PDFNet.Initialize()
' Open an existing PDF document
Using doc As New PDFDoc("input.pdf")
' Define redaction areas on specific pages
Dim redactions() As Redactor.Redaction = { New Redactor.Redaction(1, New Rect(100, 100, 200, 200), False, "redacted")}
' Apply redactions to the document
Redactor.Redact(doc, redactions)
' Save the redacted document
doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
End Using
End Sub
End Class
9. Documentation and Support
9.1 IronPDF Documentation and Support
Documentation: IronPDF offers comprehensive documentation that covers a wide range of topics, from getting started guides to advanced features like HTML to PDF conversion, PDF editing, merging, splitting, and security. The documentation is designed to be easy to follow, with plenty of code examples and explanations that guide developers through the process of implementing various PDF-related functionalities in their .NET applications.
Support: For developers who need assistance, IronPDF provides support through various channels. This includes email support, ticket support, and live engineering support chat where you can get in touch with their technical support team for help with specific issues. You can also provide feedback using a support system.
9.2 Apryse C# Documentation and Support
Documentation: Apryse C# (formerly known as PDFTron for .NET) boasts detailed documentation that includes a comprehensive API reference, developer guides, and sample code for a broad spectrum of PDF manipulation tasks.
Support: Apryse provides a support system for developers, featuring direct email support with their technical team for troubleshooting and assistance with implementation questions. You can also ask questions on Stack Overflow.
10. License Information
10.1 IronPDF License
IronPDF offers several licensing options tailored to different project needs, including Lite, Plus, and Professional licenses, with pricing starting at $749 for a Lite license. These licenses vary based on the number of developers, locations, and projects they cover. Additionally, IronPDF provides options for royalty-free redistribution and extended support and updates, with specific costs for these add-ons.
IronPDF offers a range of perpetual license options for developers:
- Lite Edition: Costs $749, suitable for 1 developer, 1 location, and 1 project, with email support included.
- Plus Edition: Priced at $1,499, it covers up to 3 developers, 3 locations, and 3 projects, with 24-hour email and chat support, and phone support.
- Professional Edition: At $2,999, this edition is for up to 10 developers, 10 locations, and 10 projects, providing comprehensive support including email, chat, phone, and screen-sharing support.
They also offer a monthly subscription at $500 per month, including 10,000 API calls, with additional calls at $0.02 each. For unlimited use, IronPDF provides an enterprise solution with a request for a quote. This solution includes an unlimited perpetual license and unlimited API calls, among other features.
10.2 Apryse C# License
Apryse C# provides a customizable pricing model that adjusts based on specific project requirements, including features, document volume, and deployment scenarios. You have to contact their sales team to get Apryse pricing information.
11. Conclusion
In conclusion, IronPDF and Apryse C# each bring powerful capabilities to the table for .NET developers working with PDFs. IronPDF, however, provides an edge with its extensive PDF manipulation features. It shines with its ability to handle comprehensive tasks such as extensive editing, merging PDFs using IronPDF that adds to its appeal. With the Iron Suite package, developers can access a suite of tools at a cost-effective price point, equipping them with a robust set of utilities for various development needs.
IronPDF stands out for its overall versatility and value proposition in most PDF processing scenarios. The final decision would ideally be based on the project requirements and the specific features needed by the developers.
Frequently Asked Questions
What are some libraries used for PDF manipulation within .NET applications?
IronPDF and Apryse C# are libraries used for PDF manipulation within .NET applications. They allow developers to create, edit, convert, and manage PDF documents programmatically.
What are the key features of Apryse C#?
Apryse C# offers easy integration with .NET projects, document creation and editing, HTML to PDF conversion, extensive support for form fields, text and content extraction, security and encryption features, and advanced PDF functionalities like annotations and bookmarks.
How do PDF libraries integrate with .NET projects?
IronPDF integrates seamlessly with .NET Framework and .NET Core applications. It supports ASP.NET projects and provides a straightforward setup process through NuGet package manager or manual integration.
What are some advanced features of PDF libraries?
IronPDF supports HTML to PDF conversion, PDF merging and splitting, adding watermarks, PDF forms handling, document security, and advanced PDF editing including headers, footers, and layout customization.
What security features do PDF libraries offer?
Both libraries offer comprehensive security features, including the ability to encrypt PDF documents, set permissions, and manage digital signatures to ensure document protection and compliance.
How can I install a PDF library in a .NET project?
IronPDF can be installed in a .NET project using the NuGet package manager in Visual Studio, or via the command line using the Package Manager Console. It can also be manually downloaded from the NuGet website.
What are some licensing options for PDF libraries?
IronPDF offers Lite, Plus, and Professional licenses, each with different levels of support and developer coverage. They also offer a monthly subscription and an enterprise solution for unlimited use.
What support do PDF libraries provide?
IronPDF provides extensive documentation, email support, ticket support, and live engineering support chat, ensuring developers have access to the resources they need for implementation and troubleshooting.
What is the process for creating a C# console application for document manipulation?
To create a C# console application, open Visual Studio, create a new project, select 'Console Application' for C#, configure the project settings, and set up the necessary libraries for PDF manipulation like IronPDF or Apryse C#.
How does Apryse C# handle document conversion?
Apryse C# can convert a variety of document formats including Office documents, images, and HTML to PDF, which is crucial for maintaining uniform document formats across applications.