Skip to footer content
MIGRATION GUIDES

How to Migrate from Apryse PDF to IronPDF in C#

Apryse PDF (formerly PDFTron) is a premium enterprise PDF SDK known for its comprehensive document processing capabilities. However, its premium pricing model ($1,500+ per developer annually), complex integration requirements, and C++ heritage create barriers for development teams seeking straightforward PDF functionality. This comprehensive guide provides a step-by-step migration path from Apryse PDF to IronPDF—a native .NET PDF library with modern C# conventions, simpler integration, and one-time perpetual licensing.

Why Migrate Away from Apryse PDF?

While Apryse PDF delivers robust functionality, several factors drive development teams to seek alternatives for their PDF generation needs.

Premium Pricing and Subscription Model

Apryse PDF targets enterprise customers with pricing that can be prohibitive for small to medium-sized projects:

Aspect Apryse PDF (PDFTron) IronPDF
Starting Price $1,500+/developer/year (reported) $749 one-time (Lite)
License Model Annual subscription Perpetual license
Viewer License Separate, additional cost N/A (use standard viewers)
Server License Enterprise pricing required Included in license tiers
Total 3-Year Cost $4,500+ per developer $749 one-time

Complexity of Integration

Apryse PDF's C++ heritage introduces complexity that impacts development velocity:

Feature Apryse PDF IronPDF
Setup Module paths, external binaries Single NuGet package
Initialization PDFNet.Initialize() with license Simple property assignment
HTML Rendering External html2pdf module required Built-in Chromium engine
API Style C++ heritage, complex Modern C# conventions
Dependencies Multiple DLLs, platform-specific Self-contained package

When to Consider Migration

Migrate to IronPDF if:

  • You primarily need HTML/URL to PDF conversion
  • You want simpler API with less boilerplate
  • Premium pricing isn't justified for your use case
  • You don't need PDFViewCtrl viewer controls
  • You prefer one-time licensing over subscriptions

Stay with Apryse PDF if:

  • You need their native viewer controls (PDFViewCtrl)
  • You use XOD or proprietary formats extensively
  • You require specific enterprise features (advanced redaction, etc.)
  • Your organization already has enterprise licenses

Pre-Migration Preparation

Prerequisites

Ensure your environment meets these requirements:

  • .NET Framework 4.6.2+ or .NET Core 3.1 / .NET 5-9
  • Visual Studio 2019+ or VS Code with C# extension
  • NuGet Package Manager access
  • IronPDF license key (free trial available at ironpdf.com)

Audit Apryse PDF Usage

Run these commands in your solution directory to identify all Apryse references:

# Find all pdftron using statements
grep -r "using pdftron" --include="*.cs" .

# Find PDFNet initialization
grep -r "PDFNet.Initialize\|PDFNet.SetResourcesPath" --include="*.cs" .

# Find PDFDoc usage
grep -r "new PDFDoc\|PDFDoc\." --include="*.cs" .

# Find HTML2PDF usage
grep -r "HTML2PDF\|InsertFromURL\|InsertFromHtmlString" --include="*.cs" .

# Find ElementReader/Writer usage
grep -r "ElementReader\|ElementWriter\|ElementBuilder" --include="*.cs" .
# Find all pdftron using statements
grep -r "using pdftron" --include="*.cs" .

# Find PDFNet initialization
grep -r "PDFNet.Initialize\|PDFNet.SetResourcesPath" --include="*.cs" .

# Find PDFDoc usage
grep -r "new PDFDoc\|PDFDoc\." --include="*.cs" .

# Find HTML2PDF usage
grep -r "HTML2PDF\|InsertFromURL\|InsertFromHtmlString" --include="*.cs" .

# Find ElementReader/Writer usage
grep -r "ElementReader\|ElementWriter\|ElementBuilder" --include="*.cs" .
SHELL

Breaking Changes to Anticipate

Apryse PDF Pattern Change Required
PDFNet.Initialize() Replace with IronPdf.License.LicenseKey
HTML2PDF module Built-in ChromePdfRenderer
ElementReader/ElementWriter IronPDF handles content internally
SDFDoc.SaveOptions Simple SaveAs() method
PDFViewCtrl Use external PDF viewers
XOD format Convert to PDF or images
Module path configuration Not needed

Step-by-Step Migration Process

Step 1: Update NuGet Packages

Remove Apryse/PDFTron packages and install IronPDF:

# Remove Apryse/PDFTron packages
dotnet remove package PDFTron.NET.x64
dotnet remove package PDFTron.NET.x86
dotnet remove package pdftron

# Install IronPDF
dotnet add package IronPdf
# Remove Apryse/PDFTron packages
dotnet remove package PDFTron.NET.x64
dotnet remove package PDFTron.NET.x86
dotnet remove package pdftron

