Przejdź do treści stopki
PORóWNANIA PRODUKTóW

IronPDF vs iTextPdf: Kompleksowe porównanie bibliotek PDF .NET

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 excels with its Chromium-based HTML rendering engine, offering full CSS3 and JavaScript support along with built-in DOCX conversion. In contrast, iTextPdf provides advanced enterprise features with AGPL or commercial licensing but requires external dependencies for modern web standards and document conversion.

For developers working with PDFs, having a reliable library for PDF generation and manipulation is essential. In the .NET ecosystem, two popular PDF libraries stand out—IronPDF and iTextPdf—each offering effective tools to create, edit, and manage PDF documents. This article provides an in-depth comparison of these libraries based on feature capabilities, documentation quality, and pricing policies.

What Are IronPDF and iTextPdf?

How Does IronPDF Simplify PDF Development?

IronPDF is a reliable .NET library for PDF management, compatible with various .NET environments (Core 8, 7, 6, Framework, and more). It offers a complete feature set, including HTML to PDF conversion, merging PDFs, encryption, and digital signatures. IronPDF's documentation is straightforward, and users have access to reliable technical support. Developers often find solutions to common issues through Stack Overflow discussions and other source code sharing platforms. The library provides API references for detailed implementation guidance and supports advanced installation methods through NuGet packages. For quick implementation, explore the quickstart guide and installation overview to get started rapidly.

What Makes iTextPdf Suitable for Enterprise Applications?

iTextPdf is an advanced PDF library for Java and .NET (C#), focusing on enterprise-level document processing. Available under both AGPL and commercial licenses, it provides flexibility for various project requirements. iTextPdf is highly customizable, making it ideal for complex PDF tasks such as document encryption, digital signing, and form creation. The library has been a staple in enterprise environments requiring extensive PDF manipulation capabilities and compliance with PDF/A standards for archival purposes. Organizations requiring Section 508 accessibility compliance often choose enterprise-grade solutions that support universal accessibility standards.

Which Platforms Do IronPDF and iTextPdf Support?

Both IronPDF and iTextPdf support cross-platform functionality, making them versatile for various application needs within .NET. Here's a breakdown of each library's compatibility.

  • .NET Versions: Compatible with .NET Core (8, 7, 6, 5, 3.1+), .NET Standard (2.0+), and .NET Framework (4.6.2+).
  • App Environments: Works seamlessly in Windows, Linux, Mac, Docker, Azure, and AWS environments.
  • Supported IDEs: Works well with Microsoft Visual Studio and JetBrains Rider & ReSharper.
  • OS & Processors: Supports Windows, Mac, Linux, x64, x86, ARM.

  • .NET Versions: Compatible with .NET Core 8, 7, 6, 5, 3.1+, .NET Standard 2.0+, .NET Framework 4.6.2+
  • App Environments: Works in Windows, Linux, Mac, Docker, Azure, and AWS
  • Supported IDEs: Microsoft Visual Studio and JetBrains Rider & ReSharper
  • OS & Processors: Windows, Mac, Linux, x64, x86, ARM
  • Mobile Platforms: Android support through MAUI
  • Container Support: Remote container deployment for scalable architectures

  • .NET Versions: Supports .NET Core (2.x, 3.x), .NET Framework (4.6.1+), and .NET 5+.
  • App Environments: Compatible with Windows, macOS, Linux, and Docker.

Where Can iTextPdf Be Deployed?

  • .NET Versions: Supports .NET Core 2.x, 3.x, .NET Framework 4.6.1+, .NET 5+
  • App Environments: Compatible with Windows, macOS, Linux, Docker
  • Wdrożenia Enterprise: Zoptymalizowane pod kątem środowisk serwerowych z licencjami AGPL lub komercyjnymi

Jakie są kluczowe cechy IronPDF w porównaniu z iTextPdf?

Poniżej znajduje się szczegółowe porównanie kluczowych funkcji oferowanych przez każdą bibliotekę.

Jakie możliwości oferuje IronPDF?

  • HTML to PDF Conversion: Supports HTML, CSS, JavaScript, and images.
  • Obsługa plików PDF: dzielenie, łączenie i edycja dokumentów PDF.
  • Bezpieczeństwo: funkcje szyfrowania i deszyfrowania plików PDF.
  • Edycja: Umożliwia dodawanie adnotacji, zakładek i konspektów.
  • Templates: Apply headers, footers, and page numbers.
  • Znak wodny: Obsługuje znaki wodne tekstowe i graficzne przy użyciu HTML/CSS do sterowania.
  • Stemplowanie plików PDF: Dodawanie obrazów i tekstowych stempli do plików PDF.

Aby uzyskać więcej informacji na temat funkcji IronPDF, odwiedź stronę funkcji IronPDF. Biblioteka obsługuje również tworzenie plików PDF z różnych źródeł, konwersję plików PDF między formatami oraz organizowanie plików PDF za pomocą profesjonalnych narzędzi.

Jakie funkcje dla Enterprise oferuje iTextPdf?

  • PDF Creation: Supports creating PDF documents from scratch.
  • Formularze: Umożliwia tworzenie i edycję formularzy PDF.
  • Digital Signatures: Sign PDF documents.
  • Kompresja: Optymalizuje rozmiary plików PDF.
  • Wyodrębnianie treści: Wyodrębnia tekst i obrazy z plików PDF.
  • Możliwości dostosowania: Duże możliwości dostosowania do złożonych projektów.

W jaki sposób obie biblioteki obsługują konwersję HTML do PDF?

Obie biblioteki obsługują konwersję HTML do PDF, choć różnią się podejściem i łatwością użytkowania. IronPDF wykorzystuje silnik renderujący Chromium, zapewniający idealną dokładność pikselową, podczas gdy iTextPdf korzysta z dodatku pdfHTML o bardziej ograniczonej obsłudze CSS. IronPDF obsługuje pliki HTML, ciągi znaków HTML i adresy URL jako źródła danych wejściowych, w tym pełne renderowanie JavaScript. W przypadku złożonych układów IronPDF obsługuje typy mediów ekranowych i drukarskich CSS oraz umożliwia precyzyjną kontrolę dzięki obsłudze niestandardowych marginesów.

IronPDF

using IronPdf;

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

// Create a PDF from an HTML string
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
pdf.SaveAs("output.pdf");

// Advanced example with external assets
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");

// Render with custom options
renderer.RenderingOptions.MarginTop = 50;
renderer.RenderingOptions.MarginBottom = 50;
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
var customPdf = renderer.RenderHtmlAsPdf("<h1>Custom Settings</h1>");
customPdf.SaveAs("custom-settings.pdf");
using IronPdf;

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

// Create a PDF from an HTML string
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
pdf.SaveAs("output.pdf");

// Advanced example with external assets
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");

// Render with custom options
renderer.RenderingOptions.MarginTop = 50;
renderer.RenderingOptions.MarginBottom = 50;
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
var customPdf = renderer.RenderHtmlAsPdf("<h1>Custom Settings</h1>");
customPdf.SaveAs("custom-settings.pdf");
Imports IronPdf

' Instantiate the renderer
Dim renderer As New ChromePdfRenderer()

' Create a PDF from an HTML string
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
pdf.SaveAs("output.pdf")

' Advanced example with external assets
Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
myAdvancedPdf.SaveAs("html-with-assets.pdf")

' Render with custom options
renderer.RenderingOptions.MarginTop = 50
renderer.RenderingOptions.MarginBottom = 50
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print
Dim customPdf = renderer.RenderHtmlAsPdf("<h1>Custom Settings</h1>")
customPdf.SaveAs("custom-settings.pdf")
$vbLabelText   $csharpLabel

iTextPdf

using iText.Html2pdf;
using System.IO;

public class HtmlToPdf
{
    public static void ConvertHtmlToPdf()
    {
        using (FileStream htmlSource = File.Open("input.html", FileMode.Open))
        using (FileStream pdfDest = File.Open("output.pdf", FileMode.Create))
        {
            ConverterProperties converterProperties = new ConverterProperties();
            HtmlConverter.ConvertToPdf(htmlSource, pdfDest, converterProperties);
        }
    }
}
using iText.Html2pdf;
using System.IO;

public class HtmlToPdf
{
    public static void ConvertHtmlToPdf()
    {
        using (FileStream htmlSource = File.Open("input.html", FileMode.Open))
        using (FileStream pdfDest = File.Open("output.pdf", FileMode.Create))
        {
            ConverterProperties converterProperties = new ConverterProperties();
            HtmlConverter.ConvertToPdf(htmlSource, pdfDest, converterProperties);
        }
    }
}
Imports iText.Html2pdf
Imports System.IO

Public Class HtmlToPdf
	Public Shared Sub ConvertHtmlToPdf()
		Using htmlSource As FileStream = File.Open("input.html", FileMode.Open)
		Using pdfDest As FileStream = File.Open("output.pdf", FileMode.Create)
			Dim converterProperties As New ConverterProperties()
			HtmlConverter.ConvertToPdf(htmlSource, pdfDest, converterProperties)
		End Using
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF zapewnia proste podejście do konwersji HTML na PDF, obsługując HTML, CSS i JavaScript. Konwertuje bezpośrednio z ciągów znaków HTML lub zawiera zasoby z opcjonalną ścieżką bazową. Biblioteka obsługuje również pliki ZIP w formacie HTML dla złożonych projektów oraz responsywny CSS dla lepszego renderowania. W przypadku treści dynamicznych IronPDF oferuje opcje wykonywania kodu JavaScript i opóźnienia renderowania, aby zapewnić pełne załadowanie strony. Dodatkowe funkcje renderowania obejmują kontrolę okna wyświetlania oraz niestandardowe rozmiary papieru. iTextPdf wymaga więcej konfiguracji, skupiając się głównie na konwersji plików z ograniczoną obsługą nowoczesnych standardów internetowych.

Która biblioteka oferuje lepsze szyfrowanie plików PDF?

Szyfrowanie jest niezbędne, gdy bezpieczeństwo ma nadrzędne znaczenie. Oto, jak każda z bibliotek sobie z tym radzi. IronPDF zapewnia kompletne funkcje bezpieczeństwa, w tym szyfrowanie AES i zarządzanie uprawnieniami. Biblioteka obsługuje zarządzanie metadanymi oraz ich oczyszczanie w celu usuwania potencjalnie szkodliwych treści.

IronPDF

using IronPdf;

// Load an encrypted PDF or create a new one
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");

// Set document security settings
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.Password = "my-password";

// Set owner password for administrative access
pdf.SecuritySettings.OwnerPassword = "owner-password";

// Save with encryption
pdf.SaveAs("secured.pdf");
using IronPdf;

// Load an encrypted PDF or create a new one
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");

// Set document security settings
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.Password = "my-password";

// Set owner password for administrative access
pdf.SecuritySettings.OwnerPassword = "owner-password";

// Save with encryption
pdf.SaveAs("secured.pdf");
Imports IronPdf

' Load an encrypted PDF or create a new one
Dim pdf = PdfDocument.FromFile("encrypted.pdf", "password")

' Set document security settings
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key")
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserAnnotations = False
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.NoPrint
pdf.SecuritySettings.AllowUserFormData = False
pdf.Password = "my-password"

' Set owner password for administrative access
pdf.SecuritySettings.OwnerPassword = "owner-password"

' Save with encryption
pdf.SaveAs("secured.pdf")
$vbLabelText   $csharpLabel

iTextPdf

using iText.Kernel.Pdf;
using System.Text;

public class EncryptPdf
{
    public static readonly string DEST = "encrypt_pdf.pdf";
    public static readonly string OWNER_PASSWORD = "World";
    public static readonly string USER_PASSWORD = "Hello";

    protected void ManipulatePdf(string dest)
    {
        PdfDocument document = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter(dest,
            new WriterProperties().SetStandardEncryption(
                Encoding.UTF8.GetBytes(USER_PASSWORD),
                Encoding.UTF8.GetBytes(OWNER_PASSWORD),
                EncryptionConstants.ALLOW_PRINTING,
                EncryptionConstants.ENCRYPTION_AES_128)));
        document.Close();
    }
}
using iText.Kernel.Pdf;
using System.Text;

