Passer au contenu du pied de page
VIDéOS

Comment appliquer des filigranes PDF personnalisés

ActivePDF est un outil PDF fiable pour les développeurs .NET . Depuis son acquisition par PDFTron en juin 2020 et sa requalification sous le nom d'Apryse en février 2023, ActivePDFest désormais l'une des marques à l'intérieur du portefeuille plus large d'Apryse. Ce guide offre un chemin de migration complet, étape par étape, d'ActivePDF vers IronPDF— une bibliothèque PDF .NET moderne, activement maintenue, supportant de .NET Framework 4.6.2 à .NET 9.

Pourquoi envisager de changer de solution ?

ActivePDF est toujours fourni et le package NuGet ActivePDF.Toolkit continue de recevoir des mises à jour sous Apryse, mais plusieurs aspects de sa conception et de son emballage peuvent amener les équipes à évaluer d'autres options.

Considérations sur la Marque et la Feuille de Route

ActivePDF est désormais une marque au sein d'Apryse, aux côtés du SDK phare Apryse. Les équipes qui ont choisi ActivePDFspécifiquement pour son focus sur l'automatisation côté serveur pourraient vouloir évaluer la pertinence de rester sur les SKU ActivePDFou passer au SDK Apryse plus large au fil du temps.

Modèle de Licence

La licence par serveur/par cœur traditionnelle d'ActivePDF peut introduire des frictions dans les environnements cloud et conteneurisés où les applications se mettent à l'échelle dynamiquement à travers l'infrastructure.

Modèles d'architecture de Legacy

La surface API d'ActivePDF reflète ses origines COM/native. Le flux de travail CloseOutputFile et les codes de retour entiers (0 pour le succès) nécessitent une gestion explicite du cycle de vie qui ne s'aligne pas toujours avec les idiomes modernes de C# comme using, les exceptions et l'async.

Disposition Multi-SKU du Produit

Le rendu HTML/URL vers PDF est présent dans le produit séparé ActivePDF.WebGrabber, tandis que la manipulation de PDF se trouve dans ActivePDF.Toolkit. À partir du Toolkit 10, les bibliothèques natives ne sont plus automatiquement copiées dans le dossier système, donc le constructeur a souvent besoin d'un argument explicite CoreLibPath—un modèle qui peut compliquer Docker, CI et les déploiements sans installateur.

ActivePDFvs.IronPDF: Principales différences

Avant de commencer le processus de migration, comprendre les différences fondamentales entre ActivePDFet IronPDF permet de mieux appréhender les modifications de code nécessaires.

Aspect ActivePDF IronPDF
Fournisseur Apryse (anciennement PDFTron, acquis ActivePDFen juin 2020) Iron Software, indépendant
Disposition du Produit Plusieurs codes de référence (Toolkit, WebGrabber, DocConverter, Serveur, Meridian) Single IronPdf NuGet package
Installation Package NuGet + chemin d'exécution native (CoreLibPath depuis la v10) Paquet NuGet unique; natives bundled
Modèle d'interface utilisateur Stateful (CloseOutputFile), dérivé de COM API fluide et fonctionnelle
Modèle de licence Par serveur / par coeur Clé basée sur le code
Support .NET .NET Framework 4.5+ / .NET Standard 1.0+ / .NET Core De .NET 4.6.2 à .NET 9
Gestion des erreurs Codes de retour entiers (0 = succès) Exceptions.NET Standard
Support asynchrone Pas natif Prise en charge complète de l'asynchronisme et de l'attente

Préparation de la migration

Auditez votre base de code

Avant de commencer la migration, identifiez toutes les utilisations d'ActivePDF dans votre solution. Les vrais espaces de noms sont APToolkitNET (Toolkit) et APWebGrabber (WebGrabber); quelques anciens projets font également référence à ActivePDF.Toolkit via l'assembly d'interopérabilité COM. Exécutez ces commandes dans votre répertoire de solutions :

grep -r "using APToolkitNET" --include="*.cs" .
grep -r "using APWebGrabber" --include="*.cs" .
grep -r "ActivePDF" --include="*.csproj" .
grep -r "using APToolkitNET" --include="*.cs" .
grep -r "using APWebGrabber" --include="*.cs" .
grep -r "ActivePDF" --include="*.csproj" .
SHELL

Rupture de document

Comprendre les différences fondamentales entre les API permet de planifier votre stratégie de migration :

Catégorie Comportement d'ActivePDF Comportement d'IronPDF Action de migration
Division du Produit Toolkit (manipulation) + WebGrabber (rendu HTML) vendus séparément Single IronPdf package Fusionnez les deux en une seule bibliothèque
Modèle d'objet APToolkitNET.Toolkit pour les PDFs, APWebGrabber.WebGrabber pour HTML ChromePdfRenderer + PdfDocument Des préoccupations distinctes
Opérations sur les fichiers CloseOutputFile() Direct SaveAs() Supprimer les appels d'ouverture/fermeture
Runtime Natif Argument CoreLibPath depuis la v10 NuGet expédie les natifs Supprimer la configuration du chemin
Création de pages Méthode NewPage() Automatique à partir de HTML Supprimer les appels à la création de pages
Valeurs de retour Codes d'erreur des nombres entiers Exceptions Implémenter try/catch
Taille de la page Unités Points (612x792 = Lettre) Enums ou millimètres Mesures de mise à jour

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 JetBrains Rider
  • Accès au Package Manager NuGet
  • Clé de licence IronPDF(essai gratuit disponible sur ironpdf.com)

Processus de migration étape par étape

Étape 1 : Mise à jour des paquets NuGet

Le package sur nuget.org est ActivePDF.Toolkit (version actuelle 11.4.4, publiée en décembre 2025). Le rendu HTML est livré séparément sous la forme ActivePDF.WebGrabber. Supprimez les SKU ActivePDFet installez IronPDF:

# Remove ActivePDFpackages
dotnet remove package ActivePDF.Toolkit
dotnet remove package ActivePDF.WebGrabber

# Install IronPDF
dotnet add package IronPdf
# Remove ActivePDFpackages
dotnet remove package ActivePDF.Toolkit
dotnet remove package ActivePDF.WebGrabber

# Install IronPDF
dotnet add package IronPdf
SHELL

Alternativement, via la console Visual Studio Package Manager :

Uninstall-Package ActivePDF.Toolkit
Uninstall-Package ActivePDF.WebGrabber
Install-Package IronPdf

Pour les projets avec des références DLL manuelles, retirez la référence de votre fichier .csproj :


<Reference Include="APToolkitNET">
    <HintPath>path\to\APToolkitNET.dll</HintPath>
</Reference>

<Reference Include="APToolkitNET">
    <HintPath>path\to\APToolkitNET.dll</HintPath>
</Reference>
XML

Étape 2 : configuration de la clé de licence

Ajoutez la clé de licence IronPDF au démarrage de l'application, avant toute opération sur les PDF :

// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

// Verify license status
bool isLicensed = IronPdf.License.IsLicensed;
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

// Verify license status
bool isLicensed = IronPdf.License.IsLicensed;
' Add at application startup (Program.vb or Startup.vb)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"

' Verify license status
Dim isLicensed As Boolean = IronPdf.License.IsLicensed
$vbLabelText   $csharpLabel

Étape 3 : mise à jour des références aux espaces de noms

Effectuez une recherche et un remplacement globaux dans votre solution :

Recherche Remplacer par
using APToolkitNET; using IronPdf;
using APWebGrabber; using IronPdf;
APToolkitNET.Toolkit ChromePdfRenderer (rendu) / PdfDocument (manipulation)
APWebGrabber.WebGrabber ChromePdfRenderer

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

Méthodes de création de documents

Méthode ActivePDF Équivalent d'IronPDF Notes
new APToolkitNET.Toolkit() new ChromePdfRenderer() / new PdfDocument(...) IronPDF sépare le rendu de la manipulation
new Toolkit(CoreLibPath: path) new ChromePdfRenderer() NuGet envoie les natifs—pas de CoreLibPath
toolkit.OpenOutputFile(path) Aucun équivalent n'est nécessaire Appelez simplement SaveAs à la fin
toolkit.CloseOutputFile() Aucun équivalent n'est nécessaire using gère le nettoyage
webGrabber.URL = html; webGrabber.ConvertToPDF() renderer.RenderHtmlAsPdf(html) WebGrabber, pas Toolkit
webGrabber.URL = url; webGrabber.ConvertToPDF() renderer.RenderUrlAsPdf(url) WebGrabber, pas Toolkit

Opérations de fichiers

Méthode ActivePDF Équivalent d'IronPDF Notes
toolkit.OpenInputFile(path) PdfDocument.FromFile(path) Charger le PDF existant
toolkit.MergeFile(path, startPage, endPage) PdfDocument.Merge(pdfs) ActivePDF fusionne dans le fichier de sortie ouvert sur place;IronPDF renvoie un nouveau document fusionné
toolkit.NumPages (propriété) pdf.PageCount Nombre de pages
toolkit.GetPageText(page, 0) pdf.Pages[i].Text / pdf.ExtractAllText() Extraction de texte

Configuration de la page

Méthode ActivePDF Équivalent d'IronPDF
toolkit.SetPageSize(612, 792) RenderingOptions.PaperSize = PdfPaperSize.Letter
toolkit.SetOrientation("Landscape") RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape
toolkit.SetMargins(t, b, l, r) RenderingOptions.MarginTop/Bottom/Left/Right

Méthodes de sécurité

Méthode ActivePDF Équivalent d'IronPDF
toolkit.SetEncryption(user, owner, 128, 0) pdf.SecuritySettings.OwnerPassword / UserPassword
toolkit.SetPermissions(flags) pdf.SecuritySettings.AllowUserXxx
toolkit.PrintText(x, y, text) (filigrane par page) pdf.ApplyWatermark(html)

Exemples de migration de code

Conversion HTML en PDF

La conversion de chaînes HTML en documents PDF représente l'un des scénarios de génération de PDF les plus courants. Notez que dans ActivePDF, le rendu HTML se trouve dans le produit WebGrabber sous licence séparée, pas Toolkit, et WebGrabber rend à partir d'une URL ou d'un chemin de fichier plutôt que d'une chaîne en mémoire.

Implémentation ActivePDF(WebGrabber) :

// NuGet: Install-Package ActivePDF.WebGrabber
using APWebGrabber;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        WebGrabber wg = new WebGrabber();

        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";
        string tempHtml = Path.Combine(Path.GetTempPath(), "input.html");
        File.WriteAllText(tempHtml, htmlContent);

        wg.URL = tempHtml;
        wg.OutputDirectory = Directory.GetCurrentDirectory();
        wg.OutputFilename = "output.pdf";

        if (wg.ConvertToPDF() == 0)
        {
            Console.WriteLine("PDF created successfully");
        }
    }
}
// NuGet: Install-Package ActivePDF.WebGrabber
using APWebGrabber;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        WebGrabber wg = new WebGrabber();

        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";
        string tempHtml = Path.Combine(Path.GetTempPath(), "input.html");
        File.WriteAllText(tempHtml, htmlContent);

        wg.URL = tempHtml;
        wg.OutputDirectory = Directory.GetCurrentDirectory();
        wg.OutputFilename = "output.pdf";

        if (wg.ConvertToPDF() == 0)
        {
            Console.WriteLine("PDF created successfully");
        }
    }
}
Imports APWebGrabber
Imports System
Imports System.IO