# Install IronPDF
dotnet add package IronPdf
SHELL

Or via Package Manager Console:

Uninstall-Package PDFTron.NET.x64
Install-Package IronPdf

Step 2: Update Namespace References

Replace Apryse namespaces with IronPDF:

// Remove these
using pdftron;
using pdftron.PDF;
using pdftron.PDF.Convert;
using pdftron.SDF;
using pdftron.Filters;

// Add these
using IronPdf;
using IronPdf.Rendering;
// Remove these
using pdftron;
using pdftron.PDF;
using pdftron.PDF.Convert;
using pdftron.SDF;
using pdftron.Filters;

// Add these
using IronPdf;
using IronPdf.Rendering;
Imports IronPdf
Imports IronPdf.Rendering
$vbLabelText   $csharpLabel

Step 3: Remove Initialization Boilerplate

Apryse PDF requires complex initialization. IronPDF eliminates this entirely.

Apryse PDF Implementation:

// Complex initialization
PDFNet.Initialize("YOUR_LICENSE_KEY");
PDFNet.SetResourcesPath("path/to/resources");
// Plus module path for HTML2PDF...
// Complex initialization
PDFNet.Initialize("YOUR_LICENSE_KEY");
PDFNet.SetResourcesPath("path/to/resources");
// Plus module path for HTML2PDF...
' Complex initialization
PDFNet.Initialize("YOUR_LICENSE_KEY")
PDFNet.SetResourcesPath("path/to/resources")
' Plus module path for HTML2PDF...
$vbLabelText   $csharpLabel

IronPDF Implementation:

// Simple license assignment (optional for development)
IronPdf.License.LicenseKey = "YOUR_LICENSE_KEY";
// Simple license assignment (optional for development)
IronPdf.License.LicenseKey = "YOUR_LICENSE_KEY";
' Simple license assignment (optional for development)
IronPdf.License.LicenseKey = "YOUR_LICENSE_KEY"
$vbLabelText   $csharpLabel

No PDFNet.Terminate() call is needed with IronPDF—resources are managed automatically.

Complete API Migration Reference

Core Class Mapping

Apryse PDF Class IronPDF Equivalent
PDFDoc PdfDocument
HTML2PDF ChromePdfRenderer
TextExtractor PdfDocument.ExtractAllText()
Stamper PdfDocument.ApplyWatermark()
PDFDraw PdfDocument.ToBitmap()
SecurityHandler PdfDocument.SecuritySettings
PDFNet IronPdf.License

Document Operations

Apryse PDF Method IronPDF Method
new PDFDoc() new PdfDocument()
new PDFDoc(path) PdfDocument.FromFile(path)
new PDFDoc(buffer) PdfDocument.FromBinaryData(bytes)
doc.Save(path, options) pdf.SaveAs(path)
doc.Save(buffer) pdf.BinaryData
doc.Close() pdf.Dispose()
doc.GetPageCount() pdf.PageCount
doc.AppendPages(doc2, start, end) PdfDocument.Merge(pdfs)

HTML to PDF Conversion

Apryse PDF Method IronPDF Method
HTML2PDF.Convert(doc) renderer.RenderHtmlAsPdf(html)
converter.InsertFromURL(url) renderer.RenderUrlAsPdf(url)
converter.InsertFromHtmlString(html) renderer.RenderHtmlAsPdf(html)
converter.SetModulePath(path) Not needed
converter.SetPaperSize(width, height) RenderingOptions.PaperSize
converter.SetLandscape(true) RenderingOptions.PaperOrientation

Code Migration Examples

HTML String to PDF

The most common operation demonstrates the dramatic reduction in boilerplate code.

Apryse PDF Implementation:

using pdftron;
using pdftron.PDF;

class Program
{
    static void Main()
    {
        PDFNet.Initialize("YOUR_LICENSE_KEY");
        PDFNet.SetResourcesPath("path/to/resources");

        string html = "<html><body><h1>Hello World</h1><p>Content here</p></body></html>";

        using (PDFDoc doc = new PDFDoc())
        {
            HTML2PDF converter = new HTML2PDF();
            converter.SetModulePath("path/to/html2pdf");
            converter.InsertFromHtmlString(html);

            HTML2PDF.WebPageSettings settings = new HTML2PDF.WebPageSettings();
            settings.SetPrintBackground(true);
            settings.SetLoadImages(true);

            if (converter.Convert(doc))
            {
                doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
                Console.WriteLine("PDF created successfully");
            }
            else
            {
                Console.WriteLine($"Conversion failed: {converter.GetLog()}");
            }
        }

        PDFNet.Terminate();
    }
}
using pdftron;
using pdftron.PDF;