public class EncryptPdf
{
    public static readonly string DEST = "encrypt_pdf.pdf";
    public static readonly string OWNER_PASSWORD = "World";
    public static readonly string USER_PASSWORD = "Hello";

    protected void ManipulatePdf(string dest)
    {
        PdfDocument document = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter(dest,
            new WriterProperties().SetStandardEncryption(
                Encoding.UTF8.GetBytes(USER_PASSWORD),
                Encoding.UTF8.GetBytes(OWNER_PASSWORD),
                EncryptionConstants.ALLOW_PRINTING,
                EncryptionConstants.ENCRYPTION_AES_128)));
        document.Close();
    }
}
Imports iText.Kernel.Pdf
Imports System.Text

Public Class EncryptPdf
	Public Shared ReadOnly DEST As String = "encrypt_pdf.pdf"
	Public Shared ReadOnly OWNER_PASSWORD As String = "World"
	Public Shared ReadOnly USER_PASSWORD As String = "Hello"

	Protected Sub ManipulatePdf(ByVal dest As String)
		Dim document As New PdfDocument(New PdfReader("input.pdf"), New PdfWriter(dest, (New WriterProperties()).SetStandardEncryption(Encoding.UTF8.GetBytes(USER_PASSWORD), Encoding.UTF8.GetBytes(OWNER_PASSWORD), EncryptionConstants.ALLOW_PRINTING, EncryptionConstants.ENCRYPTION_AES_128)))
		document.Close()
	End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF zapewnia proste szyfrowanie i kontrolę nad uprawnieniami do dokumentów. Biblioteka obsługuje niestandardowe logowanie na potrzeby audytu bezpieczeństwa oraz Zarządzanie kluczami licencyjnymi w przypadku wdrożeń Enterprise. Aby zwiększyć bezpieczeństwo, IronPDF oferuje kontrolę wersji plików PDF oraz opcje konfiguracji rejestru. iTextPdf wymaga szczegółowej konfiguracji, ze szczególnym uwzględnieniem standardów szyfrowania. W przypadku zaawansowanych potrzeb w zakresie bezpieczeństwa IronPDF obsługuje również podpisy cyfrowe z modułem HSM dla wymagań Enterprise oraz uwierzytelnianie Kerberos dla bezpiecznych środowisk.

W jaki sposób IronPDF i iTextPdf radzą sobie z redagowaniem treści?

Redagowanie informacji w plikach PDF ma zasadnicze znaczenie dla prywatności i bezpieczeństwa. Oto, w jaki sposób każda biblioteka obsługuje tę funkcję. IronPDF oferuje pełne możliwości redagowania oraz czyszczenia plików PDF w celu usuwania potencjalnie szkodliwych treści. Biblioteka umożliwia również spłaszczanie plików PDF w celu konwersji formularzy i adnotacji na treść statyczną.

IronPDF

using IronPdf;

PdfDocument pdf = PdfDocument.FromFile("novel.pdf");

// Redact 'are' from all pages
pdf.RedactTextOnAllPages("are");

// Redact specific text on specific pages
pdf.RedactTextOnPage(0, "confidential");

// Use regular expressions for pattern matching
pdf.RedactTextOnAllPages(@"\b\d{3}-\d{2}-\d{4}\b"); // Redact SSN pattern

pdf.SaveAs("redacted.pdf");
using IronPdf;

PdfDocument pdf = PdfDocument.FromFile("novel.pdf");

// Redact 'are' from all pages
pdf.RedactTextOnAllPages("are");

// Redact specific text on specific pages
pdf.RedactTextOnPage(0, "confidential");

// Use regular expressions for pattern matching
pdf.RedactTextOnAllPages(@"\b\d{3}-\d{2}-\d{4}\b"); // Redact SSN pattern

pdf.SaveAs("redacted.pdf");
Imports IronPdf

