Passer au contenu du pied de page
GUIDES DE MIGRATION

Comment migrer d'Apryse PDF vers IronPDF en C#

Full Comparison

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

View Full Comparison

Apryse PDF (anciennement PDFTron) est un SDK PDF d'entreprise haut de gamme connu pour ses capacités complètes de traitement des documents. Cependant, son modèle de tarification premium (plus de 1 500 $ par développeur et par an), ses exigences d'intégration complexes et son héritage C++ créent des obstacles pour les équipes de développement qui recherchent des fonctionnalités PDF simples. Ce guide complet fournit un chemin de migration étape par étape d'Apryse PDF vers IronPDF- une bibliothèque PDF .NET native avec des conventions C# modernes, une intégration plus simple et une licence perpétuelle à usage unique.

Pourquoi migrer loin d'Apryse PDF?

Bien qu'Apryse PDF offre des fonctionnalités robustes, plusieurs facteurs poussent les équipes de développement à chercher des alternatives pour leurs besoins de génération de PDF.

Tarification premium et modèle d'abonnement

Apryse PDF s'adresse aux entreprises avec des tarifs qui peuvent être prohibitifs pour des projets de petite ou moyenne taille :

Aspect Apryse PDF(PDFTron) IronPDF
Prix de Départ 1 500 $+/développeur/an (déclaré) 749 $ en une seule fois (Lite)
Modèle de licence Abonnement annuel Licence perpétuelle
Licence de visualisation Coût supplémentaire séparé N/A (utiliser les visionneuses standard)
Licence serveur Tarification entreprise requise Inclus dans les niveaux de licence
Coût total sur 3 ans 4 500 $ et plus par développeur 749 $ (une seule fois)

Complexité de l'intégration

L'héritage C++ d'Apryse PDF introduit une complexité qui a un impact sur la vitesse de développement :

Fonction Apryse PDF IronPDF
Configuration Chemins d'accès aux modules, binaires externes Paquet NuGet unique
Initialisation PDFNet.Initialize() avec licence Attribution simple de propriétés
Rendu HTML Module html2pdf externe requis Moteur Chromium intégré
Style API Héritage du C++, complexe Conventions C# modernes
Dépendances Plusieurs DLL, spécifiques à une plate-forme Paquet autonome

Quand envisager la migration

Migrer vers IronPDF si :

  • Vous avez principalement besoin d'une conversion HTML/URL en PDF
  • Vous voulez une API plus simple avec moins de "boilerplate
  • Le prix premium n'est pas justifié pour votre cas d'utilisation
  • Vous n'avez pas besoin des contrôles de visualisation PDFViewCtrl
  • Vous préférez la licence unique aux abonnements

Rester avec Apryse PDFsi:

  • Vous avez besoin de leurs contrôles de visualisation natifs (PDFViewCtrl)
  • Vous utilisez beaucoup XOD ou des formats propriétaires
  • Vous avez besoin de fonctionnalités spécifiques à l'entreprise (rédaction avancée, etc.)
  • Votre organisation dispose déjà de licences d'entreprise

Préparation de la migration

Prérequis

Assurez-vous que votre environnement répond à ces exigences :

  • .NET Framework 4.6.2+ ou .NET Core 3.1 / .NET 5-9
  • Visual Studio 2019+ ou VS Code avec l'extension C#
  • Accès au Package Manager NuGet
  • Clé de licence IronPDF(essai gratuit disponible sur ironpdf.com)

Audit de l'utilisation du PDF Apryse

Exécutez ces commandes dans votre répertoire de solutions pour identifier toutes les références d'Apryse :

# 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

Modifications importantes à prévoir

Apryse PDFPattern Changements requis
PDFNet.Initialize() Remplacer par IronPdf.License.LicenseKey
HTML2PDF module Intégré ChromePdfRenderer
ElementWriter IronPDF gère le contenu en interne
SDFDoc.SaveOptions Méthode simple SaveAs()
PDFViewCtrl Utiliser des visionneuses PDF externes
Format XOD Convertir en PDF ou en images
Configuration du chemin d'accès au module Pas nécessaire

Processus de migration étape par étape

Étape 1 : Mise à jour des paquets NuGet

Supprimez les paquets Apryse/PDFTron et installez 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

Ou via la console du Package Manager :

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

Étape 2 : Mise à jour des références aux espaces de noms

Remplacer les espaces de noms Apryse par 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

Étape 3 : supprimer le modèle d'initialisation

Apryse PDF nécessite une initialisation complexe. IronPDF élimine totalement ce problème.

Mise en œuvre d'Apryse PDF:

// 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

Mise en œuvre d'IronPDF:

// 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

Aucun appel PDFNet.Terminate() n'est nécessaire avec IronPDF— les ressources sont gérées automatiquement.

Référence complète de migration des API

Mappage des classes de base

Apryse PDFClass Équivalent d'IronPDF
PDFDoc PdfDocument
HTML2PDF ChromePdfRenderer
TextExtractor PdfDocument.ExtractAllText()
Stamper PdfDocument.ApplyWatermark()
PDFDraw PdfDocument.ToBitmap()
SecurityHandler PdfDocument.SecuritySettings
PDFNet IronPdf.License