class Program
{
    static void Main()
    {
        PDFNet.Initialize("YOUR_LICENSE_KEY");
        PDFNet.SetResourcesPath("path/to/resources");

        string html = "<html><body><h1>Hello World</h1><p>Content here</p></body></html>";

        using (PDFDoc doc = new PDFDoc())
        {
            HTML2PDF converter = new HTML2PDF();
            converter.SetModulePath("path/to/html2pdf");
            converter.InsertFromHtmlString(html);

            HTML2PDF.WebPageSettings settings = new HTML2PDF.WebPageSettings();
            settings.SetPrintBackground(true);
            settings.SetLoadImages(true);

            if (converter.Convert(doc))
            {
                doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized);
                Console.WriteLine("PDF created successfully");
            }
            else
            {
                Console.WriteLine($"Conversion failed: {converter.GetLog()}");
            }
        }

        PDFNet.Terminate();
    }
}
Imports pdftron
Imports pdftron.PDF

Class Program
    Shared Sub Main()
        PDFNet.Initialize("YOUR_LICENSE_KEY")
        PDFNet.SetResourcesPath("path/to/resources")

        Dim html As String = "<html><body><h1>Hello World</h1><p>Content here</p></body></html>"

        Using doc As New PDFDoc()
            Dim converter As New HTML2PDF()
            converter.SetModulePath("path/to/html2pdf")
            converter.InsertFromHtmlString(html)

            Dim settings As New HTML2PDF.WebPageSettings()
            settings.SetPrintBackground(True)
            settings.SetLoadImages(True)

            If converter.Convert(doc) Then
                doc.Save("output.pdf", SDFDoc.SaveOptions.e_linearized)
                Console.WriteLine("PDF created successfully")
            Else
                Console.WriteLine($"Conversion failed: {converter.GetLog()}")
            End If
        End Using

        PDFNet.Terminate()
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF Implementation:

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string html = "<html><body><h1>Hello World</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);

        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string html = "<html><body><h1>Hello World</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);

        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()

        Dim html As String = "<html><body><h1>Hello World</h1></body></html>"
        Dim pdf = renderer.RenderHtmlAsPdf(html)

        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF eliminates initialization, module paths, and cleanup code—reducing 35+ lines to 5 lines.

URL to PDF Conversion

Apryse PDF Implementation:

using pdftron;
using pdftron.PDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc doc = new PDFDoc())
{
    HTML2PDF converter = new HTML2PDF();
    converter.SetModulePath("path/to/html2pdf");

    HTML2PDF.WebPageSettings settings = new HTML2PDF.WebPageSettings();
    settings.SetLoadImages(true);
    settings.SetAllowJavaScript(true);
    settings.SetPrintBackground(true);

    converter.InsertFromURL("https://example.com", settings);

    if (converter.Convert(doc))
    {
        doc.Save("webpage.pdf", SDFDoc.SaveOptions.e_linearized);
    }
}

PDFNet.Terminate();
using pdftron;
using pdftron.PDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc doc = new PDFDoc())
{
    HTML2PDF converter = new HTML2PDF();
    converter.SetModulePath("path/to/html2pdf");

    HTML2PDF.WebPageSettings settings = new HTML2PDF.WebPageSettings();
    settings.SetLoadImages(true);
    settings.SetAllowJavaScript(true);
    settings.SetPrintBackground(true);

    converter.InsertFromURL("https://example.com", settings);

    if (converter.Convert(doc))
    {
        doc.Save("webpage.pdf", SDFDoc.SaveOptions.e_linearized);
    }
}

PDFNet.Terminate();
Imports pdftron
Imports pdftron.PDF

PDFNet.Initialize("YOUR_LICENSE_KEY")

Using doc As New PDFDoc()
    Dim converter As New HTML2PDF()
    converter.SetModulePath("path/to/html2pdf")

    Dim settings As New HTML2PDF.WebPageSettings()
    settings.SetLoadImages(True)
    settings.SetAllowJavaScript(True)
    settings.SetPrintBackground(True)

    converter.InsertFromURL("https://example.com", settings)

    If converter.Convert(doc) Then
        doc.Save("webpage.pdf", SDFDoc.SaveOptions.e_linearized)
    End If
End Using

PDFNet.Terminate()
$vbLabelText   $csharpLabel

