Passer au contenu du pied de page
GUIDES DE MIGRATION

Comment migrer d'Adobe PDF Library SDK vers IronPDF

Migrer du SDK de la bibliothèque PDF d'Adobe versIronPDF: Guide de migration complet en C

Adobe PDF Library SDK, distribué par Datalogics, offre le véritable moteur PDF d'Adobe avec des capacités de niveau professionnel. Cependant, les coûts de licence prohibitifs, l'intégration complexe du SDK natif et la conception d'API de bas niveau les rendent impraticables pour la plupart des équipes de développement. Ce guide complet propose un chemin de migration pas à pas du SDK Adobe PDF Library vers IronPDF, une bibliothèque PDF .NET moderne et rentable prenant en charge .NET Framework 4.6.2 jusqu'à .NET 9 et les versions ultérieures.

Pourquoi abandonner Adobe PDF Library SDK?

Bien qu'Adobe PDF Library SDK offre l'authentique moteur PDF d'Adobe, plusieurs facteurs poussent les équipes de développement à chercher des alternatives pour leurs besoins de génération et de manipulation de PDF.

Coûts de licence prohibitifs

Adobe PDF Library SDK fonctionne à des niveaux de prix d'entreprise, allant généralement de 10 000 à plus de 50 000 dollars par an. Cette structure de coûts rend le kit SDK peu pratique pour les petites et moyennes entreprises, les startups, les développeurs individuels et les projets pour lesquels des fonctionnalités complètes du moteur Adobe ne sont pas essentielles.

Intégration complexe du SDK natif

Le kit SDK de la bibliothèque Adobe PDF s'appuie sur un code C++ natif nécessitant des binaires spécifiques à la plateforme. Les développeurs doivent gérer avec soin la mémoire, les modèles d'initialisation et de terminaison explicites et les procédures d'installation complexes. La traduction doit rester professionnelle et préserver l'exactitude technique tout en expliquant les caractéristiques et les avantages de ces outils de développement, ce qui alourdit considérablement le développement et complique les pipelines CI/CD.

Conception d'API de bas niveau

La création de PDF avec Bibliothèque Adobe PDF SDKnécessite la construction programmatique de pages, de flux de contenu, de parcours de texte et de polices. Des tâches simples comme le rendu d'un contenu HTML deviennent des opérations en plusieurs étapes impliquant des calculs de coordonnées, l'intégration de polices de caractères et la gestion manuelle des éléments de contenu.

Gestion du cycle de vie des bibliothèques : frais généraux

Chaque opération nécessite d'envelopper le code dans des blocs Library.Initialize()et Library.Terminate()avec une élimination minutieuse des objets COM. L'oubli des étapes de nettoyage entraîne des fuites de ressources et l'instabilité des applications.

Surabondance pour les projets typiques

Pour les applications nécessitant principalement la conversion de HTML en PDF, la manipulation de documents de base ou la génération de rapports, le moteur PDF complet d'Adobe représente une sur-ingénierie importante alors que des solutions plus simples donnent des résultats équivalents.

Bibliothèque Adobe PDF SDKvs.IronPDF: Principales différences

La compréhension des différences architecturales fondamentales entre ces bibliothèques permet de planifier une stratégie de migration efficace.

Aspect Bibliothèque Adobe PDF SDK IronPDF
Tarification 10K-$50K+/an entreprise Licence abordable pour chaque développeur
Installation DLL natives, spécifiques à la plate-forme Simple Paquet NuGet
Création de documents Construction de pages/contenus de bas niveau Rendu HTML/CSS
Initialisation Library.Initialize()/Terminate() requis Automatique
Système de coordonnées Points PostScript, origine en bas à gauche Mise en page basée sur les CSS
Traitement des polices Intégration manuelle requise Automatique
Gestion de la mémoire Élimination manuelle des objets COM Modèle standard IDisposable
Support asynchrone Non disponible Prise en charge complète de l'asynchronisme et de l'attente