Opérations documentaires

Méthode Apryse PDF Méthode IronPDF
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)

Conversion HTML en PDF

Méthode Apryse PDF Méthode IronPDF
HTML2PDF.Convert(doc) renderer.RenderHtmlAsPdf(html)
converter.InsertFromURL(url) renderer.RenderUrlAsPdf(url)
converter.InsertFromHtmlString(html) renderer.RenderHtmlAsPdf(html)
converter.SetModulePath(path) Pas nécessaire
converter.SetPaperSize(width, height) RenderingOptions.PaperSize
converter.SetLandscape(true) RenderingOptions.PaperOrientation

Exemples de migration de code

Chaîne HTML convertie en PDF

L'opération la plus courante démontre la réduction considérable du code standard.

Mise en œuvre d'Apryse PDF:

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

Mise en œuvre d'IronPDF:

// 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 élimine l'initialisation, les chemins d'accès aux modules et le code de nettoyage, réduisant ainsi plus de 35 lignes à 5 lignes.

Conversion d'URL en PDF

Mise en œuvre d'Apryse PDF:

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

Mise en œuvre d'IronPDF:

// 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

Fusionner plusieurs fichiers PDF

Mise en œuvre d'Apryse PDF:

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

Mise en œuvre d'IronPDF:

// 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

La méthode statique Merge d'IronPDF accepte directement plusieurs documents, éliminant ainsi le modèle d'itération de page.

Extraction de texte

Mise en œuvre d'Apryse PDF:

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

Mise en œuvre d'IronPDF:

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

Ajouter des filigranes

Mise en œuvre d'Apryse PDF:

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

Mise en œuvre d'IronPDF:

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 utilise un filigrane basé sur HTML/CSS , offrant un contrôle total du style grâce à des technologies web familières.

Protection par mot de passe

Mise en œuvre d'Apryse PDF:

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

Mise en œuvre d'IronPDF:

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

En-têtes et pieds de page

Mise en œuvre d'IronPDF:

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 prend en charge les jetons d'espace réservé comme {page} et {total-pages} pour la numérotation dynamique des pages. Pour plus d'options, consultez la documentation sur les en-têtes et les pieds de page.

Intégration d'ASP.NET Core

Les exigences d'initialisation d'Apryse PDF compliquent l'intégration des applications web. IronPDF simplifie ce modèle.

Modèle IronPDF:

[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

Configuration de l'injection de dépendance

// 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

Comparaison des Performances

Métrique Apryse PDF IronPDF
Départ à froid Rapide (code natif) ~2s (Chromium init)
Rendu ultérieur Rapide Rapide
HTML complexe Variable (module html2pdf) Excellent (Chromium)
Support CSS Limité CSS3 complet
JavaScript Limité Prise en charge

Conseils pour l'optimisation des performances

// 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

Dépannage des problèmes de migration courants

Sujet : Erreurs de chemin d'accès au module

Supprimer toute configuration du chemin d'accès aux modules : le moteur Chromium d'IronPDF est intégré :

// 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

Problème : PDFNet.Initialize() introuvable

Remplacer par la configuration de la licence IronPDF:

// 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

Édition : Remplacement de PDFViewCtrl

IronPDF n'inclut pas de contrôles de visualisation. Options possibles :

  • Utiliser PDF.js pour les visionneuses web
  • Utiliser les visionneuses PDF du système
  • Prendre en compte les composants de visualisation tiers

Liste de contrôle post-migration

Après avoir effectué la migration du code, vérifiez les points suivants :

  • Vérifier que la qualité de la sortie PDF correspond aux attentes
  • Tester tous les cas limites (documents volumineux, CSS complexe)
  • Comparer les indicateurs de performance
  • Mettre à jour les configurations Docker si nécessaire
  • Supprimer la licence Apryse et les configurations associées
  • Documentez toutes les configurations spécifiques à IronPDF
  • Former l'équipe aux nouveaux modèles d'API
  • Mettre à jour les pipelines CI/CD si nécessaire

Protéger l'avenir de votre infrastructure PDF

Avec .NET 10 à l'horizon et C# 14 introduisant de nouvelles fonctionnalités de langage, le choix d'une bibliothèque PDF .NET native avec des conventions modernes garantit la compatibilité avec les capacités d'exécution en constante évolution. L'engagement d'IronPDF à prendre en charge les dernières versions de .NET signifie que votre investissement dans la migration porte ses fruits lorsque les projets se prolongent jusqu'en 2025 et 2026 - sans renouvellement annuel de l'abonnement.

Ressources supplémentaires


La migration d'Apryse PDF vers IronPDF transforme votre base de code PDF, qui passe de modèles C++ complexes à un langage C# idiomatique. L'élimination de l'initialisation, de la configuration des chemins d'accès aux modules et des licences par abonnement permet de réaliser des gains de productivité immédiats tout en réduisant les coûts à long terme.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite

Équipe de soutien Iron

Nous sommes en ligne 24 heures sur 24, 5 jours sur 7.
Chat
Email
Appelez-moi