IronPDF Implementation:

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string url = "https://www.example.com";
        var pdf = renderer.RenderUrlAsPdf(url);

        pdf.SaveAs("webpage.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string url = "https://www.example.com";
        var pdf = renderer.RenderUrlAsPdf(url);

        pdf.SaveAs("webpage.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()

        Dim url As String = "https://www.example.com"
        Dim pdf = renderer.RenderUrlAsPdf(url)

        pdf.SaveAs("webpage.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

Merging Multiple PDFs

Apryse PDF Implementation:

using pdftron;
using pdftron.PDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc mainDoc = new PDFDoc())
{
    string[] files = { "doc1.pdf", "doc2.pdf", "doc3.pdf" };

    foreach (string file in files)
    {
        using (PDFDoc doc = new PDFDoc(file))
        {
            mainDoc.AppendPages(doc, 1, doc.GetPageCount());
        }
    }

    mainDoc.Save("merged.pdf", SDFDoc.SaveOptions.e_linearized);
}

PDFNet.Terminate();
using pdftron;
using pdftron.PDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc mainDoc = new PDFDoc())
{
    string[] files = { "doc1.pdf", "doc2.pdf", "doc3.pdf" };

    foreach (string file in files)
    {
        using (PDFDoc doc = new PDFDoc(file))
        {
            mainDoc.AppendPages(doc, 1, doc.GetPageCount());
        }
    }

    mainDoc.Save("merged.pdf", SDFDoc.SaveOptions.e_linearized);
}

PDFNet.Terminate();
Imports pdftron
Imports pdftron.PDF

PDFNet.Initialize("YOUR_LICENSE_KEY")

Using mainDoc As New PDFDoc()
    Dim files As String() = {"doc1.pdf", "doc2.pdf", "doc3.pdf"}

    For Each file As String In files
        Using doc As New PDFDoc(file)
            mainDoc.AppendPages(doc, 1, doc.GetPageCount())
        End Using
    Next

    mainDoc.Save("merged.pdf", SDFDoc.SaveOptions.e_linearized)
End Using

PDFNet.Terminate()
$vbLabelText   $csharpLabel

IronPDF Implementation:

// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdf1 = PdfDocument.FromFile("document1.pdf");
        var pdf2 = PdfDocument.FromFile("document2.pdf");

        var merged = PdfDocument.Merge(new List<PdfDocument> { pdf1, pdf2 });

        merged.SaveAs("merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdf1 = PdfDocument.FromFile("document1.pdf");
        var pdf2 = PdfDocument.FromFile("document2.pdf");

        var merged = PdfDocument.Merge(new List<PdfDocument> { pdf1, pdf2 });

        merged.SaveAs("merged.pdf");
    }
}
Imports IronPdf
Imports System.Collections.Generic

Class Program
    Shared Sub Main()
        Dim pdf1 = PdfDocument.FromFile("document1.pdf")
        Dim pdf2 = PdfDocument.FromFile("document2.pdf")

        Dim merged = PdfDocument.Merge(New List(Of PdfDocument) From {pdf1, pdf2})

        merged.SaveAs("merged.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF's static Merge method accepts multiple documents directly, eliminating the page iteration pattern.

Text Extraction

Apryse PDF Implementation:

using pdftron;
using pdftron.PDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc doc = new PDFDoc("document.pdf"))
{
    TextExtractor extractor = new TextExtractor();

    for (int i = 1; i <= doc.GetPageCount(); i++)
    {
        Page page = doc.GetPage(i);
        extractor.Begin(page);

        string pageText = extractor.GetAsText();
        Console.WriteLine($"Page {i}:");
        Console.WriteLine(pageText);
    }
}

PDFNet.Terminate();
using pdftron;
using pdftron.PDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc doc = new PDFDoc("document.pdf"))
{
    TextExtractor extractor = new TextExtractor();

    for (int i = 1; i <= doc.GetPageCount(); i++)
    {
        Page page = doc.GetPage(i);
        extractor.Begin(page);

        string pageText = extractor.GetAsText();
        Console.WriteLine($"Page {i}:");
        Console.WriteLine(pageText);
    }
}

PDFNet.Terminate();
Imports pdftron
Imports pdftron.PDF

PDFNet.Initialize("YOUR_LICENSE_KEY")

Using doc As New PDFDoc("document.pdf")
    Dim extractor As New TextExtractor()

    For i As Integer = 1 To doc.GetPageCount()
        Dim page As Page = doc.GetPage(i)
        extractor.Begin(page)

        Dim pageText As String = extractor.GetAsText()
        Console.WriteLine($"Page {i}:")
        Console.WriteLine(pageText)
    Next
End Using

PDFNet.Terminate()
$vbLabelText   $csharpLabel

IronPDF Implementation:

using IronPdf;

var pdf = PdfDocument.FromFile("document.pdf");

// Extract all text at once
string allText = pdf.ExtractAllText();
Console.WriteLine(allText);

// Extract from specific page
string page1Text = pdf.ExtractTextFromPage(0); // 0-indexed
Console.WriteLine($"Page 1: {page1Text}");
using IronPdf;