Préparation de la migration

Prérequis

Assurez-vous que votre environnement répond à ces exigences avant de commencer la migration :

  • .NET Framework 4.6.2+ ou .NET Core 3.1 / .NET 5-9
  • Visual Studio 2019+ ou JetBrains Rider
  • Accès au gestionnaire de paquets NuGet
  • Clé de licenceIronPDF(essai gratuit disponible sur ironpdf.com)

Audit de l'utilisation de la bibliothèque Adobe PDF SDK

Exécutez ces commandes dans votre répertoire de solutions pour identifier toutes les références à Bibliothèque Adobe PDF SDK:

grep -r "using Datalogics" --include="*.cs" .
grep -r "Adobe.PDF.Library" --include="*.csproj" .
grep -r "Library.Initialize\|Library.Terminate" --include="*.cs" .
grep -r "using Datalogics" --include="*.cs" .
grep -r "Adobe.PDF.Library" --include="*.csproj" .
grep -r "Library.Initialize\|Library.Terminate" --include="*.cs" .
SHELL

Modifications importantes à prévoir

Catégorie Bibliothèque Adobe PDF SDK IronPDF Action de migration
Initialisation Library.Initialize()/ Terminate() Automatique Supprimer le code du cycle de vie
Création de documents new Document()avec construction de la page ChromePdfRenderer Utiliser le rendu HTML
Système de coordonnées Points PostScript, origine en bas à gauche Mise en page basée sur les CSS Utiliser HTML/CSS
Traitement des polices Création et intégration manuelles de Font Automatique Supprimer le code de police
Gestion de la mémoire Élimination manuelle des objets COM IDisposable standard Utiliser les déclarations utilisant
Construction de la page CreatePage(), AddContent() Automatique à partir de HTML Simplifier considérablement

Processus de migration étape par étape

Étape 1 : Mise à jour des paquets NuGet

Supprimez le kit SDK de la bibliothèque Adobe PDF et installezIronPDF:

# Remove Adobe PDF Library
dotnet remove package Adobe.PDF.Library.LM.NET

# Install IronPDF
dotnet add package IronPdf
# Remove Adobe PDF Library
dotnet remove package Adobe.PDF.Library.LM.NET

# Install IronPDF
dotnet add package IronPdf
SHELL

Étape 2 : configuration de la clé de licence

Remplacez la licence Adobe par la clé de licenceIronPDFbasée sur le code :

// Replace Adobe's Library.LicenseKey withIronPDFlicense
// Add at application startup, before anyIronPDFoperations
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

// Verify license status
bool isLicensed = IronPdf.License.IsLicensed;
// Replace Adobe's Library.LicenseKey withIronPDFlicense
// Add at application startup, before anyIronPDFoperations
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

// Verify license status
bool isLicensed = IronPdf.License.IsLicensed;
IRON VB CONVERTER ERROR developers@ironsoftware.com
$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
utilisant Datalogics.PDFL; utiliser IronPdf;
utilisant Datalogics.PDFL.Document; utiliser IronPdf;
utilisant Datalogics.PDFL.Page; utiliser IronPdf;
utilisant Datalogics.PDFL.Content; utiliser IronPdf;

Etape 4 : Supprimer le code du cycle de vie de la bibliothèque

L'une des simplifications les plus importantes consiste à supprimer les modèles d'initialisation et de terminaison :

// Bibliothèque Adobe PDF SDK- REMOVE THIS PATTERN
Library.Initialize();
try
{
    // PDF operations
}
finally
{
    Library.Terminate(); // Must always terminate
}

//IronPDF- Just use directly
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
// Bibliothèque Adobe PDF SDK- REMOVE THIS PATTERN
Library.Initialize();
try
{
    // PDF operations
}
finally
{
    Library.Terminate(); // Must always terminate
}

//IronPDF- Just use directly
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

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

