Przejdź do treści stopki
PORóWNANIA PRODUKTóW
Porównanie IronPDF z iTextSharp w języku C#

iTextSharp C# HTML do PDF Alternatywa dla .NET Core

Full Comparison

Looking for a detailed feature-by-feature breakdown? See how IronPDF stacks up against Itext on pricing, HTML support, and licensing.

View Full Comparison

IronPDF vs iTextSharp / iText7

Comprehensive .NET PDF library comparison — feature-by-feature with evidence-based context

iTextSharp / iText7
13
out of 20 features
10 Yes 7 Complex 3 No
IronPDF ✦
20
out of 20 features
20 Yes 0 Complex 0 No
Funkcja iTextSharp / iText7 IronPDF ✦
PDF Creation & Conversion
HTML/CSS to PDF $ Paid Add-on
HTML→PDF via pdfHTML add-on (separate package; AGPL/commercial model).
✓ Yes
Chromium-based engine with pixel-perfect CSS3, Flexbox, and Grid rendering built-in.
Wykonanie JavaScript ? Unknown
pdfHTML describes HTML/CSS→PDF conversion, but JS execution support is not stated in docs.
✓ Yes
Fully executes JS during rendering — dynamic charts, SPAs, and interactive content.
Programmatic Generation ✓ Yes
Positioned as a programmable PDF SDK for .NET — create, edit, and enhance.
✓ Yes
Generate from HTML templates, strings, ASPX views, or images. Chromium handles layout.
URL do pliku PDF $ Paid Add-on
Possible via pdfHTML add-on with URL fetching, but not a core feature.
✓ Yes
RenderUrlAsPdf() captures any live URL with full CSS/JS rendering.
DOCX do PDF ✕ No
No native Word conversion — iText is a PDF-native SDK.
✓ Yes
DocxToPdfRenderer converts Word docs preserving structure and formatting.
Reading & Extraction
Wyodrębnianie tekstu ✓ Yes
PdfTextExtractor.GetTextFromPage() with multiple extraction strategies.
✓ Yes
Extracts text with layout awareness. Combines with IronOCR for scanned docs.
Render Pages to Images ? Unknown
OCR workflows mention rendering, but a primary-source "PDF→image renderer" module isn't evidenced in cited iText docs.
✓ Built-in
Native rasterization to PNG, JPEG, BMP with configurable DPI.
Built-in OCR $ Paid Add-on
pdfOCR add-on available; install notes mention platform-specific/native dependencies (e.g., Linux/macOS runtime requirements).
✓ Via IronOCR
Native integration with IronOCR for 127+ language OCR on scanned PDFs.
Editing & Manipulation
Merging & Splitting ✓ Yes
PdfMerger class in .NET API; official examples discuss merging via PdfMerger.
✓ Yes
One-line merge, split, append, prepend, and page reordering with intuitive API.
Headers, Footers & Page Numbers ✓ Yes
PDF Association listing confirms ability to add "page numbers" and similar features to existing PDFs.
✓ Yes
HTML-based headers/footers with auto page numbers, dates, and custom content.
Znaki wodne ✓ Yes
PDF Association listing explicitly includes "watermarks … to existing PDF documents."
✓ Yes
ApplyWatermark() accepts HTML/CSS — full control over opacity, rotation, position.
Stamp Text & Images ✓ Yes
Programmatic content placement available via iText's canvas and layout APIs.
✓ Yes
TextStamper & ImageStamper with Google Fonts, positioning, per-page control.
Redact Content ✓ Yes
iText provides redaction annotation support via the cleanup module.
✓ Yes
RedactTextOnAllPages() removes sensitive text permanently in a single line.
Security & Compliance
Encryption & Passwords ✓ Yes
Full encryption and permission controls via iText's security API.
✓ Yes
AES encryption, owner/user passwords, granular permissions (print, copy, annotate).
Podpisy cyfrowe ✓ Yes
Dedicated digital signing documentation and signing API (PdfSigner).
✓ Yes
PdfSignature with X509/PFX certificate support.
PDF/A & PDF/UA Compliance ✓ Yes
Dokumentacja covers creating PDF/A and explains constraints (conversion from existing isn't automatic).
✓ Yes
Native PDF/A archival and PDF/UA accessibility compliance for enterprise use.
Platform & Deployment
Obsługa wielu platform ✓ Yes
.NET Standard 2.0 / .NET Framework 4.6.1 — runs on .NET 6+ across OSes.
✓ Yes
Windows, Linux, macOS, x64, x86, ARM. .NET 6–10, Core, Standard 2.0+, Framework 4.6.2+.
Server / Docker / Cloud ~ Complex
Core install requires multiple packages (iText + Bouncy Castle adapter); add-ons (pdfHTML/pdfOCR) add further dependency/compliance steps.
✓ Yes
Docker, Azure, AWS, IIS. Official Docker images and deployment guides.
Ease of Setup ~ Complex
Core install requires multiple packages (Bouncy Castle adapter); HTML/OCR require additional add-ons and sometimes native deps.
✓ Simple
Single Install-Package IronPdf NuGet command. Ready in minutes.
Licensing & Support
Licensing Model ~ Complex
Dual-license: AGPLv3 (source-disclosure obligations for network use) or commercial. AGPL can be restrictive for proprietary apps.
✓ Commercial
Perpetual licenses. 30-day fully functional free trial, no watermarks.
Commercial Support & SLA ✓ Yes
iText site includes commercial licensing + support agreements as part of its licensing model.
✓ 24/5 Support
Dedicated engineering support with guaranteed SLA — email, live chat, phone.
Dokumentacja ✓ Yes
Installation guides, knowledge base articles, and API references available (core + add-ons).
✓ Extensive
Full API reference, 100+ how-tos, tutorials, code examples, troubleshooting, videos.

Data sourced from official iText documentation, PDF Association listing, and NuGet package references.
iText7 is powerful but carries AGPL licensing complexity and multi-package setup overhead.
IronPDF delivers full coverage with simpler setup — try free for 30 days.

For developers working with PDFs, having a reliable library for PDF generation and manipulation is essential. In the .NET ecosystem, there can be dozens of C# PDF libraries to choose from, so how are you to choose which one best fits your needs?

Selecting the appropriate library is crucial for efficient development when working with PDF functionalities in .NET applications. This article provides a detailed comparison between two prominent C# PDF libraries: IronPDF and iText 7 (formerly known as iTextSharp). We will explore their features, performance, licensing, and suitability for various project requirements to assist you in making an informed decision.

Why Choose a .NET PDF Library?

PDFs are widely used in reports, invoices, and legal documents, making PDF generation and manipulation essential for many applications. When selecting a library, key factors to consider include:

  • Ease of integration – How quickly can you implement PDF features?
  • Support for HTML-to-PDF – Does it allow easy conversion from web content?
  • Licensing and cost – Is it free, or does it require a commercial license?
  • Funkcja set – Does it support text extraction, signing, or editing?
  • Performance – How fast does it generate or process PDFs?

An Overview of IronPDF and iText7

Wprowadzenie do IronPDF

IronPDF is a commercial PDF library designed specifically for .NET developers. It simplifies PDF generation, manipulation, and conversion, making it one of the easiest libraries to use in C# applications.

IronPDF supports .NET Core, .NET Framework, and .NET Standard, ensuring compatibility across various .NET environments. Its high level of cross-platform compatibility makes it an ideal choice for teams working across different app environments, and it seamlessly integrates with IDEs such as Visual Studio. Beyond its .NET version, IronPDF is also available in Java, Python, and Node.js.

Key Funkcjas:

  • Built-in HTML-to-PDF support – Convert web pages, HTML, CSS, and JavaScript into PDFs without extra add-ons.
  • PDF Editing – Modify existing PDFs by adding text, images, headers, and footers.
  • PDF Security – Encrypt PDFs, set password protection, and manage permissions for viewing, printing, or editing.
  • Watermarking and Annotations – Easily apply text and image watermarks, stamps, or comments to documents.
  • Form Filling and Data Extraction – Populate interactive PDF forms programmatically and extract form data.

Best for: Developers looking for a straightforward, all-in-one solution without the hassle of additional add-ons or complex licensing.

Introduction to iText7

iText 7 is a powerful and flexible PDF library that provides extensive PDF manipulation capabilities, including document creation, encryption, and signing. However, its core library does not support HTML-to-PDF conversion natively.

Najważniejsze cechy

  • Low-Level PDF Customization – Provides detailed control over PDF structure, metadata, and rendering.
  • Accessibility & Compliance: Generates PDF/A, PDF/UA, and PDF/X for long-term archiving and accessibility compliance.
  • HTML-to-PDF Conversion: The paid pdfHTML add-on enables conversion of HTML content into PDFs.
  • Java & .NET Support: Primarily designed for Java, with C# support via iText 7 for .NET.
  • PDF Form Management: Create and edit AcroForms and XFA Forms for interactive PDF forms.

Best for: Developers who need a highly customizable PDF solution and are willing to purchase additional add-ons for extended features.

Funkcjas and Advantages

Before we get into the features and their accompanying code examples, let's first take a look at one of the biggest functional differences between IronPDF and iText 7, HTML-to-PDF conversion.

  • IronPDF natively supports HTML, CSS, and JavaScript rendering without requiring any additional components.
  • iText 7, on the other hand, requires the pdfHTML add-on, which is a paid feature under commercial licensing. This increases costs for developers needing web-to-PDF functionality.

HTML to PDF Comparison Flow Chart

Bottom Line: If you need HTML-to-PDF conversion, IronPDF is the more cost-effective solution as it includes this feature out of the box.

IronPDF Key Funkcjas (With Code Examples)

IronPDF boasts a rich set of features for working with PDF documents. These range from PDF creation, to PDF manipulation and security. To get a clearer idea of the extensive range of features this library has to offer, we will be taking a look at a select few key features.

Konwersja HTML do PDF

Convert HTML content into high-quality PDF documents with IronPDF's powerful rendering engine. IronPDF's renderer doesn't simply convert HTML content either; with it, you will be able to maintain all original CSS styling and JavaScript interactivity.

using IronPdf;

public class Program
{
    static void Main(string[] args)
    {
        // Create a new ChromePdfRenderer instance for rendering HTML to PDF
        ChromePdfRenderer renderer = new ChromePdfRenderer();

        // Render the specified HTML file as a PDF document
        PdfDocument pdf = renderer.RenderHtmlFileAsPdf("example.html");

        // Save the rendered PDF to the specified file path
        pdf.SaveAs("HtmlToPdf.pdf");
    }
}
using IronPdf;

public class Program
{
    static void Main(string[] args)
    {
        // Create a new ChromePdfRenderer instance for rendering HTML to PDF
        ChromePdfRenderer renderer = new ChromePdfRenderer();

        // Render the specified HTML file as a PDF document
        PdfDocument pdf = renderer.RenderHtmlFileAsPdf("example.html");

        // Save the rendered PDF to the specified file path
        pdf.SaveAs("HtmlToPdf.pdf");
    }
}
Imports IronPdf

Public Class Program
	Shared Sub Main(ByVal args() As String)
		' Create a new ChromePdfRenderer instance for rendering HTML to PDF
		Dim renderer As New ChromePdfRenderer()

		' Render the specified HTML file as a PDF document
		Dim pdf As PdfDocument = renderer.RenderHtmlFileAsPdf("example.html")

		' Save the rendered PDF to the specified file path
		pdf.SaveAs("HtmlToPdf.pdf")
	End Sub
End Class
$vbLabelText   $csharpLabel

Input HTML
Input HTML Content

Output PDF
HTML to PDF output using IronPDF

In this code example, we have first created a new ChromePdfRenderer instance, which gives us access to the powerful rendering engine IronPDF uses to render HTML to PDF. Then, we pass an HTML file to the RenderHtmlFileAsPdf() method, which in turn renders the HTML into a PDF, stored in the PdfDocument object. Finally, we will save the PDF to the specified file location.

URL do pliku PDF

For developers looking to convert URL content into PDFs, look no further than IronPDF. With this library, you will be able to create pixel-perfect PDF documents through the use of the ChromePdfRenderer rendering engine, which will maintain all original styling and layouts when it renders the URL do pliku PDF. For this example, we will be using this URL to demonstrate how IronPDF can handle more complex CSS styling.

using IronPdf;

public class Program
{
    static void Main(string[] args)
    {
        // Create a new ChromePdfRenderer instance
        ChromePdfRenderer renderer = new ChromePdfRenderer();

        // Render the specified URL as a PDF document
        PdfDocument pdf = renderer.RenderUrlAsPdf("https://www.apple.com");

        // Save the rendered PDF to the specified file path
        pdf.SaveAs("UrlToPdf.pdf");
    }
}
using IronPdf;

public class Program
{
    static void Main(string[] args)
    {
        // Create a new ChromePdfRenderer instance
        ChromePdfRenderer renderer = new ChromePdfRenderer();

        // Render the specified URL as a PDF document
        PdfDocument pdf = renderer.RenderUrlAsPdf("https://www.apple.com");

        // Save the rendered PDF to the specified file path
        pdf.SaveAs("UrlToPdf.pdf");
    }
}
Imports IronPdf

Public Class Program
	Shared Sub Main(ByVal args() As String)
		' Create a new ChromePdfRenderer instance
		Dim renderer As New ChromePdfRenderer()

		' Render the specified URL as a PDF document
		Dim pdf As PdfDocument = renderer.RenderUrlAsPdf("https://www.apple.com")

		' Save the rendered PDF to the specified file path
		pdf.SaveAs("UrlToPdf.pdf")
	End Sub
End Class
$vbLabelText   $csharpLabel

PDF Output:
URL do pliku PDF output using IronPDF

Much like in our HTML to PDF example, the first step to converting any URL do pliku PDF using IronPDF is to first create a new ChromePdfRenderer instance. Once the method has rendered the URL content into a PDF format, using RenderUrlAsPdf, it saves the resulting PDF to a new PdfDocument object, before we use the SaveAs method to save the PDF.

PDF Signatures

Ensure the authenticity of your PDF document by applying a digital signature to your PDF documents. There are different methods of which developers might consider applying digital signatures such as digitally signing the PDF with a secure certificate, adding an image of a handwritten signature to a PDF, or stamping an image of the certificate onto the PDF itself.

using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
using IronSoftware.Drawing;

public class Program
{
    static void Main(string[] args)
    {
        // Load the certificate used for signing the PDF
        X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "your-password", X509KeyStorageFlags.Exportable);

        // Create a PdfSignature instance and set the signature image
        var sig = new PdfSignature(cert);
        sig.SignatureImage = new PdfSignatureImage("IronPdf.png", 0, new Rectangle(150, 100, 350, 250));

        // Sign the existing PDF file and save the signed version
        sig.SignPdfFile("product_report.pdf");
    }
}
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
using IronSoftware.Drawing;