var pdf = PdfDocument.FromFile("document.pdf");

// Extract all text at once
string allText = pdf.ExtractAllText();
Console.WriteLine(allText);

// Extract from specific page
string page1Text = pdf.ExtractTextFromPage(0); // 0-indexed
Console.WriteLine($"Page 1: {page1Text}");
Imports IronPdf

Dim pdf = PdfDocument.FromFile("document.pdf")

' Extract all text at once
Dim allText As String = pdf.ExtractAllText()
Console.WriteLine(allText)

' Extract from specific page
Dim page1Text As String = pdf.ExtractTextFromPage(0) ' 0-indexed
Console.WriteLine($"Page 1: {page1Text}")
$vbLabelText   $csharpLabel

Adding Watermarks

Apryse PDF Implementation:

using pdftron;
using pdftron.PDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc doc = new PDFDoc("document.pdf"))
{
    Stamper stamper = new Stamper(Stamper.SizeType.e_relative_scale, 0.5, 0.5);
    stamper.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_center,
                         Stamper.VerticalAlignment.e_vertical_center);
    stamper.SetOpacity(0.3);
    stamper.SetRotation(45);
    stamper.SetFontColor(new ColorPt(1, 0, 0));
    stamper.SetTextAlignment(Stamper.TextAlignment.e_align_center);

    stamper.StampText(doc, "CONFIDENTIAL",
        new PageSet(1, doc.GetPageCount()));

    doc.Save("watermarked.pdf", SDFDoc.SaveOptions.e_linearized);
}

PDFNet.Terminate();
using pdftron;
using pdftron.PDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc doc = new PDFDoc("document.pdf"))
{
    Stamper stamper = new Stamper(Stamper.SizeType.e_relative_scale, 0.5, 0.5);
    stamper.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_center,
                         Stamper.VerticalAlignment.e_vertical_center);
    stamper.SetOpacity(0.3);
    stamper.SetRotation(45);
    stamper.SetFontColor(new ColorPt(1, 0, 0));
    stamper.SetTextAlignment(Stamper.TextAlignment.e_align_center);

    stamper.StampText(doc, "CONFIDENTIAL",
        new PageSet(1, doc.GetPageCount()));

    doc.Save("watermarked.pdf", SDFDoc.SaveOptions.e_linearized);
}

PDFNet.Terminate();
Imports pdftron
Imports pdftron.PDF

PDFNet.Initialize("YOUR_LICENSE_KEY")

Using doc As New PDFDoc("document.pdf")
    Dim stamper As New Stamper(Stamper.SizeType.e_relative_scale, 0.5, 0.5)
    stamper.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_center, Stamper.VerticalAlignment.e_vertical_center)
    stamper.SetOpacity(0.3)
    stamper.SetRotation(45)
    stamper.SetFontColor(New ColorPt(1, 0, 0))
    stamper.SetTextAlignment(Stamper.TextAlignment.e_align_center)

    stamper.StampText(doc, "CONFIDENTIAL", New PageSet(1, doc.GetPageCount()))

    doc.Save("watermarked.pdf", SDFDoc.SaveOptions.e_linearized)
End Using

PDFNet.Terminate()
$vbLabelText   $csharpLabel

IronPDF Implementation:

using IronPdf;
using IronPdf.Editing;

var pdf = PdfDocument.FromFile("document.pdf");

// HTML-based watermark with full styling control
string watermarkHtml = @"
<div style='
    color: red;
    opacity: 0.3;
    font-size: 72px;
    font-weight: bold;
    text-align: center;
'>CONFIDENTIAL</div>";

pdf.ApplyWatermark(watermarkHtml,
    rotation: 45,
    verticalAlignment: VerticalAlignment.Middle,
    horizontalAlignment: HorizontalAlignment.Center);

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

var pdf = PdfDocument.FromFile("document.pdf");

// HTML-based watermark with full styling control
string watermarkHtml = @"
<div style='
    color: red;
    opacity: 0.3;
    font-size: 72px;
    font-weight: bold;
    text-align: center;
'>CONFIDENTIAL</div>";

pdf.ApplyWatermark(watermarkHtml,
    rotation: 45,
    verticalAlignment: VerticalAlignment.Middle,
    horizontalAlignment: HorizontalAlignment.Center);

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

Dim pdf = PdfDocument.FromFile("document.pdf")

' HTML-based watermark with full styling control
Dim watermarkHtml As String = "
<div style='
    color: red;
    opacity: 0.3;
    font-size: 72px;
    font-weight: bold;
    text-align: center;
'>CONFIDENTIAL</div>"