Module Program
    Sub Main()
        Dim wg As New WebGrabber()

        Dim htmlContent As String = "<html><body><h1>Hello World</h1></body></html>"
        Dim tempHtml As String = Path.Combine(Path.GetTempPath(), "input.html")
        File.WriteAllText(tempHtml, htmlContent)

        wg.URL = tempHtml
        wg.OutputDirectory = Directory.GetCurrentDirectory()
        wg.OutputFilename = "output.pdf"

        If wg.ConvertToPDF() = 0 Then
            Console.WriteLine("PDF created successfully")
        End If
    End Sub
End Module
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

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

        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF created successfully");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

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

        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF created successfully");
    }
}
Imports IronPdf
Imports System

Module Program
    Sub Main()
        Dim renderer As New ChromePdfRenderer()

        Dim htmlContent As String = "<html><body><h1>Hello World</h1></body></html>"

        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
        pdf.SaveAs("output.pdf")

        Console.WriteLine("PDF created successfully")
    End Sub
End Module
$vbLabelText   $csharpLabel

L'approche IronPDF élimine la gestion explicite des poignées de fichiers tout en fournissant un code plus propre et plus lisible. Pour des scénarios HTML vers PDF avancés, le ChromePdfRenderer d'IronPDF utilise un moteur de rendu basé sur Chromium pour un support CSS et JavaScript pixel-parfait.

Conversion d'URL en PDF

La capture de pages web en tant que documents PDF se trouve également dans WebGrabber, pas Toolkit.

Implémentation ActivePDF(WebGrabber) :

// NuGet: Install-Package ActivePDF.WebGrabber
using APWebGrabber;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        WebGrabber wg = new WebGrabber();

        wg.URL = "https://www.example.com";
        wg.OutputDirectory = Directory.GetCurrentDirectory();
        wg.OutputFilename = "webpage.pdf";

        if (wg.ConvertToPDF() == 0)
        {
            Console.WriteLine("PDF from URL created successfully");
        }
    }
}
// NuGet: Install-Package ActivePDF.WebGrabber
using APWebGrabber;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        WebGrabber wg = new WebGrabber();

        wg.URL = "https://www.example.com";
        wg.OutputDirectory = Directory.GetCurrentDirectory();
        wg.OutputFilename = "webpage.pdf";

        if (wg.ConvertToPDF() == 0)
        {
            Console.WriteLine("PDF from URL created successfully");
        }
    }
}
Imports APWebGrabber
Imports System
Imports System.IO

Module Program
    Sub Main()
        Dim wg As New WebGrabber()

        wg.URL = "https://www.example.com"
        wg.OutputDirectory = Directory.GetCurrentDirectory()
        wg.OutputFilename = "webpage.pdf"

        If wg.ConvertToPDF() = 0 Then
            Console.WriteLine("PDF from URL created successfully")
        End If
    End Sub
End Module
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

using IronPdf;
using System;

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

        string url = "https://www.example.com";

        var pdf = renderer.RenderUrlAsPdf(url);
        pdf.SaveAs("webpage.pdf");

        Console.WriteLine("PDF from URL created successfully");
    }
}
using IronPdf;
using System;

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

        string url = "https://www.example.com";

        var pdf = renderer.RenderUrlAsPdf(url);
        pdf.SaveAs("webpage.pdf");

        Console.WriteLine("PDF from URL created successfully");
    }
}
Imports IronPdf
Imports System

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")

        Console.WriteLine("PDF from URL created successfully")
    End Sub
End Class
$vbLabelText   $csharpLabel

Fusionner plusieurs fichiers PDF

La combinaison de plusieurs documents PDF en un seul fichier démontre l'approche fonctionnelle d'IronPDF en matière de manipulation de documents.

Implémentation ActivePDF(Toolkit) :

// NuGet: Install-Package ActivePDF.Toolkit
using APToolkitNET;
using System;

class Program
{
    static void Main()
    {
        using (Toolkit toolkit = new Toolkit())
        {
            if (toolkit.OpenOutputFile("merged.pdf") == 0)
            {
                // MergeFile(FileName, StartPage, EndPage); -1 = end of file
                toolkit.MergeFile("document1.pdf", 1, -1);
                toolkit.MergeFile("document2.pdf", 1, -1);
                toolkit.CloseOutputFile();
                Console.WriteLine("PDFs merged successfully");
            }
        }
    }
}
// NuGet: Install-Package ActivePDF.Toolkit
using APToolkitNET;
using System;

class Program
{
    static void Main()
    {
        using (Toolkit toolkit = new Toolkit())
        {
            if (toolkit.OpenOutputFile("merged.pdf") == 0)
            {
                // MergeFile(FileName, StartPage, EndPage); -1 = end of file
                toolkit.MergeFile("document1.pdf", 1, -1);
                toolkit.MergeFile("document2.pdf", 1, -1);
                toolkit.CloseOutputFile();
                Console.WriteLine("PDFs merged successfully");
            }
        }
    }
}
Imports APToolkitNET
Imports System

Module Program
    Sub Main()
        Using toolkit As New Toolkit()
            If toolkit.OpenOutputFile("merged.pdf") = 0 Then
                ' MergeFile(FileName, StartPage, EndPage); -1 = end of file
                toolkit.MergeFile("document1.pdf", 1, -1)
                toolkit.MergeFile("document2.pdf", 1, -1)
                toolkit.CloseOutputFile()
                Console.WriteLine("PDFs merged successfully")
            End If
        End Using
    End Sub
End Module
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

using IronPdf;
using System;
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(pdf1, pdf2);
        merged.SaveAs("merged.pdf");

        Console.WriteLine("PDFs merged successfully");
    }
}
using IronPdf;
using System;
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(pdf1, pdf2);
        merged.SaveAs("merged.pdf");

        Console.WriteLine("PDFs merged successfully");
    }
}
Imports IronPdf
Imports System
Imports System.Collections.Generic

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

        Dim merged = PdfDocument.Merge(pdf1, pdf2)
        merged.SaveAs("merged.pdf")

        Console.WriteLine("PDFs merged successfully")
    End Sub
End Module
$vbLabelText   $csharpLabel