public class Program
{
    static void Main(string[] args)
    {
        // Load the certificate used for signing the PDF
        X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "your-password", X509KeyStorageFlags.Exportable);

        // Create a PdfSignature instance and set the signature image
        var sig = new PdfSignature(cert);
        sig.SignatureImage = new PdfSignatureImage("IronPdf.png", 0, new Rectangle(150, 100, 350, 250));

        // Sign the existing PDF file and save the signed version
        sig.SignPdfFile("product_report.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
Imports IronSoftware.Drawing

Public Class Program
	Shared Sub Main(ByVal args() As String)
		' Load the certificate used for signing the PDF
		Dim cert As New X509Certificate2("IronSoftware.pfx", "your-password", X509KeyStorageFlags.Exportable)

		' Create a PdfSignature instance and set the signature image
		Dim sig = New PdfSignature(cert)
		sig.SignatureImage = New PdfSignatureImage("IronPdf.png", 0, New Rectangle(150, 100, 350, 250))

		' Sign the existing PDF file and save the signed version
		sig.SignPdfFile("product_report.pdf")
	End Sub
End Class
$vbLabelText   $csharpLabel

Output PDF
Digital Signature output using IronPDF

For this example, we have loaded in our certificate object, created a visual representation of the signature, or in our case the IronPDF image, and created a new PdfSignature object, which handles the signing of the PDF document itself. Finally, we used the SignPdfFile to sign and save our PDF document.

If you want to explore more of the features IronPDF has to offer, be sure to check out its informative features page, or the How-to Guides which contain in-depth code examples for each feature.

iText7 Key Funkcjas (With Code Examples)

iText7 offers a wide range of features for customizing and enhancing your PDF documents. With extensive format support for various PDF standards and advanced PDF manipulation, there is a lot packed into this PDF library. However, as mentioned before, iText7 may require additional packages in order to carry out certain PDF-related tasks such as HTML to PDF.

Konwersja HTML do PDF

Although iText7 by itself cannot handle HTML to PDF conversion, we can utilize the pdfHTML, a paid add-on found under iText7's commercial licensing, to convert the HTML file we used in our IronPDF example into a PDF document.

using iText.Html2pdf;
using System.IO;

public class Program
{
    static void Main(string[] args)
    {
        // Open the HTML file stream
        using (FileStream htmlSource = File.Open("example.html", FileMode.Open))
        // Create the output PDF file stream
        using (FileStream pdf = File.Open("HtmlToPdfOutput.pdf", FileMode.Create))
        {
            // Initialize ConverterProperties for HTML to PDF conversion
            ConverterProperties converterProperties = new ConverterProperties();

            // Convert the HTML source to a PDF document
            HtmlConverter.ConvertToPdf(htmlSource, pdf, converterProperties);

            // Close the PDF file
            pdf.Close();
        }
    }
}
using iText.Html2pdf;
using System.IO;

public class Program
{
    static void Main(string[] args)
    {
        // Open the HTML file stream
        using (FileStream htmlSource = File.Open("example.html", FileMode.Open))
        // Create the output PDF file stream
        using (FileStream pdf = File.Open("HtmlToPdfOutput.pdf", FileMode.Create))
        {
            // Initialize ConverterProperties for HTML to PDF conversion
            ConverterProperties converterProperties = new ConverterProperties();

            // Convert the HTML source to a PDF document
            HtmlConverter.ConvertToPdf(htmlSource, pdf, converterProperties);

            // Close the PDF file
            pdf.Close();
        }
    }
}
Imports iText.Html2pdf
Imports System.IO

Public Class Program
	Shared Sub Main(ByVal args() As String)
		' Open the HTML file stream
		Using htmlSource As FileStream = File.Open("example.html", FileMode.Open)
		' Create the output PDF file stream
		Using pdf As FileStream = File.Open("HtmlToPdfOutput.pdf", FileMode.Create)
			' Initialize ConverterProperties for HTML to PDF conversion
			Dim converterProperties As New ConverterProperties()

			' Convert the HTML source to a PDF document
			HtmlConverter.ConvertToPdf(htmlSource, pdf, converterProperties)

			' Close the PDF file
			pdf.Close()
		End Using
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

Output PDF
iText7 HTML to PDF output

For this example, we loaded in the HTML file and specified the file location to save the rendered PDF to. Then, using the ConvertToPdf method, we can easily convert the HTML file to a PDF document.

URL do pliku PDF

Now, it's time to compare how iText7 measures up against IronPDF when it comes to converting URLs to PDF. For this, we will use the exact same URL as before to ensure a fair comparison.

using System;
using System.Net.Http;
using System.IO;
using iText.Html2pdf;

public class Program
{
    public static async System.Threading.Tasks.Task Main(string[] args)
    {
        string url = "https://www.apple.com";  // Replace with your target URL
        string outputPdfPath = "output.pdf";

        try
        {
            // Download HTML content from the URL
            using (HttpClient client = new HttpClient())
            {
                string htmlContent = await client.GetStringAsync(url);

                // Convert HTML to PDF
                using (FileStream pdfStream = new FileStream(outputPdfPath, FileMode.Create))
                {
                    ConverterProperties properties = new ConverterProperties();
                    HtmlConverter.ConvertToPdf(htmlContent, pdfStream, properties);
                }
            }

            Console.WriteLine("PDF created successfully: " + outputPdfPath);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
}
using System;
using System.Net.Http;
using System.IO;
using iText.Html2pdf;

public class Program
{
    public static async System.Threading.Tasks.Task Main(string[] args)
    {
        string url = "https://www.apple.com";  // Replace with your target URL
        string outputPdfPath = "output.pdf";

        try
        {
            // Download HTML content from the URL
            using (HttpClient client = new HttpClient())
            {
                string htmlContent = await client.GetStringAsync(url);

                // Convert HTML to PDF
                using (FileStream pdfStream = new FileStream(outputPdfPath, FileMode.Create))
                {
                    ConverterProperties properties = new ConverterProperties();
                    HtmlConverter.ConvertToPdf(htmlContent, pdfStream, properties);
                }
            }

            Console.WriteLine("PDF created successfully: " + outputPdfPath);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
}
Imports System
Imports System.Net.Http
Imports System.IO
Imports iText.Html2pdf

Public Class Program
	Public Shared Async Function Main(ByVal args() As String) As System.Threading.Tasks.Task
		Dim url As String = "https://www.apple.com" ' Replace with your target URL
		Dim outputPdfPath As String = "output.pdf"

		Try
			' Download HTML content from the URL
			Using client As New HttpClient()
				Dim htmlContent As String = Await client.GetStringAsync(url)

				' Convert HTML to PDF
				Using pdfStream As New FileStream(outputPdfPath, FileMode.Create)
					Dim properties As New ConverterProperties()
					HtmlConverter.ConvertToPdf(htmlContent, pdfStream, properties)
				End Using
			End Using

			Console.WriteLine("PDF created successfully: " & outputPdfPath)
		Catch ex As Exception
			Console.WriteLine("Error: " & ex.Message)
		End Try
	End Function
End Class
$vbLabelText   $csharpLabel

Output PDF
iText7 URL do pliku PDF output

As seen here, iText7's approach to URL do pliku PDF conversion is more manual and complex. First, we need to download the HTML content from the URL, before following similar steps as seen in the HTML to PDF example to render our URL content into a PDF document and save it. As you can see in the output image, iText7 wasn't able to maintain much of the original styling and layout, unlike IronPDF.

PDF Signatures

using System.Security.Cryptography.X509Certificates;
using iText.Kernel.Pdf;
using iText.Signatures;
using iText.Bouncycastle.Crypto;
using iText.Commons.Bouncycastle.Cert;
using iText.Commons.Bouncycastle.Crypto;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.Crypto;
using iText.Bouncycastle.X509;
using iText.Kernel.Crypto;
using System.IO;

public class Program
{
    static void Main(string[] args)
    {
        string inputPdf = "input.pdf";       // PDF to be signed
        string outputPdf = "signed_output.pdf";  // Signed PDF output
        string pfxFile = "IronSoftware.pfx";  // Path to your PFX certificate
        string password = "Passw0rd";   // Password for PFX file

        try
        {
            // Load your certificate
            Pkcs12Store ks = new Pkcs12StoreBuilder().Build();
            using (FileStream fs = new FileStream(pfxFile, FileMode.Open, FileAccess.Read))
            {
                ks.Load(fs, password.ToCharArray());
            }

            string alias = null;
            foreach (string al in ks.Aliases)
            {
                if (ks.IsKeyEntry(al))
                {
                    alias = al;
                    break;
                }
            }

            if (alias == null)
            {
                throw new Exception("Alias not found in the PFX file.");
            }

            ICipherParameters pk = ks.GetKey(alias).Key;
            X509CertificateEntry[] chain = ks.GetCertificateChain(alias);

            // Convert BouncyCastle certificates to iText certificates
            var itextCertChain = new IX509Certificate[chain.Length];
            for (int i = 0; i < chain.Length; i++)
            {
                itextCertChain[i] = new X509CertificateBC(chain[i].Certificate);
            }

            // Create output PDF with signed content
            using (PdfReader reader = new PdfReader(inputPdf))
            using (FileStream os = new FileStream(outputPdf, FileMode.Create, FileAccess.Write))
            {
                PdfSigner signer = new PdfSigner(reader, os, new StampingProperties().UseAppendMode());

                // Set up the external signature (private key + digest algorithm)
                IPrivateKey iTextPrivateKey = new PrivateKeyBC(pk);
                IExternalSignature pks = new PrivateKeySignature(iTextPrivateKey, DigestAlgorithms.SHA256);
                IExternalDigest digest = new BouncyCastleDigest();

                // Perform the signing (detached signature)
                signer.SignDetached(digest, pks, itextCertChain, null, null, null, 0, PdfSigner.CryptoStandard.CMS);
            }

            Console.WriteLine($"PDF digitally signed successfully: {outputPdf}");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error signing PDF: {ex.Message}");
        }
    }
}
using System.Security.Cryptography.X509Certificates;
using iText.Kernel.Pdf;
using iText.Signatures;
using iText.Bouncycastle.Crypto;
using iText.Commons.Bouncycastle.Cert;
using iText.Commons.Bouncycastle.Crypto;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.Crypto;
using iText.Bouncycastle.X509;
using iText.Kernel.Crypto;
using System.IO;

public class Program
{
    static void Main(string[] args)
    {
        string inputPdf = "input.pdf";       // PDF to be signed
        string outputPdf = "signed_output.pdf";  // Signed PDF output
        string pfxFile = "IronSoftware.pfx";  // Path to your PFX certificate
        string password = "Passw0rd";   // Password for PFX file

        try
        {
            // Load your certificate
            Pkcs12Store ks = new Pkcs12StoreBuilder().Build();
            using (FileStream fs = new FileStream(pfxFile, FileMode.Open, FileAccess.Read))
            {
                ks.Load(fs, password.ToCharArray());
            }

            string alias = null;
            foreach (string al in ks.Aliases)
            {
                if (ks.IsKeyEntry(al))
                {
                    alias = al;
                    break;
                }
            }

            if (alias == null)
            {
                throw new Exception("Alias not found in the PFX file.");
            }

            ICipherParameters pk = ks.GetKey(alias).Key;
            X509CertificateEntry[] chain = ks.GetCertificateChain(alias);

            // Convert BouncyCastle certificates to iText certificates
            var itextCertChain = new IX509Certificate[chain.Length];
            for (int i = 0; i < chain.Length; i++)
            {
                itextCertChain[i] = new X509CertificateBC(chain[i].Certificate);
            }

            // Create output PDF with signed content
            using (PdfReader reader = new PdfReader(inputPdf))
            using (FileStream os = new FileStream(outputPdf, FileMode.Create, FileAccess.Write))
            {
                PdfSigner signer = new PdfSigner(reader, os, new StampingProperties().UseAppendMode());

                // Set up the external signature (private key + digest algorithm)
                IPrivateKey iTextPrivateKey = new PrivateKeyBC(pk);
                IExternalSignature pks = new PrivateKeySignature(iTextPrivateKey, DigestAlgorithms.SHA256);
                IExternalDigest digest = new BouncyCastleDigest();

                // Perform the signing (detached signature)
                signer.SignDetached(digest, pks, itextCertChain, null, null, null, 0, PdfSigner.CryptoStandard.CMS);
            }

            Console.WriteLine($"PDF digitally signed successfully: {outputPdf}");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error signing PDF: {ex.Message}");
        }
    }
}
Imports System.Security.Cryptography.X509Certificates
Imports iText.Kernel.Pdf
Imports iText.Signatures
Imports iText.Bouncycastle.Crypto
Imports iText.Commons.Bouncycastle.Cert
Imports iText.Commons.Bouncycastle.Crypto
Imports Org.BouncyCastle.Pkcs
Imports Org.BouncyCastle.Crypto
Imports iText.Bouncycastle.X509
Imports iText.Kernel.Crypto
Imports System.IO

Public Class Program
	Shared Sub Main(ByVal args() As String)
		Dim inputPdf As String = "input.pdf" ' PDF to be signed
		Dim outputPdf As String = "signed_output.pdf" ' Signed PDF output
		Dim pfxFile As String = "IronSoftware.pfx" ' Path to your PFX certificate
		Dim password As String = "Passw0rd" ' Password for PFX file

		Try
			' Load your certificate
			Dim ks As Pkcs12Store = (New Pkcs12StoreBuilder()).Build()
			Using fs As New FileStream(pfxFile, FileMode.Open, FileAccess.Read)
				ks.Load(fs, password.ToCharArray())
			End Using

			Dim [alias] As String = Nothing
			For Each al As String In ks.Aliases
				If ks.IsKeyEntry(al) Then
					[alias] = al
					Exit For
				End If
			Next al

			If [alias] Is Nothing Then
				Throw New Exception("Alias not found in the PFX file.")
			End If

			Dim pk As ICipherParameters = ks.GetKey([alias]).Key
			Dim chain() As X509CertificateEntry = ks.GetCertificateChain([alias])

			' Convert BouncyCastle certificates to iText certificates
			Dim itextCertChain = New IX509Certificate(chain.Length - 1){}
			For i As Integer = 0 To chain.Length - 1
				itextCertChain(i) = New X509CertificateBC(chain(i).Certificate)
			Next i

			' Create output PDF with signed content
			Using reader As New PdfReader(inputPdf)
			Using os As New FileStream(outputPdf, FileMode.Create, FileAccess.Write)
				Dim signer As New PdfSigner(reader, os, (New StampingProperties()).UseAppendMode())

				' Set up the external signature (private key + digest algorithm)
				Dim iTextPrivateKey As IPrivateKey = New PrivateKeyBC(pk)
				Dim pks As IExternalSignature = New PrivateKeySignature(iTextPrivateKey, DigestAlgorithms.SHA256)
				Dim digest As IExternalDigest = New BouncyCastleDigest()

				' Perform the signing (detached signature)
				signer.SignDetached(digest, pks, itextCertChain, Nothing, Nothing, Nothing, 0, PdfSigner.CryptoStandard.CMS)
			End Using
			End Using

			Console.WriteLine($"PDF digitally signed successfully: {outputPdf}")
		Catch ex As Exception
			Console.WriteLine($"Error signing PDF: {ex.Message}")
		End Try
	End Sub
End Class
$vbLabelText   $csharpLabel

Output PDF
iText7 Digital Signature Output

As you can see, while iText7 is capable of digitally signing PDF documents, the process tends to be a lot more complex than with IronPDF. This code loads a PFX certificate and uses it to digitally sign a PDF. It extracts the private key and certificate, sets up the signer, and adds a detached signature to the PDF, then saves the signed document.

Competitive Analysis

Performance and Usability

Key Advantages of IronPDF

IronPDF is renowned for its ease of use and optimization for high performance, offering a more straightforward API that simplifies common tasks such as HTML to PDF conversion. It provides high-level methods that abstract complex PDF processing tasks, allowing developers to generate, edit, and manipulate PDFs with minimal code. For multi-threaded or large-scale document processing, IronPDF supports parallel execution.

  • Easy-to-use API – High-level methods simplify common tasks like HTML-to-PDF conversion.
  • Minimal setup required – Integrates easily into .NET projects.
  • Wbudowana obsługa wykonywania równoległego – zoptymalizowana pod kątem generowania i konwersji dużych ilości plików PDF.
  • Uproszczony interfejs API – wymaga mniej linii kodu, aby osiągnąć wyniki.

iText 7 – Potężne, ale złożone

Z drugiej strony iText 7 oferuje bardziej szczegółowy i precyzyjny poziom kontroli, co może być korzystne dla programistów wymagających szerokich możliwości dostosowywania. Zapewnia solidny interfejs API do pracy z operacjami PDF na niskim poziomie. Jednak ze względu na swoją złożoność iText 7 często wymaga więcej kodu, aby osiągnąć podobne wyniki w porównaniu z IronPDF.

  • Precyzyjna kontrola plików PDF – idealne rozwiązanie dla aplikacji Enterprise wymagających ścisłej zgodności (np. PDF/A, PDF/UA, podpisy cyfrowe).
  • Wysoki stopień dostosowania – oferuje zaawansowaną obsługę plików PDF dla zaawansowanych zastosowań.
  • Bardziej stroma krzywa uczenia się – wymaga więcej ustawień i konfiguracji w porównaniu z IronPDF.
  • Więcej kodu – typowe zadania często wymagają dłuższych implementacji.

Licensing and Cost

Przy wyborze biblioteki PDF do projektu .NET kluczowe znaczenie mają kwestie licencji i kosztów. Zarówno IronPDF, jak i iText 7 działają w oparciu o różne modele licencyjne, a wybór odpowiedniego zależy od wymagań projektu, budżetu i potrzeb w zakresie zgodności z przepisami.

Licencjonowanie i koszty IronPDF

IronPDF działa w modelu licencji komercyjnych, co oznacza, że chociaż oferuje bezpłatną wersję próbną licencji komercyjnej i jest darmowy do celów programistycznych i testowych, to do pełnego wykorzystania w produkcji potrzebna jest płatna licencja. Ceny są przejrzyste i zależą od takich czynników, jak skala użytkowania, liczba programistów oraz rodzaj projektu.

Licencjonowanie IronPDF:

  • Komercyjny model licencyjny (bez ograniczeń open source).
  • Prosta struktura cenowa oparta na licencjach dla programistów lub Team Licenses.
  • Bez dodatkowych kosztów za konwersję HTML do PDF, zabezpieczenia PDF lub inne podstawowe funkcje.
  • Najlepsze rozwiązanie dla firm**, które potrzebują prostego i ekonomicznego rozwiązania do obsługi plików PDF**.

Podsumowując: IronPDF zawiera wszystkie najważniejsze funkcje w ramach jednej licencji, co czyni go opłacalnym wyborem dla zespołów i firm.

Licencjonowanie i koszty iText7

iText7 działa w oparciu o model podwójnej licencji, który obejmuje:

  1. AGPL (GNU Affero General Public License) – Bezpłatna dla projektów open source, ale wymaga, aby cały projekt wykorzystujący iText7 był open source i zgodny z AGPL. Oznacza to, że wszelkie modyfikacje lub uzupełnienia wprowadzone do projektu muszą być również udostępniane publicznie.
  2. Licencja komercyjna – wymagana w przypadku każdego oprogramowania własnościowego lub aplikacji komercyjnych, których twórcy nie chcą ujawniać kodu źródłowego. Struktura cenowa różni się w zależności od wykorzystania, poziomu wsparcia i skali wdrożenia.

Dla firm, które chcą zintegrować iText 7 z własnym oprogramowaniem, wymagana jest licencja komercyjna. Koszt może być znaczny, zwłaszcza w przypadku rozwiązań na poziomie Enterprise, ponieważ cena jest ustalana w przeliczeniu na jednego programistę, ale zapewnia to dostęp do profesjonalnego wsparcia i gwarantuje zgodność z przepisami.

Dlaczego iText 7 może być droższy:

  • Ceny na programistę – każdy programista potrzebuje osobnej licencji, co zwiększa całkowite koszty dla zespołów.
  • Podstawowe funkcje wymagają kosztownych dodatków:
    • pdfHTML (płatny) – Wymagany do konwersji HTML na PDF.
    • pdfOCR (płatny) – Potrzebny do rozpoznawania tekstu z obrazów.
    • pdfCalligraph (płatny) – poprawia renderowanie tekstu i obsługę czcionek.
    • pdfRender (płatny) – dodaje funkcję konwersji plików PDF na obrazy.
    • pdf2Data (płatna) – Wyodrębnia dane strukturalne z plików PDF.
  • Koszty dla Enterprise mogą szybko wzrosnąć, gdy potrzebnych jest wiele funkcji i programistów.

Podsumowanie: Jeśli Twój zespół potrzebuje wielu programistów i kluczowych funkcji, takich jak konwersja HTML do PDF oraz OCR, iText 7 może być znacznie droższy niż IronPDF, który zapewnia te funkcje bez dodatkowych kosztów.

Scenariusze zastosowań

Małe projekty a projekty Enterprise

W przypadku małych i średnich projektów, które wymagają szybkiego wdrożenia funkcji PDF przy minimalnej konfiguracji, IronPDF jest atrakcyjnym wyborem ze względu na przyjazny dla użytkownika interfejs API i kompleksowy zestaw funkcji. W przypadku projektów na poziomie przedsiębiorstwa, które wymagają szerokiego dostosowania i zgodności z określonymi standardami PDF, warto skorzystać z zaawansowanych możliwości iText7, jednak IronPDF również stanowi silnego kandydata do tego rodzaju zadań ze względu na wysoką wydajność, opcje licencyjne i łatwość obsługi.

Wykorzystanie akademickie i komercyjne

W środowiskach akademickich lub projektach open source licencja AGPL iText 7 pozwala na bezpłatne użytkowanie, pod warunkiem że licencja projektu jest zgodna. W przypadku zastosowań komercyjnych zarówno IronPDF, jak i iText 7 wymagają zakupu licencji komercyjnej. Warto zapoznać się z warunkami licencji każdej biblioteki, aby upewnić się, że są one zgodne z celami Twojego projektu.

Wnioski

Wybór odpowiedniej biblioteki PDF do projektu .NET to kluczowa decyzja, która zależy od takich czynników, jak łatwość obsługi, zestaw funkcji i wymagania licencyjne. Zarówno IronPDF, jak i iText 7 oferują zaawansowane funkcje związane z plikami PDF, ale są dostosowane do różnych wymagań. Oprócz tych dwóch bibliotek, konkurenci tacy jak Aspose, Syncfusion i PDFSharp oferują konkurencyjne biblioteki .NET do obsługi plików PDF. Jednak IronPDF konsekwentnie przoduje w branży PDF dzięki łatwemu w użyciu API, kompleksowemu zestawowi funkcji i opłacalności.

Poniżej przedstawiamy przekonujące argumenty przemawiające za tym, dlaczego IronPDF jest doskonałym wyborem dla wszystkich Twoich potrzeb związanych z biblioteką PDF dla platformy .NET.

IronPDF vs iText7 comparison overview

Zalety IronPDF

  • Łatwość użytkowania: IronPDF został zaprojektowany z naciskiem na prostotę, co czyni go idealnym wyborem dla programistów, którzy potrzebują szybko zintegrować funkcje PDF ze swoimi aplikacjami .NET. Jego intuicyjny interfejs API skraca czas nauki i przyspiesza proces tworzenia oprogramowania.
  • Kompleksowa dokumentacja i wsparcie: IronPDF oferuje szczegółową dokumentację i responsywną obsługę klienta, dzięki czemu programiści mogą szybko opanować obsługę oprogramowania i skutecznie rozwiązywać problemy.
  • Płynna konwersja HTML do PDF: IronPDF doskonale radzi sobie z konwersją HTML, w tym CSS i JavaScript, na wysokiej jakości pliki PDF. Jest to szczególnie przydatne w przypadku projektów, które wymagają dynamicznego generowania plików PDF na podstawie treści internetowych.
  • Licencjonowanie komercyjne: W przypadku zastosowań komercyjnych IronPDF oferuje elastyczne opcje licencjonowania, zapewniające zgodność z przepisami bez ograniczeń, które mogą wynikać z licencji open source.

Ograniczenia iText

  • Złożoność: Chociaż iText 7 oferuje zaawansowane funkcje i możliwość dostosowania, jego API może być skomplikowane dla programistów, którzy dopiero zaczynają pracę z plikami PDF. Może to skutkować wydłużeniem czasu realizacji typowych zadań w porównaniu z prostszym podejściem stosowanym w IronPDF.
  • Koszty licencji na użytek komercyjny: Licencja AGPL iText 7 wymaga, aby wszelkie dzieła pochodne były udostępniane na zasadach open source, chyba że zakupisz licencję komercyjną. Może to stanowić ograniczenie dla aplikacji własnościowych, które nie mogą spełnić warunków licencji AGPL.
  • Funkcje zorientowane na Javę: Chociaż iText 7 jest dostępny dla platformy .NET, jego korzenie w ekosystemie Javy mogą czasami sprawiać, że programiści C# postrzegają go jako mniej natywny, zwłaszcza w przypadku problemów związanych z wieloplatformowością lub integracją z narzędziami opartymi na Javie.

Podsumowanie

Jeśli Twój projekt wymaga szybkiego generowania plików PDF, zwłaszcza z treści internetowych, i szukasz łatwego w użyciu rozwiązania, IronPDF będzie prawdopodobnie lepszym wyborem. Jeśli jednak Twoja aplikacja wymaga zaawansowanej obróbki plików PDF lub ścisłej zgodności ze standardami PDF, a potrzebujesz elastyczności umożliwiającej szerokie dostosowywanie, iText7 może być lepszym rozwiązaniem. Weź pod uwagę konkretne wymagania swojego projektu i ograniczenia licencyjne, aby wybrać bibliotekę najlepiej odpowiadającą Twoim potrzebom.

Wypróbuj IronPDF już dziś: pobierz bezpłatną wersję próbną, aby samodzielnie poznać zaawansowane funkcje IronPDF!

Zwróć uwagęiText 7 jest zastrzeżonym znakiem towarowym odpowiedniego właściciela. Ta strona nie jest powiązana z iText 7, nie jest przez nią promowana ani sponsorowana. Wszystkie nazwy produktów, logo i marki są własnością ich odpowiednich właścicieli. Porównania mają charakter wyłącznie informacyjny i odzwierciedlają informacje dostępne publicznie w momencie pisania.

Często Zadawane Pytania

Jak mogę przekonwertować HTML na PDF w języku C#?

Możesz użyć metody RenderHtmlAsPdf biblioteki IronPDF do konwersji ciągów HTML na pliki PDF. Możesz również konwertować pliki HTML na pliki PDF za pomocą metody RenderHtmlFileAsPdf.

Jakie są główne różnice między IronPDF a iText 7?

IronPDF oferuje płynną konwersję HTML do PDF oraz prosty model licencjonowania komercyjnego, podczas gdy iText 7 wymaga płatnego dodatku do konwersji HTML do PDF i stosuje model podwójnego licencjonowania. IronPDF jest znany z łatwości obsługi, podczas gdy iText 7 zapewnia zaawansowaną edycję plików PDF, ale wymaga dłuższego okresu nauki obsługi.

Dlaczego warto wybrać IronPDF for .NET?

IronPDF jest idealnym rozwiązaniem do szybkiego i ekonomicznego wdrażania plików PDF, oferując łatwość obsługi, obszerną dokumentację oraz wbudowaną konwersję HTML do PDF bez dodatkowych kosztów. Obsługuje wiele wersji .NET i zapewnia rozbudowane funkcje, takie jak edycja plików PDF i zabezpieczenia.

Czy IronPDF nadaje się do generowania złożonych dokumentów PDF?

Tak, IronPDF obsługuje tworzenie złożonych dokumentów PDF z funkcjami takimi jak wypełnianie formularzy, adnotacje i ekstrakcja danych. Jego rozbudowane możliwości sprawiają, że nadaje się do różnych profesjonalnych zastosowań związanych z plikami PDF.

Jakie opcje licencyjne są dostępne dla IronPDF?

IronPDF działa na zasadzie licencji komercyjnej, co oznacza, że do użytku produkcyjnego potrzebna jest płatna licencja. Ten prosty model eliminuje złożoność związaną z systemami podwójnych licencji, takimi jak te stosowane w iText 7.

Czy IronPDF można zintegrować z projektami .NET Core?

Tak, IronPDF można zintegrować z projektami .NET Core. Obsługuje on .NET Core, .NET Framework i .NET Standard, dzięki czemu jest wszechstronny w różnych środowiskach programistycznych.

W jaki sposób IronPDF obsługuje funkcje zabezpieczeń plików PDF?

IronPDF oferuje solidne funkcje zabezpieczeń plików PDF, w tym szyfrowanie, ochronę hasłem i podpisy cyfrowe, które pomagają zabezpieczyć poufne informacje zawarte w dokumentach.

Co sprawia, że IronPDF jest bardziej przyjazny dla użytkownika w porównaniu z innymi bibliotekami?

IronPDF jest uważany za przyjazny dla użytkownika ze względu na prosty interfejs API, minimalne wymagania konfiguracyjne i obszerną dokumentację, co sprawia, że jest łatwy do wdrożenia nawet dla programistów z ograniczonym doświadczeniem w generowaniu plików PDF.

Czy korzystanie z funkcji konwersji HTML do PDF w IronPDF wiąże się z dodatkowymi kosztami?

Nie, IronPDF zawiera wbudowane funkcje konwersji HTML do PDF, co eliminuje potrzebę stosowania dodatkowych komponentów lub ponoszenia dodatkowych kosztów, w przeciwieństwie do niektórych innych bibliotek PDF, które wymagają płatnych dodatków.

Jak wypada IronPDF pod względem wydajności i szybkości?

IronPDF jest zoptymalizowany pod kątem wydajności i szybkości, zapewniając szybkie i niezawodne generowanie oraz edycję plików PDF, co ma kluczowe znaczenie dla aplikacji przetwarzających duże ilości plików PDF.

Curtis Chau
Autor tekstów technicznych

Curtis Chau posiada tytuł licencjata z informatyki (Uniwersytet Carleton) i specjalizuje się w front-endowym rozwoju, z ekspertką w Node.js, TypeScript, JavaScript i React. Pasjonuje się tworzeniem intuicyjnych i estetycznie przyjemnych interfejsów użytkownika, Curtis cieszy się pracą z nowoczesnymi frameworkami i tworzeniem dobrze zorganizowanych, atrakcyjnych wizualnie podrę...

Czytaj więcej

Zespol wsparcia Iron

Jestesmy online 24 godziny, 5 dni w tygodniu.
Czat
Email
Zadzwon do mnie