pdf.ApplyWatermark(watermarkHtml,
    rotation:=45,
    verticalAlignment:=VerticalAlignment.Middle,
    horizontalAlignment:=HorizontalAlignment.Center)

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

IronPDF uses HTML/CSS-based watermarking, providing full styling control through familiar web technologies.

Password Protection

Apryse PDF Implementation:

using pdftron;
using pdftron.PDF;
using pdftron.SDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc doc = new PDFDoc("document.pdf"))
{
    SecurityHandler handler = new SecurityHandler();
    handler.ChangeUserPassword("user123");
    handler.ChangeMasterPassword("owner456");

    handler.SetPermission(SecurityHandler.Permission.e_print, false);
    handler.SetPermission(SecurityHandler.Permission.e_extract_content, false);

    doc.SetSecurityHandler(handler);
    doc.Save("protected.pdf", SDFDoc.SaveOptions.e_linearized);
}

PDFNet.Terminate();
using pdftron;
using pdftron.PDF;
using pdftron.SDF;

PDFNet.Initialize("YOUR_LICENSE_KEY");

using (PDFDoc doc = new PDFDoc("document.pdf"))
{
    SecurityHandler handler = new SecurityHandler();
    handler.ChangeUserPassword("user123");
    handler.ChangeMasterPassword("owner456");

    handler.SetPermission(SecurityHandler.Permission.e_print, false);
    handler.SetPermission(SecurityHandler.Permission.e_extract_content, false);

    doc.SetSecurityHandler(handler);
    doc.Save("protected.pdf", SDFDoc.SaveOptions.e_linearized);
}

PDFNet.Terminate();
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF

PDFNet.Initialize("YOUR_LICENSE_KEY")

Using doc As New PDFDoc("document.pdf")
    Dim handler As New SecurityHandler()
    handler.ChangeUserPassword("user123")
    handler.ChangeMasterPassword("owner456")

    handler.SetPermission(SecurityHandler.Permission.e_print, False)
    handler.SetPermission(SecurityHandler.Permission.e_extract_content, False)

    doc.SetSecurityHandler(handler)
    doc.Save("protected.pdf", SDFDoc.SaveOptions.e_linearized)
End Using

PDFNet.Terminate()
$vbLabelText   $csharpLabel

IronPDF Implementation:

using IronPdf;

var pdf = PdfDocument.FromFile("document.pdf");

// Set passwords
pdf.SecuritySettings.UserPassword = "user123";
pdf.SecuritySettings.OwnerPassword = "owner456";

// Set permissions
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;

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

var pdf = PdfDocument.FromFile("document.pdf");

// Set passwords
pdf.SecuritySettings.UserPassword = "user123";
pdf.SecuritySettings.OwnerPassword = "owner456";

// Set permissions
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;

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

Dim pdf = PdfDocument.FromFile("document.pdf")

' Set passwords
pdf.SecuritySettings.UserPassword = "user123"
pdf.SecuritySettings.OwnerPassword = "owner456"

' Set permissions
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit

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

Headers and Footers

IronPDF Implementation:

using IronPdf;

var renderer = new ChromePdfRenderer();

renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter
{
    HtmlFragment = "<div style='text-align:center; font-size:12px;'>Company Header</div>",
    DrawDividerLine = true,
    MaxHeight = 30
};

renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
    HtmlFragment = "<div style='text-align:center; font-size:10px;'>Page {page} of {total-pages}</div>",
    DrawDividerLine = true,
    MaxHeight = 25
};

var pdf = renderer.RenderHtmlAsPdf("<h1>Content</h1>");
pdf.SaveAs("with_headers.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();

renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter
{
    HtmlFragment = "<div style='text-align:center; font-size:12px;'>Company Header</div>",
    DrawDividerLine = true,
    MaxHeight = 30
};

renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
    HtmlFragment = "<div style='text-align:center; font-size:10px;'>Page {page} of {total-pages}</div>",
    DrawDividerLine = true,
    MaxHeight = 25
};

var pdf = renderer.RenderHtmlAsPdf("<h1>Content</h1>");
pdf.SaveAs("with_headers.pdf");
Imports IronPdf

Dim renderer As New ChromePdfRenderer()

renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter With {
    .HtmlFragment = "<div style='text-align:center; font-size:12px;'>Company Header</div>",
    .DrawDividerLine = True,
    .MaxHeight = 30
}

renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter With {
    .HtmlFragment = "<div style='text-align:center; font-size:10px;'>Page {page} of {total-pages}</div>",
    .DrawDividerLine = True,
    .MaxHeight = 25
}

Dim pdf = renderer.RenderHtmlAsPdf("<h1>Content</h1>")
pdf.SaveAs("with_headers.pdf")
$vbLabelText   $csharpLabel