Méthodes de cycle de vie des bibliothèques

Méthode Adobe Équivalent d'IronPDF Notes
Library.Initialize() Pas nécessaire Initialisation automatique
Library.Terminate() Pas nécessaire Nettoyage automatique
Library.LicenseKey = "KEY" IronPdf.License.LicenseKey = "KEY" Définir une fois au démarrage
utilisant (Library lib = new Library()) Pas nécessaire Aucun wrapper n'est nécessaire

Méthodes de création de documents

Méthode Adobe Méthode IronPDF Notes
new Document() new ChromePdfRenderer() Renderer pour HTML
new Document(path) PdfDocument.FromFile(path) Charger le PDF existant
doc.CreatePage(index, rect) Automatique à partir de HTML Pages auto-créées
doc.Save(SaveFlags.Full, path) pdf.SaveAs(path) Enregistrer dans un fichier
doc.NumPages pdf.PageCount Propriété du nombre de pages
doc.GetPage(index) pdf.Pages[index] Page d'accès
doc.InsertPages(...) PdfDocument.Merge() Fusionner des documents

Création de contenu (changement de paradigme majeur)

Adobe PDF Library SDK nécessite une construction de contenu de bas niveau.IronPDFutilise HTML/CSS :

Méthode Adobe Méthode IronPDF Notes
new Text() Utilisez les codes HTML <p>, <h1>, etc. Balises HTML
text.AddRun(textRun) Utiliser HTML Texte via HTML
new TextRun(text, font, size, point) Style CSS Style via CSS
new Font(name, flags) CSS font-family Polices de caractères via CSS
new Image(path) HTML <img> balise Images via HTML
content.AddElement(...) Contenu HTML Construire avec HTML
page.UpdateContent() Pas nécessaire Automatique

Filigrane et méthodes de sécurité

Méthode Adobe Méthode IronPDF Notes
new Watermark(doc, textParams, wmParams) pdf.ApplyWatermark(html) Filigrane HTML
WatermarkParams.Opacity CSS opacité Opacité via CSS
new EncryptionHandler(user, owner, perms) pdf.SecuritySettings Configuration de la sécurité
PermissionFlags.PrintDoc AllowUserPrinting Autorisation d'impression

Extraction de texte

Méthode Adobe Méthode IronPDF Notes
nouveau WordFinder(doc, config) pdf.ExtractAllText() Extraction simple
wordFinder.GetWordList() pdf.Pages[i].Text Texte par page
Itération de mots/caractères complexes Appel de méthode unique Beaucoup plus simple

Exemples de migration de code

Conversion HTML en PDF

La simplification la plus spectaculaire se produit lors de la conversion du contenu en PDF. Bibliothèque Adobe PDF SDKnécessite la construction manuelle des pages, l'intégration des polices et le positionnement des coordonnées.

Mise en œuvre de la bibliothèque SDK d'Adobe PDF:

// Adobe PDF Library SDK
using Datalogics.PDFL;
using System;

class AdobeHtmlToPdf
{
    static void Main()
    {
        using (Library lib = new Library())
        {
            // Adobe PDF Library requires complex setup with HTML conversion parameters
            HTMLConversionParameters htmlParams = new HTMLConversionParameters();
            htmlParams.PaperSize = PaperSize.Letter;
            htmlParams.Orientation = Orientation.Portrait;

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

            // Convert HTML to PDF
            Document doc = Document.CreateFromHTML(htmlContent, htmlParams);
            doc.Save(SaveFlags.Full, "output.pdf");
            doc.Dispose();
        }
    }
}
// Adobe PDF Library SDK
using Datalogics.PDFL;
using System;