Pour des scénarios de fusion plus avancés, notamment l'extraction sélective de pages, voir la documentation de fusion IronPDF.

Ajouter des en-têtes et des pieds de page

Implémentation ActivePDF(WebGrabber) :

using APWebGrabber;
using System.IO;

public void CreatePdfWithHeaderFooter(string html, string outputPath)
{
    var wg = new WebGrabber();
    string tempHtml = Path.Combine(Path.GetTempPath(), "input.html");
    File.WriteAllText(tempHtml, html);

    wg.URL = tempHtml;
    wg.HeaderText = "My Document";
    wg.FooterText = "Page [page] of [pages]";
    wg.OutputDirectory = Path.GetDirectoryName(outputPath);
    wg.OutputFilename = Path.GetFileName(outputPath);
    wg.ConvertToPDF();
}
using APWebGrabber;
using System.IO;

public void CreatePdfWithHeaderFooter(string html, string outputPath)
{
    var wg = new WebGrabber();
    string tempHtml = Path.Combine(Path.GetTempPath(), "input.html");
    File.WriteAllText(tempHtml, html);

    wg.URL = tempHtml;
    wg.HeaderText = "My Document";
    wg.FooterText = "Page [page] of [pages]";
    wg.OutputDirectory = Path.GetDirectoryName(outputPath);
    wg.OutputFilename = Path.GetFileName(outputPath);
    wg.ConvertToPDF();
}
Imports APWebGrabber
Imports System.IO

Public Sub CreatePdfWithHeaderFooter(html As String, outputPath As String)
    Dim wg As New WebGrabber()
    Dim tempHtml As String = Path.Combine(Path.GetTempPath(), "input.html")
    File.WriteAllText(tempHtml, html)

    wg.URL = tempHtml
    wg.HeaderText = "My Document"
    wg.FooterText = "Page [page] of [pages]"
    wg.OutputDirectory = Path.GetDirectoryName(outputPath)
    wg.OutputFilename = Path.GetFileName(outputPath)
    wg.ConvertToPDF()
End Sub
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

using IronPdf;

public void CreatePdfWithHeaderFooter(string html, string outputPath)
{
    var renderer = new ChromePdfRenderer();

    renderer.RenderingOptions.TextHeader = new TextHeaderFooter
    {
        CenterText = "My Document",
        FontSize = 12,
        FontFamily = "Arial"
    };

    renderer.RenderingOptions.TextFooter = new TextHeaderFooter
    {
        CenterText = "Page {page} of {total-pages}",
        FontSize = 10,
        FontFamily = "Arial"
    };

    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs(outputPath);
}
using IronPdf;

public void CreatePdfWithHeaderFooter(string html, string outputPath)
{
    var renderer = new ChromePdfRenderer();

    renderer.RenderingOptions.TextHeader = new TextHeaderFooter
    {
        CenterText = "My Document",
        FontSize = 12,
        FontFamily = "Arial"
    };

    renderer.RenderingOptions.TextFooter = new TextHeaderFooter
    {
        CenterText = "Page {page} of {total-pages}",
        FontSize = 10,
        FontFamily = "Arial"
    };

    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs(outputPath);
}
Imports IronPdf

Public Sub CreatePdfWithHeaderFooter(html As String, outputPath As String)
    Dim renderer = New ChromePdfRenderer()

    renderer.RenderingOptions.TextHeader = New TextHeaderFooter With {
        .CenterText = "My Document",
        .FontSize = 12,
        .FontFamily = "Arial"
    }

    renderer.RenderingOptions.TextFooter = New TextHeaderFooter With {
        .CenterText = "Page {page} of {total-pages}",
        .FontSize = 10,
        .FontFamily = "Arial"
    }

    Using pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs(outputPath)
    End Using
End Sub
$vbLabelText   $csharpLabel

IronPDF prend en charge les en-têtes et pieds de page textuels et HTML, offrant ainsi une flexibilité de conception totale.

Protection des mots de passe et sécurité

Implémentation ActivePDF(Toolkit) :

using APToolkitNET;

public void ProtectPdf(string inputPath, string outputPath, string password)
{
    using (Toolkit toolkit = new Toolkit())
    {
        if (toolkit.OpenOutputFile(outputPath) == 0
            && toolkit.OpenInputFile(inputPath) == 0)
        {
            toolkit.SetEncryption(password, password, 128, 0);
            toolkit.CopyForm(0, 0);
            toolkit.CloseInputFile();
            toolkit.CloseOutputFile();
        }
    }
}
using APToolkitNET;

public void ProtectPdf(string inputPath, string outputPath, string password)
{
    using (Toolkit toolkit = new Toolkit())
    {
        if (toolkit.OpenOutputFile(outputPath) == 0
            && toolkit.OpenInputFile(inputPath) == 0)
        {
            toolkit.SetEncryption(password, password, 128, 0);
            toolkit.CopyForm(0, 0);
            toolkit.CloseInputFile();
            toolkit.CloseOutputFile();
        }
    }
}
Imports APToolkitNET

Public Sub ProtectPdf(inputPath As String, outputPath As String, password As String)
    Using toolkit As New Toolkit()
        If toolkit.OpenOutputFile(outputPath) = 0 AndAlso toolkit.OpenInputFile(inputPath) = 0 Then
            toolkit.SetEncryption(password, password, 128, 0)
            toolkit.CopyForm(0, 0)
            toolkit.CloseInputFile()
            toolkit.CloseOutputFile()
        End If
    End Using
End Sub
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

using IronPdf;

public void ProtectPdf(string inputPath, string outputPath, string password)
{
    using var pdf = PdfDocument.FromFile(inputPath);

    pdf.SecuritySettings.OwnerPassword = password;
    pdf.SecuritySettings.UserPassword = password;
    pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
    pdf.SecuritySettings.AllowUserCopyPasteContent = false;
    pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;

    pdf.SaveAs(outputPath);
}
using IronPdf;