Dim pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")

' Redact 'are' from all pages
pdf.RedactTextOnAllPages("are")

' Redact specific text on specific pages
pdf.RedactTextOnPage(0, "confidential")

' Use regular expressions for pattern matching
pdf.RedactTextOnAllPages("\b\d{3}-\d{2}-\d{4}\b") ' Redact SSN pattern

pdf.SaveAs("redacted.pdf")
$vbLabelText   $csharpLabel

iTextPdf

using iText.Kernel.Pdf;
using iText.Kernel.Colors;

// Define areas to redact on each page
Rectangle[] rectanglesToRedact = { new Rectangle(100, 100, 200, 50) };

// Draw black rectangles to cover sensitive areas
using (PdfDocument pdfDoc = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter("output_redacted.pdf")))
{
    for (int pageNum = 1; pageNum <= pdfDoc.GetNumberOfPages(); pageNum++)
    {
        PdfPage page = pdfDoc.GetPage(pageNum);
        PdfCanvas canvas = new PdfCanvas(page);
        foreach (Rectangle rect in rectanglesToRedact)
        {
            canvas.SetFillColor(ColorConstants.BLACK)
                  .Rectangle(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight())
                  .Fill();
        }
    }
}
using iText.Kernel.Pdf;
using iText.Kernel.Colors;

// Define areas to redact on each page
Rectangle[] rectanglesToRedact = { new Rectangle(100, 100, 200, 50) };

// Draw black rectangles to cover sensitive areas
using (PdfDocument pdfDoc = new PdfDocument(new PdfReader("input.pdf"), new PdfWriter("output_redacted.pdf")))
{
    for (int pageNum = 1; pageNum <= pdfDoc.GetNumberOfPages(); pageNum++)
    {
        PdfPage page = pdfDoc.GetPage(pageNum);
        PdfCanvas canvas = new PdfCanvas(page);
        foreach (Rectangle rect in rectanglesToRedact)
        {
            canvas.SetFillColor(ColorConstants.BLACK)
                  .Rectangle(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight())
                  .Fill();
        }
    }
}
Imports iText.Kernel.Pdf
Imports iText.Kernel.Colors

' Define areas to redact on each page
Private rectanglesToRedact() As Rectangle = { New Rectangle(100, 100, 200, 50) }

' Draw black rectangles to cover sensitive areas
Using pdfDoc As New PdfDocument(New PdfReader("input.pdf"), New PdfWriter("output_redacted.pdf"))
	Dim pageNum As Integer = 1
	Do While pageNum <= pdfDoc.GetNumberOfPages()
		Dim page As PdfPage = pdfDoc.GetPage(pageNum)
		Dim canvas As New PdfCanvas(page)
		For Each rect As Rectangle In rectanglesToRedact
			canvas.SetFillColor(ColorConstants.BLACK).Rectangle(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight()).Fill()
		Next rect
		pageNum += 1
	Loop
End Using
$vbLabelText   $csharpLabel

IronPDF oferuje wygodne narzędzie do redagowania, które z łatwością ukrywa poufny tekst na wszystkich stronach. Biblioteka oferuje również funkcje zamiany tekstu do aktualizacji treści dokumentów oraz dostęp do DOM plików PDF w celu szczegółowej manipulacji treścią. Aby wyodrębnić treść przed redakcją, należy użyć funkcji wyodrębniania tekstu i obrazów lub programowo przeanalizować pliki PDF. iTextPdf wymaga ręcznego zdefiniowania i zastosowania czarnych prostokątów w celu zakrycia wrażliwych obszarów. W celu pełnej oczyszczania dokumentów IronPDF oferuje również funkcje oczyszczania plików PDF w celu usunięcia potencjalnie złośliwych treści oraz spłaszczania plików PDF w celu przekształcenia elementów interaktywnych w treści statyczne.

Która biblioteka ułatwia tworzenie podpisów cyfrowych?

Automatyzacja podpisywania dokumentów PDF pozwala zaoszczędzić sporo czasu. Oto porównanie sposobu obsługi podpisów cyfrowych przez IronPDF i iTextPdf. IronPDF obsługuje różne metody podpisywania, w tym podpisy oparte na certyfikatach oraz integrację z modułem HSM. Biblioteka przechowuje również historię zmian, umożliwiającą śledzenie modyfikacji dokumentów oraz sprawdzanie ważności podpisów.

IronPDF

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

// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);

// Create PdfSignature object
var sig = new PdfSignature(cert)
{
    SigningContact = "support@ironsoftware.com",
    SigningLocation = "Chicago, USA",
    SigningReason = "Document Approval"
};

// Sign PDF document
PdfDocument pdf = PdfDocument.FromFile("document.pdf");
pdf.Sign(sig);

// Apply timestamp
var timestampedSig = new PdfSignature(cert)
{
    TimestampHashAlgorithm = TimestampHashAlgorithm.SHA256,
    TimeStampUrl = "___PROTECTED_URL_245___"
};

pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);

// Create PdfSignature object
var sig = new PdfSignature(cert)
{
    SigningContact = "support@ironsoftware.com",
    SigningLocation = "Chicago, USA",
    SigningReason = "Document Approval"
};

// Sign PDF document
PdfDocument pdf = PdfDocument.FromFile("document.pdf");
pdf.Sign(sig);

// Apply timestamp
var timestampedSig = new PdfSignature(cert)
{
    TimestampHashAlgorithm = TimestampHashAlgorithm.SHA256,
    TimeStampUrl = "___PROTECTED_URL_245___"
};

pdf.SaveAs("signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates

' Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
Dim cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)

' Create PdfSignature object
Dim sig As New PdfSignature(cert) With {
    .SigningContact = "support@ironsoftware.com",
    .SigningLocation = "Chicago, USA",
    .SigningReason = "Document Approval"
}

' Sign PDF document
Dim pdf As PdfDocument = PdfDocument.FromFile("document.pdf")
pdf.Sign(sig)

' Apply timestamp
Dim timestampedSig As New PdfSignature(cert) With {
    .TimestampHashAlgorithm = TimestampHashAlgorithm.SHA256,
    .TimeStampUrl = "___PROTECTED_URL_245___"
}

pdf.SaveAs("signed.pdf")
$vbLabelText   $csharpLabel

iTextPdf

using System;
using System.IO;
using iText.Kernel.Pdf;
using iText.Signatures;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.X509;

class Program
{
    static void Main(string[] args)
    {
        string src = "input.pdf";
        string dest = "output_signed.pdf";
        string pfxFile = "your_certificate.pfx";
        string pfxPassword = "your_password";

        try
        {
            // Load your certificate
            Pkcs12Store ks = new Pkcs12Store(new FileStream(pfxFile, FileMode.Open), pfxPassword.ToCharArray());
            string alias = null;
            foreach (string al in ks.Aliases)
            {
                if (ks.IsKeyEntry(al))
                {
                    alias = al;
                    break;
                }
            }
            ICipherParameters pk = ks.GetKey(alias).Key;
            X509CertificateEntry[] chain = ks.GetCertificateChain(alias);
            X509Certificate2 cert = new X509Certificate2(chain[0].Certificate.GetEncoded());

            // Create output PDF with signed content
            using (PdfReader reader = new PdfReader(src))
            {
                using (PdfWriter writer = new PdfWriter(dest))
                {
                    using (PdfDocument pdfDoc = new PdfDocument(reader, writer))
                    {
                        // Create the signer
                        PdfSigner signer = new PdfSigner(pdfDoc, writer, new StampingProperties().UseAppendMode());

                        // Configure signature appearance
                        PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
                        appearance.SetReason("Digital Signature");
                        appearance.SetLocation("Your Location");
                        appearance.SetContact("Your Contact");

                        // Create signature
                        IExternalSignature pks = new PrivateKeySignature(pk, "SHA-256");
                        signer.SignDetached(pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CMS);
                    }
                }
            }
            Console.WriteLine($"PDF digitally signed successfully: {dest}");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error signing PDF: {ex.Message}");
        }
    }
}
using System;
using System.IO;
using iText.Kernel.Pdf;
using iText.Signatures;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.X509;