IronPDF supports placeholder tokens like {page} and {total-pages} for dynamic page numbering. For more options, see the headers and footers documentation.

ASP.NET Core Integration

Apryse PDF's initialization requirements complicate web application integration. IronPDF simplifies this pattern.

IronPDF Pattern:

[ApiController]
[Route("[controller]")]
public class PdfController : ControllerBase
{
    [HttpGet("generate")]
    public IActionResult GeneratePdf()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Report</h1>");

        return File(pdf.BinaryData, "application/pdf", "report.pdf");
    }

    [HttpGet("generate-async")]
    public async Task<IActionResult> GeneratePdfAsync()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = await renderer.RenderHtmlAsPdfAsync("<h1>Report</h1>");

        return File(pdf.Stream, "application/pdf", "report.pdf");
    }
}
[ApiController]
[Route("[controller]")]
public class PdfController : ControllerBase
{
    [HttpGet("generate")]
    public IActionResult GeneratePdf()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Report</h1>");

        return File(pdf.BinaryData, "application/pdf", "report.pdf");
    }

    [HttpGet("generate-async")]
    public async Task<IActionResult> GeneratePdfAsync()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = await renderer.RenderHtmlAsPdfAsync("<h1>Report</h1>");

        return File(pdf.Stream, "application/pdf", "report.pdf");
    }
}
Imports Microsoft.AspNetCore.Mvc

<ApiController>
<Route("[controller]")>
Public Class PdfController
    Inherits ControllerBase

    <HttpGet("generate")>
    Public Function GeneratePdf() As IActionResult
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf("<h1>Report</h1>")

        Return File(pdf.BinaryData, "application/pdf", "report.pdf")
    End Function

    <HttpGet("generate-async")>
    Public Async Function GeneratePdfAsync() As Task(Of IActionResult)
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = Await renderer.RenderHtmlAsPdfAsync("<h1>Report</h1>")

        Return File(pdf.Stream, "application/pdf", "report.pdf")
    End Function
End Class
$vbLabelText   $csharpLabel

Dependency Injection Configuration

// Program.cs
public void ConfigureServices(IServiceCollection services)
{
    // Set license once
    IronPdf.License.LicenseKey = Configuration["IronPdf:LicenseKey"];

    // Register renderer as scoped service
    services.AddScoped<ChromePdfRenderer>();

    // Or create a wrapper service
    services.AddScoped<IPdfService, IronPdfService>();
}

// IronPdfService.cs
public class IronPdfService : IPdfService
{
    private readonly ChromePdfRenderer _renderer;

    public IronPdfService()
    {
        _renderer = new ChromePdfRenderer();
        _renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        _renderer.RenderingOptions.PrintHtmlBackgrounds = true;
    }

    public PdfDocument GenerateFromHtml(string html) =>
        _renderer.RenderHtmlAsPdf(html);

    public Task<PdfDocument> GenerateFromHtmlAsync(string html) =>
        _renderer.RenderHtmlAsPdfAsync(html);
}
// Program.cs
public void ConfigureServices(IServiceCollection services)
{
    // Set license once
    IronPdf.License.LicenseKey = Configuration["IronPdf:LicenseKey"];

    // Register renderer as scoped service
    services.AddScoped<ChromePdfRenderer>();

    // Or create a wrapper service
    services.AddScoped<IPdfService, IronPdfService>();
}

// IronPdfService.cs
public class IronPdfService : IPdfService
{
    private readonly ChromePdfRenderer _renderer;

    public IronPdfService()
    {
        _renderer = new ChromePdfRenderer();
        _renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        _renderer.RenderingOptions.PrintHtmlBackgrounds = true;
    }

    public PdfDocument GenerateFromHtml(string html) =>
        _renderer.RenderHtmlAsPdf(html);

    public Task<PdfDocument> GenerateFromHtmlAsync(string html) =>
        _renderer.RenderHtmlAsPdfAsync(html);
}
' Program.vb
Public Sub ConfigureServices(services As IServiceCollection)
    ' Set license once
    IronPdf.License.LicenseKey = Configuration("IronPdf:LicenseKey")

    ' Register renderer as scoped service
    services.AddScoped(Of ChromePdfRenderer)()

    ' Or create a wrapper service
    services.AddScoped(Of IPdfService, IronPdfService)()
End Sub