public void ProtectPdf(string inputPath, string outputPath, string password)
{
    using var pdf = PdfDocument.FromFile(inputPath);

    pdf.SecuritySettings.OwnerPassword = password;
    pdf.SecuritySettings.UserPassword = password;
    pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
    pdf.SecuritySettings.AllowUserCopyPasteContent = false;
    pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;

    pdf.SaveAs(outputPath);
}
Imports IronPdf

Public Sub ProtectPdf(inputPath As String, outputPath As String, password As String)
    Using pdf = PdfDocument.FromFile(inputPath)
        pdf.SecuritySettings.OwnerPassword = password
        pdf.SecuritySettings.UserPassword = password
        pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights
        pdf.SecuritySettings.AllowUserCopyPasteContent = False
        pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit

        pdf.SaveAs(outputPath)
    End Using
End Sub
$vbLabelText   $csharpLabel

L'API paramètres de sécurité d'IronPDF permet un contrôle granulaire des autorisations sur les documents à l'aide d'enums fortement typés au lieu de drapeaux entiers.

Extraction de texte

Implémentation ActivePDF(Toolkit) :

using APToolkitNET;
using System.Text;

public string ExtractText(string pdfPath)
{
    var sb = new StringBuilder();

    using (Toolkit toolkit = new Toolkit())
    {
        if (toolkit.OpenInputFile(pdfPath) == 0)
        {
            int pageCount = toolkit.NumPages;
            for (int i = 1; i <= pageCount; i++)
            {
                sb.AppendLine(toolkit.GetPageText(i, 0));
            }
            toolkit.CloseInputFile();
        }
    }

    return sb.ToString();
}
using APToolkitNET;
using System.Text;

public string ExtractText(string pdfPath)
{
    var sb = new StringBuilder();

    using (Toolkit toolkit = new Toolkit())
    {
        if (toolkit.OpenInputFile(pdfPath) == 0)
        {
            int pageCount = toolkit.NumPages;
            for (int i = 1; i <= pageCount; i++)
            {
                sb.AppendLine(toolkit.GetPageText(i, 0));
            }
            toolkit.CloseInputFile();
        }
    }

    return sb.ToString();
}
Imports APToolkitNET
Imports System.Text

Public Function ExtractText(pdfPath As String) As String
    Dim sb As New StringBuilder()

    Using toolkit As New Toolkit()
        If toolkit.OpenInputFile(pdfPath) = 0 Then
            Dim pageCount As Integer = toolkit.NumPages
            For i As Integer = 1 To pageCount
                sb.AppendLine(toolkit.GetPageText(i, 0))
            Next
            toolkit.CloseInputFile()
        End If
    End Using

    Return sb.ToString()
End Function
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

using IronPdf;

public string ExtractText(string pdfPath)
{
    using var pdf = PdfDocument.FromFile(pdfPath);
    return pdf.ExtractAllText();
}
using IronPdf;

public string ExtractText(string pdfPath)
{
    using var pdf = PdfDocument.FromFile(pdfPath);
    return pdf.ExtractAllText();
}
Imports IronPdf

Public Function ExtractText(pdfPath As String) As String
    Using pdf = PdfDocument.FromFile(pdfPath)
        Return pdf.ExtractAllText()
    End Using
End Function
$vbLabelText   $csharpLabel

La mise en œuvre d'IronPDF réduit l'extraction de texte de plusieurs lignes à un seul appel de méthode.

Ajouter des filigranes

Implémentation ActivePDF(Toolkit — dessiné comme texte par page) :

using APToolkitNET;

public void AddWatermark(string inputPath, string outputPath, string watermarkText)
{
    using (Toolkit toolkit = new Toolkit())
    {
        if (toolkit.OpenOutputFile(outputPath) == 0
            && toolkit.OpenInputFile(inputPath) == 0)
        {
            int pageCount = toolkit.NumPages;
            for (int i = 1; i <= pageCount; i++)
            {
                toolkit.CopyForm(i, 0);
                toolkit.SetFont("Helvetica", 72);
                toolkit.SetTextColor(200, 200, 200);
                toolkit.PrintText(150, 400, watermarkText);
            }
            toolkit.CloseInputFile();
            toolkit.CloseOutputFile();
        }
    }
}
using APToolkitNET;

public void AddWatermark(string inputPath, string outputPath, string watermarkText)
{
    using (Toolkit toolkit = new Toolkit())
    {
        if (toolkit.OpenOutputFile(outputPath) == 0
            && toolkit.OpenInputFile(inputPath) == 0)
        {
            int pageCount = toolkit.NumPages;
            for (int i = 1; i <= pageCount; i++)
            {
                toolkit.CopyForm(i, 0);
                toolkit.SetFont("Helvetica", 72);
                toolkit.SetTextColor(200, 200, 200);
                toolkit.PrintText(150, 400, watermarkText);
            }
            toolkit.CloseInputFile();
            toolkit.CloseOutputFile();
        }
    }
}
Imports APToolkitNET

Public Sub AddWatermark(inputPath As String, outputPath As String, watermarkText As String)
    Using toolkit As New Toolkit()
        If toolkit.OpenOutputFile(outputPath) = 0 AndAlso toolkit.OpenInputFile(inputPath) = 0 Then
            Dim pageCount As Integer = toolkit.NumPages
            For i As Integer = 1 To pageCount
                toolkit.CopyForm(i, 0)
                toolkit.SetFont("Helvetica", 72)
                toolkit.SetTextColor(200, 200, 200)
                toolkit.PrintText(150, 400, watermarkText)
            Next
            toolkit.CloseInputFile()
            toolkit.CloseOutputFile()
        End If
    End Using
End Sub
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

using IronPdf;