class Program
{
    static void Main(string[] args)
    {
        string src = "input.pdf";
        string dest = "output_signed.pdf";
        string pfxFile = "your_certificate.pfx";
        string pfxPassword = "your_password";

        try
        {
            // Load your certificate
            Pkcs12Store ks = new Pkcs12Store(new FileStream(pfxFile, FileMode.Open), pfxPassword.ToCharArray());
            string alias = null;
            foreach (string al in ks.Aliases)
            {
                if (ks.IsKeyEntry(al))
                {
                    alias = al;
                    break;
                }
            }
            ICipherParameters pk = ks.GetKey(alias).Key;
            X509CertificateEntry[] chain = ks.GetCertificateChain(alias);
            X509Certificate2 cert = new X509Certificate2(chain[0].Certificate.GetEncoded());

            // Create output PDF with signed content
            using (PdfReader reader = new PdfReader(src))
            {
                using (PdfWriter writer = new PdfWriter(dest))
                {
                    using (PdfDocument pdfDoc = new PdfDocument(reader, writer))
                    {
                        // Create the signer
                        PdfSigner signer = new PdfSigner(pdfDoc, writer, new StampingProperties().UseAppendMode());

                        // Configure signature appearance
                        PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
                        appearance.SetReason("Digital Signature");
                        appearance.SetLocation("Your Location");
                        appearance.SetContact("Your Contact");

                        // Create signature
                        IExternalSignature pks = new PrivateKeySignature(pk, "SHA-256");
                        signer.SignDetached(pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CMS);
                    }
                }
            }
            Console.WriteLine($"PDF digitally signed successfully: {dest}");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error signing PDF: {ex.Message}");
        }
    }
}
Imports System
Imports System.IO
Imports iText.Kernel.Pdf
Imports iText.Signatures
Imports Org.BouncyCastle.Crypto
Imports Org.BouncyCastle.Pkcs
Imports Org.BouncyCastle.X509

Friend Class Program
	Shared Sub Main(ByVal args() As String)
		Dim src As String = "input.pdf"
		Dim dest As String = "output_signed.pdf"
		Dim pfxFile As String = "your_certificate.pfx"
		Dim pfxPassword As String = "your_password"

		Try
			' Load your certificate
			Dim ks As New Pkcs12Store(New FileStream(pfxFile, FileMode.Open), pfxPassword.ToCharArray())
			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
			Dim pk As ICipherParameters = ks.GetKey([alias]).Key
			Dim chain() As X509CertificateEntry = ks.GetCertificateChain([alias])
			Dim cert As New X509Certificate2(chain(0).Certificate.GetEncoded())

			' Create output PDF with signed content
			Using reader As New PdfReader(src)
				Using writer As New PdfWriter(dest)
					Using pdfDoc As New PdfDocument(reader, writer)
						' Create the signer
						Dim signer As New PdfSigner(pdfDoc, writer, (New StampingProperties()).UseAppendMode())

						' Configure signature appearance
						Dim appearance As PdfSignatureAppearance = signer.GetSignatureAppearance()
						appearance.SetReason("Digital Signature")
						appearance.SetLocation("Your Location")
						appearance.SetContact("Your Contact")

						' Create signature
						Dim pks As IExternalSignature = New PrivateKeySignature(pk, "SHA-256")
						signer.SignDetached(pks, chain, Nothing, Nothing, Nothing, 0, PdfSigner.CryptoStandard.CMS)
					End Using
				End Using
			End Using
			Console.WriteLine($"PDF digitally signed successfully: {dest}")
		Catch ex As Exception
			Console.WriteLine($"Error signing PDF: {ex.Message}")
		End Try
	End Sub
End Class
$vbLabelText   $csharpLabel

Podczas stosowania podpisów cyfrowych w plikach PDF, IronPDF zapewnia proste i wydajne podejście z wykorzystaniem certyfikatów X509. Jego API upraszcza integrację bez utraty kontroli nad bezpieczeństwem. IronPDF obsługuje również śledzenie historii zmian w celu zachowania integralności dokumentów oraz wiele typów podpisów, w tym podpisy wizualne. Biblioteka integruje się z urządzeniami HSM w celu zwiększenia bezpieczeństwa i obsługuje weryfikację certyfikatów. Aby zapewnić bezpieczny obieg dokumentów, zapoznaj się z funkcjami podpisywania i zabezpieczania plików PDF. Proces podpisywania w iTextPdf oferuje więcej opcji dostosowywania, ale wymaga skomplikowanej konfiguracji. Programiści zyskują szczegółową kontrolę, ale muszą zmierzyć się z trudniejszym procesem nauki obsługi certyfikatów i konfiguracji podpisów.

W jaki sposób obie biblioteki nakładają znaki wodne na pliki PDF?

Znakowanie plików PDF znakiem wodnym jest niezbędne dla budowania marki, zachowania poufności i ochrony praw autorskich. Oto jak IronPDF i iTextPdf nakładają znaki wodne na dokumenty PDF. IronPDF oferuje elastyczne opcje znakowania wodnego z obsługą HTML/CSS. Biblioteka umożliwia również tworzenie warstw tła i pierwszego planu dla złożonych nakładek.

IronPDF

using IronPdf;

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

var pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_246___");

// Add text watermark
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);

// Add image watermark
pdf.ApplyWatermark("<img src='logo.png' style='width:200px'>", 45, IronPdf.Editing.VerticalAlignment.Bottom, IronPdf.Editing.HorizontalAlignment.Right);

// Add complex HTML watermark with transparency
string watermarkHtml = @"
<div style='font-size:80px; color:rgba(255,0,0,0.3); font-family:Arial; transform:rotate(-45deg);'>
    CONFIDENTIAL
</div>";
pdf.ApplyWatermark(watermarkHtml, 0, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);

pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
using IronPdf;

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

var pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_246___");

// Add text watermark
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);

// Add image watermark
pdf.ApplyWatermark("<img src='logo.png' style='width:200px'>", 45, IronPdf.Editing.VerticalAlignment.Bottom, IronPdf.Editing.HorizontalAlignment.Right);

// Add complex HTML watermark with transparency
string watermarkHtml = @"
<div style='font-size:80px; color:rgba(255,0,0,0.3); font-family:Arial; transform:rotate(-45deg);'>
    CONFIDENTIAL
</div>";
pdf.ApplyWatermark(watermarkHtml, 0, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);

pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
Imports IronPdf

' Stamps a Watermark onto a new or existing PDF
Dim renderer As New ChromePdfRenderer()

Dim pdf = renderer.RenderUrlAsPdf("___PROTECTED_URL_246___")

' Add text watermark
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)

' Add image watermark
pdf.ApplyWatermark("<img src='logo.png' style='width:200px'>", 45, IronPdf.Editing.VerticalAlignment.Bottom, IronPdf.Editing.HorizontalAlignment.Right)

' Add complex HTML watermark with transparency
Dim watermarkHtml As String = "
<div style='font-size:80px; color:rgba(255,0,0,0.3); font-family:Arial; transform:rotate(-45deg);'>
    CONFIDENTIAL
</div>"
pdf.ApplyWatermark(watermarkHtml, 0, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)

pdf.SaveAs("C:\Path\To\Watermarked.pdf")
$vbLabelText   $csharpLabel

iTextPdf

using iText.IO.Font;
using iText.IO.Font.Constants;
using iText.Kernel.Colors;
using iText.Kernel.Font;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas;
using iText.Kernel.Pdf.Extgstate;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;

public class TransparentWatermark 
{
    public static readonly string DEST = "results/sandbox/stamper/transparent_watermark.pdf";
    public static readonly string SRC = "../../../resources/pdfs/hero.pdf";

    public static void Main(string[] args) 
    {
        FileInfo file = new FileInfo(DEST);
        file.Directory.Create();

        new TransparentWatermark().ManipulatePdf(DEST);
    }