class AdobeHtmlToPdf
{
    static void Main()
    {
        using (Library lib = new Library())
        {
            // Adobe PDF Library requires complex setup with HTML conversion parameters
            HTMLConversionParameters htmlParams = new HTMLConversionParameters();
            htmlParams.PaperSize = PaperSize.Letter;
            htmlParams.Orientation = Orientation.Portrait;

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

            // Convert HTML to PDF
            Document doc = Document.CreateFromHTML(htmlContent, htmlParams);
            doc.Save(SaveFlags.Full, "output.pdf");
            doc.Dispose();
        }
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

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

class IronPdfHtmlToPdf
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";

        // Convert HTML to PDF with simple API
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class IronPdfHtmlToPdf
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        string htmlContent = "<html><body><h1>Hello World</h1></body></html>";

        // Convert HTML to PDF with simple API
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronPDF élimine l'enveloppe du cycle de vie de la bibliothèque, les objets de paramètres de conversion et l'élimination explicite. Le ChromePdfRendererutilise un moteur basé sur Chromium pour une prise en charge CSS et JavaScript parfaite au pixel près. Pour les scénarios avancés, consultez la documentation HTML vers PDF.

Fusionner plusieurs fichiers PDF

La fusion des PDF montre clairement la différence de complexité des API.

Mise en œuvre de la bibliothèque SDK d'Adobe PDF:

// Adobe PDF Library SDK
using Datalogics.PDFL;
using System;

class AdobeMergePdfs
{
    static void Main()
    {
        using (Library lib = new Library())
        {
            // Open first PDF document
            Document doc1 = new Document("document1.pdf");
            Document doc2 = new Document("document2.pdf");

            // Insert pages from second document into first
            PageInsertParams insertParams = new PageInsertParams();
            insertParams.InsertFlags = PageInsertFlags.None;

            for (int i = 0; i < doc2.NumPages; i++)
            {
                Page page = doc2.GetPage(i);
                doc1.InsertPage(doc1.NumPages - 1, page, insertParams);
            }

            doc1.Save(SaveFlags.Full, "merged.pdf");
            doc1.Dispose();
            doc2.Dispose();
        }
    }
}
// Adobe PDF Library SDK
using Datalogics.PDFL;
using System;

class AdobeMergePdfs
{
    static void Main()
    {
        using (Library lib = new Library())
        {
            // Open first PDF document
            Document doc1 = new Document("document1.pdf");
            Document doc2 = new Document("document2.pdf");

            // Insert pages from second document into first
            PageInsertParams insertParams = new PageInsertParams();
            insertParams.InsertFlags = PageInsertFlags.None;

            for (int i = 0; i < doc2.NumPages; i++)
            {
                Page page = doc2.GetPage(i);
                doc1.InsertPage(doc1.NumPages - 1, page, insertParams);
            }

            doc1.Save(SaveFlags.Full, "merged.pdf");
            doc1.Dispose();
            doc2.Dispose();
        }
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

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

class IronPdfMergePdfs
{
    static void Main()
    {
        // Load PDF documents
        var pdf1 = PdfDocument.FromFile("document1.pdf");
        var pdf2 = PdfDocument.FromFile("document2.pdf");

        // Merge PDFs with simple method
        var merged = PdfDocument.Merge(pdf1, pdf2);
        merged.SaveAs("merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class IronPdfMergePdfs
{
    static void Main()
    {
        // Load PDF documents
        var pdf1 = PdfDocument.FromFile("document1.pdf");
        var pdf2 = PdfDocument.FromFile("document2.pdf");

        // Merge PDFs with simple method
        var merged = PdfDocument.Merge(pdf1, pdf2);
        merged.SaveAs("merged.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

L'approche d'Adobe nécessite une itération page par page avec des paramètres d'insertion.IronPDFfournit une seule méthode Fusion qui accepte plusieurs documents.

Ajouter des filigranes

Le filigrane illustre la façon dontIronPDFtire parti de HTML/CSS pour la flexibilité du style.

Mise en œuvre de la bibliothèque SDK d'Adobe PDF:

// Adobe PDF Library SDK
using Datalogics.PDFL;
using System;

class AdobeAddWatermark
{
    static void Main()
    {
        using (Library lib = new Library())
        {
            Document doc = new Document("input.pdf");

            // Create watermark with complex API
            WatermarkParams watermarkParams = new WatermarkParams();
            watermarkParams.Opacity = 0.5;
            watermarkParams.Rotation = 45.0;
            watermarkParams.VerticalAlignment = WatermarkVerticalAlignment.Center;
            watermarkParams.HorizontalAlignment = WatermarkHorizontalAlignment.Center;

            WatermarkTextParams textParams = new WatermarkTextParams();
            textParams.Text = "CONFIDENTIAL";

            Watermark watermark = new Watermark(doc, textParams, watermarkParams);

            doc.Save(SaveFlags.Full, "watermarked.pdf");
            doc.Dispose();
        }
    }
}
// Adobe PDF Library SDK
using Datalogics.PDFL;
using System;

class AdobeAddWatermark
{
    static void Main()
    {
        using (Library lib = new Library())
        {
            Document doc = new Document("input.pdf");

            // Create watermark with complex API
            WatermarkParams watermarkParams = new WatermarkParams();
            watermarkParams.Opacity = 0.5;
            watermarkParams.Rotation = 45.0;
            watermarkParams.VerticalAlignment = WatermarkVerticalAlignment.Center;
            watermarkParams.HorizontalAlignment = WatermarkHorizontalAlignment.Center;

            WatermarkTextParams textParams = new WatermarkTextParams();
            textParams.Text = "CONFIDENTIAL";

            Watermark watermark = new Watermark(doc, textParams, watermarkParams);

            doc.Save(SaveFlags.Full, "watermarked.pdf");
            doc.Dispose();
        }
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Mise en œuvre d'IronPDF:

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

class IronPdfAddWatermark
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");

        // Apply text watermark with simple API
        pdf.ApplyWatermark("<h1 style='color:red; opacity:0.5;'>CONFIDENTIAL</h1>",
            rotation: 45,
            verticalAlignment: VerticalAlignment.Middle,
            horizontalAlignment: HorizontalAlignment.Center);

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

class IronPdfAddWatermark
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");

        // Apply text watermark with simple API
        pdf.ApplyWatermark("<h1 style='color:red; opacity:0.5;'>CONFIDENTIAL</h1>",
            rotation: 45,
            verticalAlignment: VerticalAlignment.Middle,
            horizontalAlignment: HorizontalAlignment.Center);

        pdf.SaveAs("watermarked.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Le filigrane basé sur HTML d'IronPDF permet un contrôle complet de la conception grâce au style CSS, ce qui élimine le besoin d'objets de paramètres distincts.

Protection et chiffrement des mots de passe

Mise en œuvre de la bibliothèque SDK d'Adobe PDF:

using Datalogics.PDFL;

public void ProtectPdf(string inputPath, string outputPath, string password)
{
    Library.Initialize();
    try
    {
        using (Document doc = new Document(inputPath))
        {
            PermissionFlags permissions =
                PermissionFlags.PrintDoc |
                PermissionFlags.PrintFidelity;

            EncryptionHandler encHandler = new EncryptionHandler(
                password,      // User password
                password,      // Owner password
                permissions,
                EncryptionMethod.AES256);

            doc.SetEncryptionHandler(encHandler);
            doc.Save(SaveFlags.Full | SaveFlags.Encrypted, outputPath);
        }
    }
    finally
    {
        Library.Terminate();
    }
}
using Datalogics.PDFL;

public void ProtectPdf(string inputPath, string outputPath, string password)
{
    Library.Initialize();
    try
    {
        using (Document doc = new Document(inputPath))
        {
            PermissionFlags permissions =
                PermissionFlags.PrintDoc |
                PermissionFlags.PrintFidelity;

            EncryptionHandler encHandler = new EncryptionHandler(
                password,      // User password
                password,      // Owner password
                permissions,
                EncryptionMethod.AES256);

            doc.SetEncryptionHandler(encHandler);
            doc.Save(SaveFlags.Full | SaveFlags.Encrypted, outputPath);
        }
    }
    finally
    {
        Library.Terminate();
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$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.UserPassword = password;
    pdf.SecuritySettings.OwnerPassword = 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.UserPassword = password;
    pdf.SecuritySettings.OwnerPassword = password;
    pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
    pdf.SecuritySettings.AllowUserCopyPasteContent = false;
    pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;

    pdf.SaveAs(outputPath);
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronPDF utilise des propriétés fortement typées au lieu de drapeaux de permission en bits et d'objets de gestion du chiffrement.

Extraction de texte

Mise en œuvre de la bibliothèque SDK d'Adobe PDF:

using Datalogics.PDFL;

public string ExtractText(string pdfPath)
{
    string extractedText = "";

    Library.Initialize();
    try
    {
        using (Document doc = new Document(pdfPath))
        {
            WordFinderConfig config = new WordFinderConfig();
            config.IgnoreCharGaps = true;

            for (int i = 0; i < doc.NumPages; i++)
            {
                using (WordFinder wordFinder = new WordFinder(doc, i, config))
                {
                    IList<Word> words = wordFinder.GetWordList();
                    foreach (Word word in words)
                    {
                        extractedText += word.Text + " ";
                    }
                    extractedText += "\n";
                }
            }
        }
    }
    finally
    {
        Library.Terminate();
    }

    return extractedText;
}
using Datalogics.PDFL;

public string ExtractText(string pdfPath)
{
    string extractedText = "";

    Library.Initialize();
    try
    {
        using (Document doc = new Document(pdfPath))
        {
            WordFinderConfig config = new WordFinderConfig();
            config.IgnoreCharGaps = true;

            for (int i = 0; i < doc.NumPages; i++)
            {
                using (WordFinder wordFinder = new WordFinder(doc, i, config))
                {
                    IList<Word> words = wordFinder.GetWordList();
                    foreach (Word word in words)
                    {
                        extractedText += word.Text + " ";
                    }
                    extractedText += "\n";
                }
            }
        }
    }
    finally
    {
        Library.Terminate();
    }

    return extractedText;
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$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();
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

L'itération mot à mot d'Adobe se transforme en un simple appel de méthode avec IronPDF.

En-têtes et pieds de page

Mise en œuvre de la bibliothèque SDK d'Adobe PDF:

using Datalogics.PDFL;

public void AddHeaderFooter(string inputPath, string outputPath)
{
    Library.Initialize();
    try
    {
        using (Document doc = new Document(inputPath))
        {
            Font font = new Font("Helvetica", FontCreateFlags.None);

            for (int i = 0; i < doc.NumPages; i++)
            {
                using (Page page = doc.GetPage(i))
                {
                    Content content = page.Content;

                    // Add header
                    Text header = new Text();
                    header.AddRun(new TextRun("Document Header",
                        font, 10, new Point(72, page.MediaBox.Top - 36)));
                    content.AddElement(header);

                    // Add footer with page number
                    Text footer = new Text();
                    footer.AddRun(new TextRun($"Page {i + 1} of {doc.NumPages}",
                        font, 10, new Point(72, 36)));
                    content.AddElement(footer);

                    page.UpdateContent();
                }
            }
            doc.Save(SaveFlags.Full, outputPath);
        }
    }
    finally
    {
        Library.Terminate();
    }
}
using Datalogics.PDFL;

public void AddHeaderFooter(string inputPath, string outputPath)
{
    Library.Initialize();
    try
    {
        using (Document doc = new Document(inputPath))
        {
            Font font = new Font("Helvetica", FontCreateFlags.None);

            for (int i = 0; i < doc.NumPages; i++)
            {
                using (Page page = doc.GetPage(i))
                {
                    Content content = page.Content;

                    // Add header
                    Text header = new Text();
                    header.AddRun(new TextRun("Document Header",
                        font, 10, new Point(72, page.MediaBox.Top - 36)));
                    content.AddElement(header);

                    // Add footer with page number
                    Text footer = new Text();
                    footer.AddRun(new TextRun($"Page {i + 1} of {doc.NumPages}",
                        font, 10, new Point(72, 36)));
                    content.AddElement(footer);

                    page.UpdateContent();
                }
            }
            doc.Save(SaveFlags.Full, outputPath);
        }
    }
    finally
    {
        Library.Terminate();
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$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 = "Document Header",
        FontSize = 10,
        FontFamily = "Helvetica"
    };

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

    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 = "Document Header",
        FontSize = 10,
        FontFamily = "Helvetica"
    };

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

    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs(outputPath);
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronPDF gère automatiquement l'itération des pages et prend en charge les jetons de remplacement tels que {page} et {total-pages}. Pour des mises en page plus avancées, consultez la documentation sur les en-têtes et les pieds de page.

Conversion d'URL en PDF

Adobe PDF Library SDK n'intègre pas de fonction de rendu d'URL.IronPDFassure la prise en charge native :

using IronPdf;

public void ConvertUrlToPdf(string url, string outputPath)
{
    var renderer = new ChromePdfRenderer();
    using var pdf = renderer.RenderUrlAsPdf(url);
    pdf.SaveAs(outputPath);
}
using IronPdf;

public void ConvertUrlToPdf(string url, string outputPath)
{
    var renderer = new ChromePdfRenderer();
    using var pdf = renderer.RenderUrlAsPdf(url);
    pdf.SaveAs(outputPath);
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Pour connaître l'ensemble des options de conversion d'URL, consultez la documentation sur les URL au format PDF.

Intégration d'ASP.NET Core

Le modèle d'initialisation statique d'Adobe PDF Library SDK crée des frictions avec l'injection de dépendances.IronPDFs'intègre naturellement aux architectures .NET modernes.

Adobe Pattern (problématique pour DI):

public class AdobePdfService
{
    public byte[] Generate(string content)
    {
        Library.Initialize();
        try
        {
            // Document complexeconstruction...
            return bytes;
        }
        finally
        {
            Library.Terminate();
        }
    }
}
public class AdobePdfService
{
    public byte[] Generate(string content)
    {
        Library.Initialize();
        try
        {
            // Document complexeconstruction...
            return bytes;
        }
        finally
        {
            Library.Terminate();
        }
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

ModèleIronPDF(DI-Friendly):

public interface IPdfService
{
    Task<byte[]> GeneratePdfAsync(string html);
}

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;
    }
}

// Register in Program.cs (.NET 6+):
builder.Services.AddSingleton<IPdfService, IronPdfService>();
public interface IPdfService
{
    Task<byte[]> GeneratePdfAsync(string html);
}

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;
    }
}

// Register in Program.cs (.NET 6+):
builder.Services.AddSingleton<IPdfService, IronPdfService>();
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Support asynchrone

Adobe PDF Library SDK ne prend pas en charge les opérations asynchrones.IronPDFoffre des fonctionnalités asynchrones/await complètes, essentielles pour les applications web évolutives :

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");
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Optimisation des performances

Comparaison de l'utilisation de la mémoire

Scénario Bibliothèque Adobe PDF SDK IronPDF Notes
PDF simple ~100 MB ~50 MB Adobe charge le moteur complet
Document complexe ~200 MB ~80 MB IronPDFplus efficace
Lot (100 PDF) Haut (mémoire native) ~100 MB IronPDFmieux géré

Conseils d'optimisation

Réutiliser les instances de rendu :

// Good: Reuse renderer for batch operations
var renderer = new ChromePdfRenderer();
foreach (var html in htmlList)
{
    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs($"output_{i}.pdf");
}
// Good: Reuse renderer for batch operations
var renderer = new ChromePdfRenderer();
foreach (var html in htmlList)
{
    using var pdf = renderer.RenderHtmlAsPdf(html);
    pdf.SaveAs($"output_{i}.pdf");
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Utiliser Async dans les applications Web:

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");
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Dépannage des problèmes de migration courants

Sujet : Le positionnement par coordonnées ne fonctionne pas

Adobe utilise les coordonnées de points PostScript.IronPDFutilise le positionnement CSS :

// Adobe: Point-based
new TextRun("Hello", font, 12, new Point(100, 700));

// IronPDF: CSS-based
string html = "<p style='position:absolute; left:100px; top:92px;'>Hello</p>";
// Adobe: Point-based
new TextRun("Hello", font, 12, new Point(100, 700));

// IronPDF: CSS-based
string html = "<p style='position:absolute; left:100px; top:92px;'>Hello</p>";
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Sujet : Différences de taille de page

Adobe utilise des points PostScript.IronPDFutilise des enums ou des dimensions personnalisées :

// Adobe: Points
Rect(0, 0, 612, 792) // Letter

// IronPDF: Enum or custom
renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter;
// Or custom:
renderer.RenderingOptions.SetCustomPaperSizeInInches(8.5, 11);
// Adobe: Points
Rect(0, 0, 612, 792) // Letter

// IronPDF: Enum or custom
renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter;
// Or custom:
renderer.RenderingOptions.SetCustomPaperSizeInInches(8.5, 11);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Problème : Police introuvable

Adobe exige l'intégration manuelle des polices.IronPDFgère automatiquement les polices de caractères :

// IronPDF: Use web fonts if needed
string html = @"
<style>
    @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
    body { font-family: 'Roboto', sans-serif; }
</style>";
// IronPDF: Use web fonts if needed
string html = @"
<style>
    @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
    body { font-family: 'Roboto', sans-serif; }
</style>";
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Sujet : SaveFlags non disponible

Adobe utilise des combinaisons de drapeaux de sauvegarde.IronPDFutilise l'enregistrement direct :

// Adobe
doc.Save(SaveFlags.Full | SaveFlags.Incremental, path);

//IronPDF- full save is default
pdf.SaveAs(path);
// Adobe
doc.Save(SaveFlags.Full | SaveFlags.Incremental, path);

//IronPDF- full save is default
pdf.SaveAs(path);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$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 sorties PDF avec les versions précédentes
  • [Tester tous les flux de travail PDF dans un environnement de mise à l'essai
  • [Vérifier que la licence fonctionne correctement (IronPdf.License.IsLicensed)
  • [La traduction doit rester professionnelle, en préservant la précision technique tout en expliquant les caractéristiques et les avantages de ces outils de développement
  • [Supprimer la configuration de la licence Adobe
  • [Mise à jour des dépendances du pipeline CI/CD
  • [Supprimer toutes les DLL de la bibliothèque Adobe PDF du projet
  • [Documenter de nouveaux modèles pour votre équipe de développement

Protéger l'avenir de votre infrastructure PDF

À l'approche de .NET 10 et de l'introduction de nouvelles fonctionnalités du langage C# 14, le choix d'une bibliothèque PDF .NET activement développée 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 s'étendent jusqu'en 2025 et 2026.

Ressources supplémentaires


La migration du SDK Adobe PDF Library versIronPDFsimplifie considérablement votre base de code de génération de PDF tout en réduisant les coûts de licence d'un ordre de grandeur. Le passage de la construction de pages de bas niveau au rendu HTML/CSS élimine des centaines de lignes de code de calcul des coordonnées, de gestion des polices et de traitement du cycle de vie. Pour les équipes qui créent des applications .NET modernes,IronPDFoffre des capacités équivalentes avec une API conviviale pour les développeurs, conçue pour les flux de travail de développement contemporains.

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