public void AddWatermark(string inputPath, string outputPath, string watermarkText)
{
    using var pdf = PdfDocument.FromFile(inputPath);

    pdf.ApplyWatermark(
        $"<h1 style='color:lightgray;font-size:72px;'>{watermarkText}</h1>",
        rotation: 45,
        opacity: 50);

    pdf.SaveAs(outputPath);
}
using IronPdf;

public void AddWatermark(string inputPath, string outputPath, string watermarkText)
{
    using var pdf = PdfDocument.FromFile(inputPath);

    pdf.ApplyWatermark(
        $"<h1 style='color:lightgray;font-size:72px;'>{watermarkText}</h1>",
        rotation: 45,
        opacity: 50);

    pdf.SaveAs(outputPath);
}
Imports IronPdf

Public Sub AddWatermark(inputPath As String, outputPath As String, watermarkText As String)
    Using pdf = PdfDocument.FromFile(inputPath)
        pdf.ApplyWatermark(
            $"<h1 style='color:lightgray;font-size:72px;'>{watermarkText}</h1>",
            rotation:=45,
            opacity:=50)

        pdf.SaveAs(outputPath)
    End Using
End Sub
$vbLabelText   $csharpLabel

Le filigrane basé sur le HTML d'IronPDF permet un style CSS pour un contrôle complet de la conception sans itération page par page.

Intégration d'ASP.NET Core

Les applications web modernes bénéficient considérablement des modèles d'intégration plus propres d'IronPDF.

Modèle ActivePDF(WebGrabber) :

[HttpPost]
public IActionResult GeneratePdf([FromBody] ReportRequest request)
{
    var wg = new APWebGrabber.WebGrabber();
    string tempHtml = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".html");
    System.IO.File.WriteAllText(tempHtml, request.Html);

    wg.URL = tempHtml;
    wg.OutputDirectory = Path.GetTempPath();
    wg.OutputFilename = "temp.pdf";

    if (wg.ConvertToPDF() == 0)
    {
        byte[] bytes = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), "temp.pdf"));
        return File(bytes, "application/pdf", "report.pdf");
    }

    return BadRequest("PDF generation failed");
}
[HttpPost]
public IActionResult GeneratePdf([FromBody] ReportRequest request)
{
    var wg = new APWebGrabber.WebGrabber();
    string tempHtml = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".html");
    System.IO.File.WriteAllText(tempHtml, request.Html);

    wg.URL = tempHtml;
    wg.OutputDirectory = Path.GetTempPath();
    wg.OutputFilename = "temp.pdf";

    if (wg.ConvertToPDF() == 0)
    {
        byte[] bytes = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), "temp.pdf"));
        return File(bytes, "application/pdf", "report.pdf");
    }

    return BadRequest("PDF generation failed");
}
Imports System
Imports System.IO
Imports Microsoft.AspNetCore.Mvc

<HttpPost>
Public Function GeneratePdf(<FromBody> request As ReportRequest) As IActionResult
    Dim wg As New APWebGrabber.WebGrabber()
    Dim tempHtml As String = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() & ".html")
    System.IO.File.WriteAllText(tempHtml, request.Html)

    wg.URL = tempHtml
    wg.OutputDirectory = Path.GetTempPath()
    wg.OutputFilename = "temp.pdf"

    If wg.ConvertToPDF() = 0 Then
        Dim bytes As Byte() = System.IO.File.ReadAllBytes(Path.Combine(Path.GetTempPath(), "temp.pdf"))
        Return File(bytes, "application/pdf", "report.pdf")
    End If

    Return BadRequest("PDF generation failed")
End Function
$vbLabelText   $csharpLabel

Modèle IronPDF:

[HttpPost]
public IActionResult GeneratePdf([FromBody] ReportRequest request)
{
    var renderer = new ChromePdfRenderer();
    using var pdf = renderer.RenderHtmlAsPdf(request.Html);

    return File(pdf.BinaryData, "application/pdf", "report.pdf");
}
[HttpPost]
public IActionResult GeneratePdf([FromBody] ReportRequest request)
{
    var renderer = new ChromePdfRenderer();
    using var pdf = renderer.RenderHtmlAsPdf(request.Html);

    return File(pdf.BinaryData, "application/pdf", "report.pdf");
}
<HttpPost>
Public Function GeneratePdf(<FromBody> request As ReportRequest) As IActionResult
    Dim renderer As New ChromePdfRenderer()
    Using pdf = renderer.RenderHtmlAsPdf(request.Html)
        Return File(pdf.BinaryData, "application/pdf", "report.pdf")
    End Using
End Function
$vbLabelText   $csharpLabel

IronPDF élimine le besoin de fichiers temporaires, renvoyant les données binaires du PDF directement depuis la mémoire.

Support asynchrone pour les applications Web

ActivePDF n'a pas de support asynchrone natif.IronPDF offre des fonctionnalités asynchrones/await complètes, essentielles pour les applications web évolutives :

using IronPdf;

public async Task<byte[]> GeneratePdfAsync(string html)
{
    var renderer = new ChromePdfRenderer();
    using var pdf = await renderer.RenderHtmlAsPdfAsync(html);
    return pdf.BinaryData;
}
using IronPdf;

public async Task<byte[]> GeneratePdfAsync(string html)
{
    var renderer = new ChromePdfRenderer();
    using var pdf = await renderer.RenderHtmlAsPdfAsync(html);
    return pdf.BinaryData;
}
Imports IronPdf

Public Async Function GeneratePdfAsync(html As String) As Task(Of Byte())
    Dim renderer As New ChromePdfRenderer()
    Using pdf = Await renderer.RenderHtmlAsPdfAsync(html)
        Return pdf.BinaryData
    End Using
End Function
$vbLabelText   $csharpLabel

Configuration de l'injection de dépendance

Pour les applications .NET 6+, enregistrez les services IronPDF dans votre conteneur DI :

// Program.cs (.NET 6+)
builder.Services.AddSingleton<ChromePdfRenderer>();