    protected void ManipulatePdf(string dest) 
    {
        PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
        PdfCanvas under = new PdfCanvas(pdfDoc.GetFirstPage().NewContentStreamBefore(), new PdfResources(), pdfDoc);
        PdfFont font = PdfFontFactory.CreateFont(FontProgramFactory.CreateFont(StandardFonts.HELVETICA));
        Paragraph paragraph = new Paragraph("This watermark is added UNDER the existing content")
                .SetFont(font)
                .SetFontSize(15);

        Canvas canvasWatermark1 = new Canvas(under, pdfDoc.GetDefaultPageSize())
                .ShowTextAligned(paragraph, 297, 550, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
        canvasWatermark1.Close();
        PdfCanvas over = new PdfCanvas(pdfDoc.GetFirstPage());
        over.SetFillColor(ColorConstants.BLACK);
        paragraph = new Paragraph("This watermark is added ON TOP OF the existing content")
                .SetFont(font)
                .SetFontSize(15);

        Canvas canvasWatermark2 = new Canvas(over, pdfDoc.GetDefaultPageSize())
                .ShowTextAligned(paragraph, 297, 500, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
        canvasWatermark2.Close();
        paragraph = new Paragraph("This TRANSPARENT watermark is added ON TOP OF the existing content")
                .SetFont(font)
                .SetFontSize(15);
        over.SaveState();

        PdfExtGState gs1 = new PdfExtGState();
        gs1.SetFillOpacity(0.5f);
        over.SetExtGState(gs1);
        Canvas canvasWatermark3 = new Canvas(over, pdfDoc.GetDefaultPageSize())
                .ShowTextAligned(paragraph, 297, 450, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
        canvasWatermark3.Close();
        over.RestoreState();

        pdfDoc.Close();
    }
}
using iText.IO.Font;
using iText.IO.Font.Constants;
using iText.Kernel.Colors;
using iText.Kernel.Font;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas;
using iText.Kernel.Pdf.Extgstate;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;

public class TransparentWatermark 
{
    public static readonly string DEST = "results/sandbox/stamper/transparent_watermark.pdf";
    public static readonly string SRC = "../../../resources/pdfs/hero.pdf";

    public static void Main(string[] args) 
    {
        FileInfo file = new FileInfo(DEST);
        file.Directory.Create();

        new TransparentWatermark().ManipulatePdf(DEST);
    }

    protected void ManipulatePdf(string dest) 
    {
        PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
        PdfCanvas under = new PdfCanvas(pdfDoc.GetFirstPage().NewContentStreamBefore(), new PdfResources(), pdfDoc);
        PdfFont font = PdfFontFactory.CreateFont(FontProgramFactory.CreateFont(StandardFonts.HELVETICA));
        Paragraph paragraph = new Paragraph("This watermark is added UNDER the existing content")
                .SetFont(font)
                .SetFontSize(15);

        Canvas canvasWatermark1 = new Canvas(under, pdfDoc.GetDefaultPageSize())
                .ShowTextAligned(paragraph, 297, 550, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
        canvasWatermark1.Close();
        PdfCanvas over = new PdfCanvas(pdfDoc.GetFirstPage());
        over.SetFillColor(ColorConstants.BLACK);
        paragraph = new Paragraph("This watermark is added ON TOP OF the existing content")
                .SetFont(font)
                .SetFontSize(15);

        Canvas canvasWatermark2 = new Canvas(over, pdfDoc.GetDefaultPageSize())
                .ShowTextAligned(paragraph, 297, 500, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
        canvasWatermark2.Close();
        paragraph = new Paragraph("This TRANSPARENT watermark is added ON TOP OF the existing content")
                .SetFont(font)
                .SetFontSize(15);
        over.SaveState();

        PdfExtGState gs1 = new PdfExtGState();
        gs1.SetFillOpacity(0.5f);
        over.SetExtGState(gs1);
        Canvas canvasWatermark3 = new Canvas(over, pdfDoc.GetDefaultPageSize())
                .ShowTextAligned(paragraph, 297, 450, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
        canvasWatermark3.Close();
        over.RestoreState();

        pdfDoc.Close();
    }
}
Imports iText.IO.Font
Imports iText.IO.Font.Constants
Imports iText.Kernel.Colors
Imports iText.Kernel.Font
Imports iText.Kernel.Pdf
Imports iText.Kernel.Pdf.Canvas
Imports iText.Kernel.Pdf.Extgstate
Imports iText.Layout
Imports iText.Layout.Element
Imports iText.Layout.Properties

Public Class TransparentWatermark
	Public Shared ReadOnly DEST As String = "results/sandbox/stamper/transparent_watermark.pdf"
	Public Shared ReadOnly SRC As String = "../../../resources/pdfs/hero.pdf"

	Public Shared Sub Main(ByVal args() As String)
		Dim file As New FileInfo(DEST)
		file.Directory.Create()

		Call (New TransparentWatermark()).ManipulatePdf(DEST)
	End Sub

	Protected Sub ManipulatePdf(ByVal dest As String)
		Dim pdfDoc As New PdfDocument(New PdfReader(SRC), New PdfWriter(dest))
		Dim under As New PdfCanvas(pdfDoc.GetFirstPage().NewContentStreamBefore(), New PdfResources(), pdfDoc)
		Dim font As PdfFont = PdfFontFactory.CreateFont(FontProgramFactory.CreateFont(StandardFonts.HELVETICA))
		Dim paragraph As Paragraph = (New Paragraph("This watermark is added UNDER the existing content")).SetFont(font).SetFontSize(15)

		Dim canvasWatermark1 As Canvas = (New Canvas(under, pdfDoc.GetDefaultPageSize())).ShowTextAligned(paragraph, 297, 550, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0)
		canvasWatermark1.Close()
		Dim over As New PdfCanvas(pdfDoc.GetFirstPage())
		over.SetFillColor(ColorConstants.BLACK)
		paragraph = (New Paragraph("This watermark is added ON TOP OF the existing content")).SetFont(font).SetFontSize(15)

		Dim canvasWatermark2 As Canvas = (New Canvas(over, pdfDoc.GetDefaultPageSize())).ShowTextAligned(paragraph, 297, 500, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0)
		canvasWatermark2.Close()
		paragraph = (New Paragraph("This TRANSPARENT watermark is added ON TOP OF the existing content")).SetFont(font).SetFontSize(15)
		over.SaveState()

		Dim gs1 As New PdfExtGState()
		gs1.SetFillOpacity(0.5F)
		over.SetExtGState(gs1)
		Dim canvasWatermark3 As Canvas = (New Canvas(over, pdfDoc.GetDefaultPageSize())).ShowTextAligned(paragraph, 297, 450, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0)
		canvasWatermark3.Close()
		over.RestoreState()

		pdfDoc.Close()
	End Sub
End Class
$vbLabelText   $csharpLabel

API IronPDF umożliwia szybkie nakładanie znaków wodnych z elastycznością dostosowywania HTML i CSS. Takie podejście pozwala tworzyć wizualnie wyróżniające się znaki wodne bez konieczności skomplikowanej konfiguracji. Aby zapewnić większą kontrolę, IronPDF obsługuje warstwy tła i pierwszego planu, umożliwiając nakładanie złożonych elementów na dokument, stosowanie wielu znaków wodnych oraz niestandardowe pozycjonowanie. Biblioteka oferuje również integrację BARCODE do celów śledzenia oraz obsługę grafiki SVG dla skalowalnych znaków wodnych. W przypadku zaawansowanych potrzeb zapoznaj się z funkcjami przekształcania stron PDF oraz rysowania linii i prostokątów. iTextPdf umożliwia wysoce konfigurowalne umieszczanie znaków wodnych dzięki szczegółowym opcjom konfiguracyjnym, choć wymaga to większego nakładu pracy programistycznej.### Która biblioteka oferuje lepsze możliwości umieszczania znaków wodnych na obrazach i tekście?

Umieszczanie treści w plikach PDF przypomina stosowanie znaków wodnych, ale skupia się na dodawaniu konkretnych elementów, takich jak obrazy lub tekst, w celach identyfikacyjnych lub brandingowych. Oto, jak IronPDF i iTextPdf wykonują to zadanie. IronPDF oferuje rozbudowane funkcje stemplowania z elastycznymi opcjami pozycjonowania. Biblioteka obsługuje również rysowanie tekstu i map bitowych bezpośrednio na stronach PDF.

IronPDF

using IronPdf;
using IronPdf.Editing;

ChromePdfRenderer renderer = new ChromePdfRenderer();

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");

// Create text stamper
TextStamper textStamper = new TextStamper()
{
    Text = "Text Stamper!",
    FontFamily = "Bungee Spice",
    UseGoogleFont = true,
    FontSize = 30,
    IsBold = true,
    IsItalic = true,
    VerticalAlignment = VerticalAlignment.Top,
    HorizontalAlignment = HorizontalAlignment.Center,
    Opacity = 50,
    Rotation = -45
};

// Stamp the text stamper on all pages
pdf.ApplyStamp(textStamper);

// Create HTML stamper for complex layouts
HtmlStamper htmlStamper = new HtmlStamper()
{
    Html = @"<div style='border:2px solid red; padding:10px;'>
             <h3>APPROVED</h3>
             <p>Date: " + DateTime.Now.ToShortDateString() + @"</p>
             </div>",
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalAlignment = HorizontalAlignment.Right,
    Width = 200,
    Height = 100
};

pdf.ApplyStamp(htmlStamper);

// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("___PROTECTED_URL_247___"))
{
    VerticalAlignment = VerticalAlignment.Top,
    HorizontalAlignment = HorizontalAlignment.Left,
    MaxWidth = new Length(150),
    MaxHeight = new Length(150)
};

// Stamp the image stamper on specific pages
pdf.ApplyStamp(imageStamper, new[] { 0, 2, 4 });

pdf.SaveAs("stamped.pdf");
using IronPdf;
using IronPdf.Editing;

ChromePdfRenderer renderer = new ChromePdfRenderer();

PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");

// Create text stamper
TextStamper textStamper = new TextStamper()
{
    Text = "Text Stamper!",
    FontFamily = "Bungee Spice",
    UseGoogleFont = true,
    FontSize = 30,
    IsBold = true,
    IsItalic = true,
    VerticalAlignment = VerticalAlignment.Top,
    HorizontalAlignment = HorizontalAlignment.Center,
    Opacity = 50,
    Rotation = -45
};

// Stamp the text stamper on all pages
pdf.ApplyStamp(textStamper);

// Create HTML stamper for complex layouts
HtmlStamper htmlStamper = new HtmlStamper()
{
    Html = @"<div style='border:2px solid red; padding:10px;'>
             <h3>APPROVED</h3>
             <p>Date: " + DateTime.Now.ToShortDateString() + @"</p>
             </div>",
    VerticalAlignment = VerticalAlignment.Bottom,
    HorizontalAlignment = HorizontalAlignment.Right,
    Width = 200,
    Height = 100
};

pdf.ApplyStamp(htmlStamper);

// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("___PROTECTED_URL_247___"))
{
    VerticalAlignment = VerticalAlignment.Top,
    HorizontalAlignment = HorizontalAlignment.Left,
    MaxWidth = new Length(150),
    MaxHeight = new Length(150)
};

// Stamp the image stamper on specific pages
pdf.ApplyStamp(imageStamper, new[] { 0, 2, 4 });

pdf.SaveAs("stamped.pdf");
Imports IronPdf
Imports IronPdf.Editing

Dim renderer As New ChromePdfRenderer()

Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")

' Create text stamper
Dim textStamper As New TextStamper() With {
    .Text = "Text Stamper!",
    .FontFamily = "Bungee Spice",
    .UseGoogleFont = True,
    .FontSize = 30,
    .IsBold = True,
    .IsItalic = True,
    .VerticalAlignment = VerticalAlignment.Top,
    .HorizontalAlignment = HorizontalAlignment.Center,
    .Opacity = 50,
    .Rotation = -45
}

' Stamp the text stamper on all pages
pdf.ApplyStamp(textStamper)

' Create HTML stamper for complex layouts
Dim htmlStamper As New HtmlStamper() With {
    .Html = "<div style='border:2px solid red; padding:10px;'>" &
            "<h3>APPROVED</h3>" &
            "<p>Date: " & DateTime.Now.ToShortDateString() & "</p>" &
            "</div>",
    .VerticalAlignment = VerticalAlignment.Bottom,
    .HorizontalAlignment = HorizontalAlignment.Right,
    .Width = 200,
    .Height = 100
}

pdf.ApplyStamp(htmlStamper)

' Create image stamper
Dim imageStamper As New ImageStamper(New Uri("___PROTECTED_URL_247___")) With {
    .VerticalAlignment = VerticalAlignment.Top,
    .HorizontalAlignment = HorizontalAlignment.Left,
    .MaxWidth = New Length(150),
    .MaxHeight = New Length(150)
}

' Stamp the image stamper on specific pages
pdf.ApplyStamp(imageStamper, {0, 2, 4})

pdf.SaveAs("stamped.pdf")
$vbLabelText   $csharpLabel

iTextPdf

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

public void StampPDF(string inputPdfPath, string outputPdfPath, string stampText)
{
    PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputPdfPath), new PdfWriter(outputPdfPath));

    Document doc = new Document(pdfDoc);

    // Add stamp (text) to each page
    int numPages = pdfDoc.GetNumberOfPages();
    for (int i = 1; i <= numPages; i++)
    {
        doc.ShowTextAligned(new Paragraph(stampText),
                            36, 36, i, iText.Layout.Properties.TextAlignment.LEFT,
                            iText.Layout.Properties.VerticalAlignment.TOP, 0);
    }

    doc.Close();
}
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

public void StampPDF(string inputPdfPath, string outputPdfPath, string stampText)
{
    PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputPdfPath), new PdfWriter(outputPdfPath));

    Document doc = new Document(pdfDoc);

    // Add stamp (text) to each page
    int numPages = pdfDoc.GetNumberOfPages();
    for (int i = 1; i <= numPages; i++)
    {
        doc.ShowTextAligned(new Paragraph(stampText),
                            36, 36, i, iText.Layout.Properties.TextAlignment.LEFT,
                            iText.Layout.Properties.VerticalAlignment.TOP, 0);
    }

    doc.Close();
}
Imports iText.Kernel.Pdf
Imports iText.Layout
Imports iText.Layout.Element

Public Sub StampPDF(ByVal inputPdfPath As String, ByVal outputPdfPath As String, ByVal stampText As String)
	Dim pdfDoc As New PdfDocument(New PdfReader(inputPdfPath), New PdfWriter(outputPdfPath))

	Dim doc As New Document(pdfDoc)

	' Add stamp (text) to each page
	Dim numPages As Integer = pdfDoc.GetNumberOfPages()
	For i As Integer = 1 To numPages
		doc.ShowTextAligned(New Paragraph(stampText), 36, 36, i, iText.Layout.Properties.TextAlignment.LEFT, iText.Layout.Properties.VerticalAlignment.TOP, 0)
	Next i

	doc.Close()
End Sub
$vbLabelText   $csharpLabel

Metody umieszczania obrazów i tekstu w plikach PDF oferowane przez IronPDF są proste i wszechstronne, umożliwiając łatwe dodawanie treści związanych z marką lub etykiet do stron PDF. API wykorzystuje znane elementy stylizacji HTML/CSS, co ułatwia dostosowywanie. W przypadku złożonych potrzeb związanych z pieczątkami IronPDF efektywnie obsługuje wiele pieczątek, integrację z Google Fonts oraz czcionki internetowe. Biblioteka umożliwia również rysowanie tekstu i map bitowych bezpośrednio na plikach PDF oraz obsługuje nanoszenie kodów BarCode w celu śledzenia zapasów. Aby uzyskać precyzyjną kontrolę, zapoznaj się z funkcjami tłumaczenia obiektów PDF i skalowania obiektów PDF. iTextPdf oferuje również funkcje umieszczania obrazów i tekstu, choć konfiguracja wymaga więcej ręcznej pracy i znajomości struktury układu plików PDF. Możliwość bezpośredniej edycji treści na stronach PDF zapewnia niezawodne narzędzia do stemplowania, choć konfiguracja iTextPdf wymaga większego nakładu pracy.

Czy obie biblioteki mogą konwertować pliki DOCX do formatu PDF?

W niektórych projektach konieczna jest konwersja plików DOCX do formatu PDF. Poniżej znajduje się porównanie sposobu, w jaki IronPDF i iTextPdf radzą sobie z tym zadaniem, z podkreśleniem różnic między nimi. IronPDF oferuje natywną konwersję plików DOCX do formatu PDF oraz obsługę innych formatów, w tym dokumentów RTF.

IronPDF

using IronPdf;

// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();

// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");

// Advanced rendering with options
renderer.RenderingOptions.MarginTop = 50;
renderer.RenderingOptions.MarginBottom = 50;

// Handle mail merge
var mergeFields = new Dictionary<string, string>
{
    ["Name"] = "John Doe",
    ["Date"] = DateTime.Now.ToShortDateString()
};
PdfDocument mergedPdf = renderer.RenderDocxAsPdf("template.docx", mergeFields);

// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
using IronPdf;

// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();

// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");

// Advanced rendering with options
renderer.RenderingOptions.MarginTop = 50;
renderer.RenderingOptions.MarginBottom = 50;

// Handle mail merge
var mergeFields = new Dictionary<string, string>
{
    ["Name"] = "John Doe",
    ["Date"] = DateTime.Now.ToShortDateString()
};
PdfDocument mergedPdf = renderer.RenderDocxAsPdf("template.docx", mergeFields);

// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
Imports IronPdf

' Instantiate Renderer
Dim renderer As New DocxToPdfRenderer()

' Render from DOCX file
Dim pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")

' Advanced rendering with options
renderer.RenderingOptions.MarginTop = 50
renderer.RenderingOptions.MarginBottom = 50

' Handle mail merge
Dim mergeFields As New Dictionary(Of String, String) From {
    {"Name", "John Doe"},
    {"Date", DateTime.Now.ToShortDateString()}
}
Dim mergedPdf As PdfDocument = renderer.RenderDocxAsPdf("template.docx", mergeFields)

' Save the PDF
pdf.SaveAs("pdfFromDocx.pdf")
$vbLabelText   $csharpLabel

iTextPdf

W przeciwieństwie do IronPDF, iTextPdf nie posiada wbudowanej obsługi konwersji plików DOCX do formatu PDF. Aby wykonać tę konwersję, programiści muszą skorzystać z bibliotek innych firm, takich jak DocX lub Aspose.Words, aby najpierw przekonwertować plik DOCX do formatu zgodnego z PDF, a następnie przetworzyć lub zmodyfikować go za pomocą iTextPdf.

IronPDF zapewnia proste, wbudowane rozwiązanie do konwersji plików DOCX na PDF, eliminując potrzebę korzystania z dodatkowych bibliotek. Dzięki temu doskonale nadaje się dla programistów potrzebujących szybkiej, zintegrowanej konwersji. IronPDF obsługuje również konwersję RTF do PDF dla starszych formatów dokumentów, Markdown do PDF dla procesów dokumentacyjnych, XML do PDF dla danych strukturalnych oraz konwersję obrazów do PDF, w tym obsługę wielo-ramkowych plików TIFF. Aby usprawnić przetwarzanie dokumentów, zapoznaj się z funkcjami korespondencji seryjnej i generowania spisu treści. Natomiast iTextPdf opiera się na zewnętrznych bibliotekach do konwersji plików DOCX, co wymaga dodatkowej konfiguracji i zależności, co zwiększa złożoność projektu.

W jakim stopniu IronPDF i iTextPdf obsługują Bootstrap i nowoczesny CSS?

Podczas generowania plików PDF z aplikacji internetowych w stylu Bootstrap pełna obsługa frameworka zapewnia spójność projektu bez konieczności stosowania równoległych plików CSS lub modyfikacji układu. Zrozumienie podziałów stron w plikach HTML i PDF oraz kwestii związanych z responsywnym projektowaniem ma kluczowe znaczenie dla uzyskania profesjonalnego efektu końcowego. Aby uzyskać lepsze wyniki, należy używać typów mediów CSS i niestandardowych opóźnień renderowania.

Czy IronPDF obsługuje nowoczesne frameworki CSS?

IronPDF's Chromium engine provides complete support for:

  • Bootstrap 5: Full flexbox layouts, CSS Grid, utility classes, all components
  • Bootstrap 4: Complete card systems, navigation, flex utilities, responsive design
  • Tailwind CSS: All utility classes with browser-accurate rendering
  • Foundation: Complete grid system and component library
  • Modern CSS3: Flexbox, CSS Grid, custom properties, animations, transitions

Weryfikacja w praktyce: IronPDF renderuje stronę główną Bootstrap oraz wszystkie oficjalne przykłady z pikselową dokładnością, wykorzystując swoje responsywne możliwości CSS. Biblioteka obsługuje również niestandardowe rozmiary papieru i kontrolę okna wyświetlania w celu poprawy renderowania układu. W przypadku złożonych układów należy skorzystać z opcji renderowania i ustawień orientacji strony. Biblioteka obsługuje języki międzynarodowe i kodowanie UTF-8 dla aplikacji globalnych.

Jakie są ograniczenia CSS w iTextPdf?

iTextPDF uses pdfHTML with selective CSS3 support:

  • Limited flexbox support: Added in version 7.1.15 but incomplete
  • No CSS Grid: Grid-based Bootstrap layouts not supported
  • Bootstrap 3 limitations: Modern Bootstrap 4/5 components require workarounds
  • Manual layout conversion: Complex layouts often need PDF-specific code

iTextPdf's documentation explicitly states that advanced CSS features may not render as expected, requiring developers to test each Bootstrap component and often create simplified layouts.

Development impact: Teams must maintain separate layout code for PDF generation or extensively test and modify Bootstrap components, increasing development time and reducing design consistency.

For complete Bootstrap framework guidance and CSS3 rendering capabilities, see the Bootstrap & Flexbox CSS Guide. Additional resources include pixel-perfect formatting tips, font management, and font kerning solutions for consistent typography. For web applications, explore ASPX to PDF conversion and Angular.js PDF generation capabilities.

What Do the Code Examples Tell Us About IronPDF vs. iTextPdf?

Feature comparison table between IronPDF and iTextPDF libraries showing capabilities for PDF manipulation including HTML conversion, encryption, redaction, signatures, watermarks, stamping, and DOCX support.

For more detailed examples, visit IronPDF Examples or explore the code examples library. The demos section provides interactive examples of IronPDF's capabilities. Additional resources include parallel PDF generation, multi-threaded processing, and async examples for high-performance applications.

How Do IronPDF and iTextPdf Compare on Pricing and Licensing?

What Are IronPDF's Pricing Options?

IronPDF offers different levels and additional features for purchasing licenses. Developers can also buy the Iron Suite, which gives access to all Iron Software products at the price of two. If you're not ready to buy a license, IronPDF provides a free trial with full features for evaluation. The licensing page provides complete details on available options. For enterprise deployments, explore license key management and setting license keys programmatically.

  • Perpetual licenses: Offers a range of perpetual licenses depending on the size of your team, your project needs, and the number of locations. Each license type comes with email support.
  • Lite License: This license costs $799 and supports one developer, one location, and one project.
  • Plus License: Supporting three developers, three locations, and three projects, this is the next step up from the lite license and costs $1,199. The Plus license offers chat support and phone support in addition to basic email support.
  • Professional License: This license is suitable for larger teams, supporting ten developers, ten locations, and ten projects for $2,399. It offers the same contact support channels as the previous tiers but also offers screen-sharing support.
  • Royalty-free redistribution: IronPDF's licensing also offers royalty-free redistribution coverage for an extra $2,399.
  • Uninterrupted product support: IronPDF offers access to ongoing product updates, security feature upgrades, and support from their engineering team for either $999/year or a one-time purchase of $1,999 for a 5-year coverage.
  • Iron Suite: For $1,498, you get access to all Iron Software products including IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint, and IronWebScraper.

IronPDF pricing comparison showing three perpetual license tiers (Lite, Plus, Professional) ranging from $749-$2,999, with a bundle promotion for Iron Suite offering 9 products for the price of 2

How Does iTextPdf Handle Licensing?

  • AGPL License: The iTextPDF Core library is open source under the AGPL license, which is free to use under conditions. Developers must release any modifications under the same license.
  • Commercial License: For developers not meeting AGPL conditions, iTextPDF offers commercial licensing through a quote-based model.

For licensing upgrades and transitions, visit IronPDF licensing upgrades. The license key application guide helps with implementation, and license key configuration provides deployment options. For troubleshooting licensing issues, see unable to connect to licensing server and licensing extensions.

What Documentation and Support Do IronPDF and iTextPdf Offer?

  • Comprehensive Documentation: Extensive and user-friendly documentation covering all the features it has to offer.
  • 24/5 Support: Active engineer support is available.
  • Video Tutorials: Step-by-step video guides are available on YouTube.
  • Community Forum: Engaged community for additional support.
  • Regular Updates: Monthly product updates to ensure the latest features and security patches.

  • Complete Documentation: Extensive, user-friendly documentation covering all features
  • 24/5 Support: Active engineering support available
  • Video Tutorials: Step-by-step video guides on YouTube
  • Community Forum: Engaged community for additional support through Stack Overflow and GitHub
  • Regular Updates: Monthly product updates ensure latest features and security patches
  • Code Examples: Extensive code example library with practical implementations
  • Troubleshooting Guides: Detailed guides for quick troubleshooting and platform-specific issues

For detailed troubleshooting, IronPDF provides guides for common issues like AWS deployment, Azure configuration, memory management, Docker integration, IIS setup, and performance optimization. Platform-specific guides cover Windows deployment, Linux configuration, and macOS support. Additional resources include engineering request guidance, Azure log management, AWS log files, and security CVE information.

  • Documentation: The iText PDF documentation thoroughly covers available features.
  • Examples and Tutorials: Code examples and tutorials help developers get started.
  • GitHub Community: Developers can report issues, submit pull requests, and interact with the iTextPDF team.
  • Regular Updates: iTextPDF provides frequent updates and improvements.

For more details on IronPDF documentation and support, visit IronPDF Documentation and the IronSoftware YouTube Channel. Explore how-to guides for specific features, API reference for detailed implementation, and tutorials for complete learning. The VB.NET PDF tutorial and F# PDF library guide provide language-specific resources. For modern application frameworks, explore Blazor tutorial, MAUI PDF viewing, and XAML to PDF conversion.## Which PDF Library Should Senior .NET Developers Choose?

In the field of PDF manipulation tools for .NET, both IronPDF and iTextPdf offer valuable solutions for developers. IronPDF is notable for its straightforward integration across .NET platforms and user-friendly features like DOCX to PDF conversion without external dependencies. For advanced rendering needs, IronPDF supports JavaScript execution, WebGL support, and custom render delays for dynamic content. The library also includes JavaScript message listeners and custom JavaScript execution for interactive PDFs. For handling complex rendering scenarios, explore network idle waiting, render delay configuration, and initial render optimization. In contrast, iTextPdf is known for its versatility and rich features, remaining effective, especially when combined with other tools, though it requires additional dependencies for DOCX conversion.

For performance improvements, IronPDF offers async processing, parallel generation, and multi-threading support to efficiently handle high-volume PDF operations. The library also provides advanced features like PDF compression, linearization for fast web viewing, and PDF/A compliance for archival requirements. Additional enterprise features include PDF/A-3 with ZUGFeRD support for e-invoicing, PDF/UA compliance for accessibility, and PDF version control. For cloud deployments, IronPDF offers remote engine options, Docker container support, and a native vs remote engine comparison.

Ultimately, choosing between IronPDF and iTextPdf depends on the project's specific needs, licensing preferences, and required support level. Both libraries provide reliable ways to simplify PDF workflows in .NET applications. For developers prioritizing modern web standards and ease of use, IronPDF's Chrome-based rendering and complete API make it an excellent choice. The library's creating PDFs, converting PDFs, and organizing PDFs tutorials provide thorough guidance. For specialized document handling, explore PDF reports generation, reading PDF text, and PDF to HTML conversion. Additional capabilities include paper printing, network printer support, rasterization to images, and Base64 conversion. Those requiring AGPL licensing or extensive low-level PDF manipulation might find iTextPdf more suitable.

For further comparison with other PDF libraries, explore Aspose vs IronPDF, Apryse vs IronPDF, QuestPDF vs IronPDF, and Syncfusion vs IronPDF to make an informed decision for your PDF development needs. For deployment guidance, review IronPDF installer options, software installer integration, and deployment best practices. The library's milestones highlight ongoing improvements, including Chrome rendering enhancements, compatibility updates, PDFium DOM updates, and stability improvements.

Zwróć uwagęiTextPdf is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by iTextPdf. 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 funkcje oferuje IronPDF do tworzenia i manipulacji PDF-ami?

IronPDF oferuje takie funkcje jak konwersja HTML do PDF, scalanie PDF, szyfrowanie, podpisy cyfrowe, znak wodny i konwersja DOCX do PDF.

Jak IronPDF ułatwia podpisywanie PDF-ów?

IronPDF pozwala stosować podpisy cyfrowe do plików PDF za pomocą certyfikatów X509, oferując prostą metodę ochrony dokumentów.

Czy IronPDF może być używany na różnych systemach operacyjnych?

Tak, IronPDF wspiera zgodność międzyplatformową. Działa bez problemu na Windows, Linux i Mac, a także jest kompatybilny z .NET Core, .NET Standard i .NET Framework.

Jak iTextPDF różni się od IronPDF pod względem szyfrowania dokumentów?

Podczas gdy iTextPDF oferuje szczegółowe ustawienia dla standardów szyfrowania, IronPDF upraszcza proces dzięki wbudowanym metodom szyfrowania łatwym do wdrożenia.

Jakie zasoby wsparcia są dostępne dla użytkowników IronPDF?

IronPDF oferuje rozbudowane wsparcie przez obszerne dokumentacje, samouczki wideo, forum społecznościowe i wsparcie inżynierskie 24/5.

Jak IronPDF obsługuje konwersję DOCX do PDF?

IronPDF zawiera natywne możliwości konwersji DOCX do PDF, umożliwiając płynne wdrażanie bez potrzeby dodatkowych bibliotek.

Jakie opcje licencyjne są dostępne dla IronPDF?

IronPDF oferuje licencje wieczyste z różnymi poziomami, takimi jak Lite, Plus i Professional, wraz z opcjami redystrybucji bez opłat licencyjnych i nadal wsparciem produktu.

Jak mogę zastosować znaki wodne do PDF-ów używając IronPDF?

IronPDF pozwala łatwo stosować znaki wodne za pomocą HTML i CSS, umożliwiając szybkie dodanie tekstu lub obrazów jako znaki wodne i dostosowanie ich w razie potrzeby.

Co sprawia, że IronPDF jest odpowiedni dla deweloperów pracujących z aplikacjami .NET?

IronPDF jest zaprojektowany jako przyjazny dla użytkownika z uproszczonym API, co sprawia, że jest efektywny do zadań takich jak konwersja HTML do PDF, szyfrowanie i podpisywanie cyfrowe, idealny dla programistów .NET.

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
iText Logo

Zmęczony drogimi odnowieniami i przestarzałymi aktualizacjami produktów?

Dokonaj łatwego przejścia z iText z naszym wsparciem inżynierskim na rzecz migracji i lepszego dealu.

IronPDF Logo

Zespol wsparcia Iron

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