' IronPdfService.vb
Public Class IronPdfService
    Implements IPdfService

    Private ReadOnly _renderer As ChromePdfRenderer

    Public Sub New()
        _renderer = New ChromePdfRenderer()
        _renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
        _renderer.RenderingOptions.PrintHtmlBackgrounds = True
    End Sub

    Public Function GenerateFromHtml(html As String) As PdfDocument Implements IPdfService.GenerateFromHtml
        Return _renderer.RenderHtmlAsPdf(html)
    End Function

    Public Function GenerateFromHtmlAsync(html As String) As Task(Of PdfDocument) Implements IPdfService.GenerateFromHtmlAsync
        Return _renderer.RenderHtmlAsPdfAsync(html)
    End Function
End Class
$vbLabelText   $csharpLabel

Performance Comparison

Metric Apryse PDF IronPDF
Cold start Fast (native code) ~2s (Chromium init)
Subsequent renders Fast Fast
Complex HTML Variable (html2pdf module) Excellent (Chromium)
CSS support Limited Full CSS3
JavaScript Limited Supported

Performance Optimization Tips

// 1. Reuse renderer instance
private static readonly ChromePdfRenderer SharedRenderer = new ChromePdfRenderer();

// 2. Disable unnecessary features for speed
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.EnableJavaScript = false; // If not needed
renderer.RenderingOptions.WaitFor.RenderDelay(0);   // No delay
renderer.RenderingOptions.Timeout = 30000;          // 30s max

// 3. Proper disposal
using (var pdf = renderer.RenderHtmlAsPdf(html))
{
    pdf.SaveAs("output.pdf");
}
// 1. Reuse renderer instance
private static readonly ChromePdfRenderer SharedRenderer = new ChromePdfRenderer();

// 2. Disable unnecessary features for speed
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.EnableJavaScript = false; // If not needed
renderer.RenderingOptions.WaitFor.RenderDelay(0);   // No delay
renderer.RenderingOptions.Timeout = 30000;          // 30s max

// 3. Proper disposal
using (var pdf = renderer.RenderHtmlAsPdf(html))
{
    pdf.SaveAs("output.pdf");
}
' 1. Reuse renderer instance
Private Shared ReadOnly SharedRenderer As New ChromePdfRenderer()

' 2. Disable unnecessary features for speed
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.EnableJavaScript = False ' If not needed
renderer.RenderingOptions.WaitFor.RenderDelay(0)   ' No delay
renderer.RenderingOptions.Timeout = 30000          ' 30s max

' 3. Proper disposal
Using pdf = renderer.RenderHtmlAsPdf(html)
    pdf.SaveAs("output.pdf")
End Using
$vbLabelText   $csharpLabel

Troubleshooting Common Migration Issues

Issue: Module Path Errors

Remove all module path configuration—IronPDF's Chromium engine is built-in:

// Remove this
converter.SetModulePath("path/to/html2pdf");

// Just use the renderer
var renderer = new ChromePdfRenderer();
// Remove this
converter.SetModulePath("path/to/html2pdf");

// Just use the renderer
var renderer = new ChromePdfRenderer();
$vbLabelText   $csharpLabel

Issue: PDFNet.Initialize() Not Found

Replace with IronPDF license setup:

// Remove this
PDFNet.Initialize("KEY");
PDFNet.SetResourcesPath("path");

// Use this (optional for development)
IronPdf.License.LicenseKey = "YOUR-KEY";
// Remove this
PDFNet.Initialize("KEY");
PDFNet.SetResourcesPath("path");

// Use this (optional for development)
IronPdf.License.LicenseKey = "YOUR-KEY";
' Remove this
PDFNet.Initialize("KEY")
PDFNet.SetResourcesPath("path")

' Use this (optional for development)
IronPdf.License.LicenseKey = "YOUR-KEY"
$vbLabelText   $csharpLabel

Issue: PDFViewCtrl Replacement

IronPDF doesn't include viewer controls. Options:

  • Use PDF.js for web viewers
  • Use system PDF viewers
  • Consider third-party viewer components

Post-Migration Checklist

After completing the code migration, verify the following:

  • Verify PDF output quality matches expectations
  • Test all edge cases (large documents, complex CSS)
  • Compare performance metrics
  • Update Docker configurations if applicable
  • Remove Apryse license and related configurations
  • Document any IronPDF-specific configurations
  • Train team on new API patterns
  • Update CI/CD pipelines if needed

Future-Proofing Your PDF Infrastructure

With .NET 10 on the horizon and C# 14 introducing new language features, choosing a native .NET PDF library with modern conventions ensures compatibility with evolving runtime capabilities. IronPDF's commitment to supporting the latest .NET versions means your migration investment pays dividends as projects extend into 2025 and 2026—without annual subscription renewals.

Additional Resources


Migrating from Apryse PDF to IronPDF transforms your PDF codebase from complex C++ patterns to idiomatic C#. The elimination of initialization boilerplate, module path configuration, and subscription-based licensing delivers immediate productivity gains while reducing long-term costs.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me