// Service wrapper
public interface IPdfService
{
    Task<byte[]> GeneratePdfAsync(string html);
    Task<byte[]> GeneratePdfFromUrlAsync(string url);
}

public class IronPdfService : IPdfService
{
    private readonly ChromePdfRenderer _renderer;

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

    public async Task<byte[]> GeneratePdfAsync(string html)
    {
        using var pdf = await _renderer.RenderHtmlAsPdfAsync(html);
        return pdf.BinaryData;
    }

    public async Task<byte[]> GeneratePdfFromUrlAsync(string url)
    {
        using var pdf = await _renderer.RenderUrlAsPdfAsync(url);
        return pdf.BinaryData;
    }
}
// Program.cs (.NET 6+)
builder.Services.AddSingleton<ChromePdfRenderer>();

// Service wrapper
public interface IPdfService
{
    Task<byte[]> GeneratePdfAsync(string html);
    Task<byte[]> GeneratePdfFromUrlAsync(string url);
}

public class IronPdfService : IPdfService
{
    private readonly ChromePdfRenderer _renderer;

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

    public async Task<byte[]> GeneratePdfAsync(string html)
    {
        using var pdf = await _renderer.RenderHtmlAsPdfAsync(html);
        return pdf.BinaryData;
    }

    public async Task<byte[]> GeneratePdfFromUrlAsync(string url)
    {
        using var pdf = await _renderer.RenderUrlAsPdfAsync(url);
        return pdf.BinaryData;
    }
}
Imports Microsoft.Extensions.DependencyInjection
Imports System.Threading.Tasks

' Program.vb (.NET 6+)
builder.Services.AddSingleton(Of ChromePdfRenderer)()

' Service wrapper
Public Interface IPdfService
    Function GeneratePdfAsync(html As String) As Task(Of Byte())
    Function GeneratePdfFromUrlAsync(url As String) As Task(Of Byte())
End Interface

Public Class IronPdfService
    Implements IPdfService

    Private ReadOnly _renderer As ChromePdfRenderer

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

    Public Async Function GeneratePdfAsync(html As String) As Task(Of Byte()) Implements IPdfService.GeneratePdfAsync
        Using pdf = Await _renderer.RenderHtmlAsPdfAsync(html)
            Return pdf.BinaryData
        End Using
    End Function

    Public Async Function GeneratePdfFromUrlAsync(url As String) As Task(Of Byte()) Implements IPdfService.GeneratePdfFromUrlAsync
        Using pdf = Await _renderer.RenderUrlAsPdfAsync(url)
            Return pdf.BinaryData
        End Using
    End Function
End Class
$vbLabelText   $csharpLabel

Migration du traitement des erreurs

ActivePDF utilise des codes de retour entiers nécessitant des tables de consultation.IronPDF utilise une gestion moderne des exceptions :

Gestion des erreurs d'ActivePDF:

using APToolkitNET;

using (var toolkit = new Toolkit())
{
    int result = toolkit.OpenOutputFile(path);

    if (result != 0)
    {
        // Error - look up the code in "Toolkit Return Results and Error Codes"
        Console.WriteLine($"Error code: {result}");
    }
}
using APToolkitNET;

using (var toolkit = new Toolkit())
{
    int result = toolkit.OpenOutputFile(path);

    if (result != 0)
    {
        // Error - look up the code in "Toolkit Return Results and Error Codes"
        Console.WriteLine($"Error code: {result}");
    }
}
Imports APToolkitNET

Using toolkit As New Toolkit()
    Dim result As Integer = toolkit.OpenOutputFile(path)

    If result <> 0 Then
        ' Error - look up the code in "Toolkit Return Results and Error Codes"
        Console.WriteLine($"Error code: {result}")
    End If
End Using
$vbLabelText   $csharpLabel

Gestion des erreurs IronPDF:

try
{
    var renderer = new ChromePdfRenderer();
    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs(path);
}
catch (IronPdf.Exceptions.IronPdfProductException ex)
{
    Console.WriteLine($"IronPDF Error: {ex.Message}");
}
catch (Exception ex)
{
    Console.WriteLine($"General Error: {ex.Message}");
}
try
{
    var renderer = new ChromePdfRenderer();
    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs(path);
}
catch (IronPdf.Exceptions.IronPdfProductException ex)
{
    Console.WriteLine($"IronPDF Error: {ex.Message}");
}
catch (Exception ex)
{
    Console.WriteLine($"General Error: {ex.Message}");
}
Imports IronPdf.Exceptions

Try
    Dim renderer = New ChromePdfRenderer()
    Using pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs(path)
    End Using
Catch ex As IronPdfProductException
    Console.WriteLine($"IronPDF Error: {ex.Message}")
Catch ex As Exception
    Console.WriteLine($"General Error: {ex.Message}")
End Try
$vbLabelText   $csharpLabel

Conseils d'optimisation des performances

Réutiliser l'instance du moteur de rendu

Créer un nouveau ChromePdfRenderer a un surcoût d'initialisation. Pour les opérations par lots, réutilisez une seule instance :

var renderer = new ChromePdfRenderer();
foreach (var html in htmlList)
{
    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs($"output_{i}.pdf");
}
var renderer = new ChromePdfRenderer();
foreach (var html in htmlList)
{
    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs($"output_{i}.pdf");
}
Imports IronPdf

Dim renderer As New ChromePdfRenderer()
For Each html In htmlList
    Using pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs($"output_{i}.pdf")
    End Using
Next
$vbLabelText   $csharpLabel

Utiliser Async dans les applications Web

Pour les applications ASP.NET Core, la génération asynchrone de PDF permet d'améliorer le débit :

public async Task<IActionResult> GenerateReport()
{
    var renderer = new ChromePdfRenderer();
    using var pdf = await renderer.RenderHtmlAsPdfAsync(html);
    return File(pdf.BinaryData, "application/pdf");
}
public async Task<IActionResult> GenerateReport()
{
    var renderer = new ChromePdfRenderer();
    using var pdf = await renderer.RenderHtmlAsPdfAsync(html);
    return File(pdf.BinaryData, "application/pdf");
}
Imports System.Threading.Tasks
Imports Microsoft.AspNetCore.Mvc

Public Class ReportController
    Inherits Controller

    Public Async Function GenerateReport() As Task(Of IActionResult)
        Dim renderer As New ChromePdfRenderer()
        Using pdf = Await renderer.RenderHtmlAsPdfAsync(html)
            Return File(pdf.BinaryData, "application/pdf")
        End Using
    End Function
End Class
$vbLabelText   $csharpLabel

Élimination correcte des ressources

Utilisez toujours des instructions using pour assurer le nettoyage approprié :

using var pdf = renderer.RenderHtmlAsPdf(html);
return pdf.BinaryData;
using var pdf = renderer.RenderHtmlAsPdf(html);
return pdf.BinaryData;
$vbLabelText   $csharpLabel

Compression d'images

Réduisez la taille des fichiers de sortie grâce à la compression d'images :

using var pdf = renderer.RenderHtmlAsPdf(html);
pdf.CompressImages(85); // 85% quality
pdf.SaveAs("compressed.pdf");
using var pdf = renderer.RenderHtmlAsPdf(html);
pdf.CompressImages(85); // 85% quality
pdf.SaveAs("compressed.pdf");
$vbLabelText   $csharpLabel

Dépannage des problèmes de migration courants

Sujet : Différences de taille de page

ActivePDF WebGrabber utilise les points (612x792 = Letter), tandis qu'IronPDF utilise des énumérations ou des millimètres :

// ActivePDFWebGrabber: Points
wg.PageWidth = 612;
wg.PageHeight = 792;

// IronPDF: Use enum
renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter;
// Or custom in mm:
renderer.RenderingOptions.SetCustomPaperSizeInMillimeters(215.9, 279.4);
// ActivePDFWebGrabber: Points
wg.PageWidth = 612;
wg.PageHeight = 792;

// IronPDF: Use enum
renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter;
// Or custom in mm:
renderer.RenderingOptions.SetCustomPaperSizeInMillimeters(215.9, 279.4);
' ActivePDFWebGrabber: Points
wg.PageWidth = 612
wg.PageHeight = 792

' IronPDF: Use enum
renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter
' Or custom in mm:
renderer.RenderingOptions.SetCustomPaperSizeInMillimeters(215.9, 279.4)
$vbLabelText   $csharpLabel

Sujet : Équivalent de CloseOutputFile manquant

IronPDF utilise un paradigme moderne sans gestion explicite des poignées de fichiers :

// ActivePDFToolkit
toolkit.OpenOutputFile(path);
// ... operations ...
toolkit.CloseOutputFile(); // Required!

//IronPDF- no open/close needed
using var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs(path); // 'using' handles cleanup
// ActivePDFToolkit
toolkit.OpenOutputFile(path);
// ... operations ...
toolkit.CloseOutputFile(); // Required!

//IronPDF- no open/close needed
using var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs(path); // 'using' handles cleanup
Imports ActivePDFToolkit
Imports IronPDF

' ActivePDFToolkit
toolkit.OpenOutputFile(path)
' ... operations ...
toolkit.CloseOutputFile() ' Required!

' IronPDF - no open/close needed
Using pdf = renderer.RenderHtmlAsPdf(html)
    pdf.SaveAs(path) ' 'Using' handles cleanup
End Using
$vbLabelText   $csharpLabel

Sujet : PDF Rendus vides

Si le contenu dépendant de JavaScript s'affiche en blanc, configurez des délais de rendu :

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.RenderDelay(2000);
// Or wait for element:
renderer.RenderingOptions.WaitFor.HtmlElementById("content-loaded");
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.WaitFor.RenderDelay(2000);
// Or wait for element:
renderer.RenderingOptions.WaitFor.HtmlElementById("content-loaded");
Dim renderer = New ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.RenderDelay(2000)
' Or wait for element:
renderer.RenderingOptions.WaitFor.HtmlElementById("content-loaded")
$vbLabelText   $csharpLabel

Sujet : CSS/Images non chargées

Configurez l'URL de base pour la résolution des chemins relatifs :

renderer.RenderingOptions.BaseUrl = new Uri("https://yourdomain.com/assets/");
renderer.RenderingOptions.BaseUrl = new Uri("https://yourdomain.com/assets/");
renderer.RenderingOptions.BaseUrl = New Uri("https://yourdomain.com/assets/")
$vbLabelText   $csharpLabel

Liste de contrôle post-migration

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

  • Exécuter tous les tests unitaires et d'intégration existants
  • Comparer visuellement les fichiers PDF générés avec les versions précédentes
  • Tester tous les flux de travail PDF dans un environnement de test
  • Vérifiez que la licence fonctionne correctement (IronPdf.License.IsLicensed)
  • Comparer les performances avec l'implémentation précédente
  • Supprimer les anciens fichiers d'installation d'ActivePDF et les références DLL
  • Mettre à jour les dépendances du pipeline CI/CD
  • Modèles IronPDF à documenter pour votre équipe de développement

Ressources supplémentaires


La migration d'ActivePDF vers IronPDF modernise votre infrastructure de génération de PDF grâce à des API plus propres, une meilleure intégration .NET et un support actif à long terme. L'investissement dans la migration est rentabilisé par l'amélioration de la maintenabilité du code, les capacités asynchrones et la confiance dans le développement continu de votre bibliothèque PDF.

Veuillez noterActivePDF et Apryse sont des marques déposées de leurs propriétaires respectifs. Ce site n'est pas affilié, approuvé ou sponsorisé par ActivePDFou Apryse. Tous les noms de produits, logos et marques sont la propriété de leurs propriétaires respectifs. Les comparaisons sont à titre informatif uniquement et reflètent les informations publiquement disponibles au moment de l'écriture.

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