Ir para o conteúdo do rodapé
GUIAS DE MIGRAçãO

Como migrar do Easy PDF SDK para o IronPDF em C#

A BCL Technologies, editora original do easyPDF SDK, foi adquirida pela Apryse (anteriormente PDFTron) em março de 2020, e o produto agora está posicionado como um SDK legado ao lado do Apryse PDF SDK. O próprio SDK depende de várias tecnologias legadas que criam desafios de implantação e manutenção em ambientes de desenvolvimento modernos.

Problemas comuns de implantação do SDK Easy PDF

Os desenvolvedores frequentemente se deparam com esses problemas ao trabalhar com o Easy PDF SDK:

  • bcl.easypdf.interop.easypdfprinter.dll error loading
  • COM object that has been separated from its underlying RCW cannot be used
  • Timeout expired waiting for print job to complete
  • The printer operation failed because the service is not running
  • Error: Access denied (sessão interativa necessária)
  • Cannot find printer: BCL easyPDF Printer

Esses erros geralmente decorrem da arquitetura do Easy PDF SDK, que depende de drivers de impressora virtual, interoperabilidade COM e sessões interativas do Windows que são difíceis de reproduzir em ambientes de servidor modernos.

SDK de PDF fácil vs. IronPDF: Principais diferenças

Recurso SDK de PDF fácil IronPDF
Plataforma Exclusivo para Windows Windows, Linux, macOS, Docker
Dependência do escritório Obrigatório None
Distribuição Instalador MSI + referências manuais a DLLs (sem pacote NuGet) Pacote NuGet (IronPdf)
Instalação MSI + driver de impressora virtual + registro COM Pacote NuGet
Suporte ao servidor Normalmente requer uma sessão interativa do Windows Executa sem monitor
Renderização HTML Básico (para escritório) Chromium completo (CSS3, JS)
Suporte .NET .NET Core limitado .NET Framework 4.6.2+ e .NET 5/6/7/8/9
Padrão Assíncrono Baseado em retorno de chamada assíncrono/await nativo
Suporte a contêineres Não suportado pelo fornecedor Docker/Kubernetes completo

Limitações da plataforma

O SDK de PDF fácil tem como alvo o Windows e depende de instalações do Microsoft Office para conversões de documentos do Office, o que limita seu uso em Linux, macOS e ambientes em contêiner, como Docker. Essa dependência tende a tornar a configuração do servidor mais complexa e vincular a implantação ao Windows — uma restrição para equipes que praticam DevOps multiplataforma ou que dependem de contêineres Linux.

Preparação pré-migratória

Pré-requisitos

Certifique-se de que seu ambiente atenda a estes requisitos:

  • .NET Framework 4.6.2 ou superior ou .NET Core 3.1 / .NET 5-9
  • Visual Studio 2019 ou superior ou VS Code com extensão C#
  • Acesso ao Gerenciador de Pacotes NuGet
  • Chave de licença do IronPDF(teste gratuito disponível em IronPDF )

Auditoria de uso do SDK Easy PDF

Execute estes comandos no diretório da sua solução para identificar todas as referências ao Easy PDF SDK:

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

# Find Printer/PDFDocument usage
grep -r "Printer\|PDFDocument\|PDFConverter\|HTMLConverter" --include="*.cs" .

# Find COM interop references
grep -r "easyPDF\|BCL.easyPDF" --include="*.csproj" .

# Find configuration settings
grep -r "PageOrientation\|TimeOut\|PrintOffice" --include="*.cs" .
# Find all BCL using statements
grep -r "using BCL" --include="*.cs" .

# Find Printer/PDFDocument usage
grep -r "Printer\|PDFDocument\|PDFConverter\|HTMLConverter" --include="*.cs" .

# Find COM interop references
grep -r "easyPDF\|BCL.easyPDF" --include="*.csproj" .

# Find configuration settings
grep -r "PageOrientation\|TimeOut\|PrintOffice" --include="*.cs" .
SHELL

Mudanças significativas a serem previstas

Padrão SDK de PDF fácil Alteração necessária
new Printer() Use ChromePdfRenderer
PrintOfficeDocToPDF() A conversão do escritório foi tratada de forma diferente.
RenderHTMLToPDF() RenderHtmlAsPdf()
Referências de interoperabilidade COM Remover completamente
Configuração do driver da impressora Não é necessário
Callbacks BeginPrintToFile() assíncrono/await nativo
Requisitos da sessão interativa Executa sem monitor
indexação de páginas baseada em 1 indexação baseada em 0
Tempo limite em segundos Tempo limite em milissegundos

Processo de migração passo a passo

Passo 1: Remova o Easy PDF SDK

Easy PDF SDK é distribuído como um instalador MSI ao invés de um pacote NuGet, e os projetos geralmente fazem referência às suas assemblies (como BCL.easyPDF.PDFConverter.dll for .NET Framework ou BCL.easyPDF.PDFConverter.NetCore.dll for .NET Core) diretamente. Remover todas as referências:

  1. Desinstale o BCL EasyPDF SDK em Programas e Recursos.
  2. Remova entradas de DLL <Reference> do seu .csproj
  3. Remover referências de interoperabilidade COM
  4. Limpe as entradas do GAC, se presentes.

Passo 2: Instale o IronPDF

# Install IronPDF
dotnet add package IronPdf
# Install IronPDF
dotnet add package IronPdf
SHELL

Ou através do Console do Gerenciador de Pacotes:

Install-Package IronPdf

Etapa 3: Atualizar referências de namespace

Substitua os namespaces do SDK de PDF fácil pelo IronPDF:

// Remove these
using BCL.easyPDF;
using BCL.easyPDF.PDFConverter;
using BCL.easyPDF.PDFProcessor;
using BCL.easyPDF.Printer;

// Add these
using IronPdf;
using IronPdf.Rendering;
// Remove these
using BCL.easyPDF;
using BCL.easyPDF.PDFConverter;
using BCL.easyPDF.PDFProcessor;
using BCL.easyPDF.Printer;

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

Referência completa para migração de API

Mapeamento de Classes Principais

Classe SDK de PDF fácil Equivalente ao IronPDF
Printer ChromePdfRenderer
PDFDocument PdfDocument
HTMLConverter ChromePdfRenderer
PrinterConfiguration ChromePdfRenderOptions
PageOrientation PdfPaperOrientation
PageSize PdfPaperSize
SecurityHandler PdfDocument.SecuritySettings

Métodos de criação de PDFs

Método fácil para o SDK de PDF Método IronPDF
printer.RenderHTMLToPDF(html, path) renderer.RenderHtmlAsPdf(html).SaveAs(path)
printer.RenderUrlToPDF(url, path) renderer.RenderUrlAsPdf(url).SaveAs(path)
htmlConverter.ConvertHTML(html, doc) renderer.RenderHtmlAsPdf(html)
htmlConverter.ConvertURL(url, doc) renderer.RenderUrlAsPdf(url)

Métodos de manipulação de PDF

Método fácil para o SDK de PDF Método IronPDF
doc.Append(doc2) PdfDocument.Merge(pdf1, pdf2)
doc.ExtractPages(start, end) pdf.CopyPages(start, end)
doc.DeletePage(index) pdf.RemovePages(index)
doc.GetPageCount() pdf.PageCount
doc.Save(path) pdf.SaveAs(path)
doc.Close() pdf.Dispose() ou using
doc.ExtractText() pdf.ExtractAllText()

Opções de configuração

Opção SDK de PDF fácil Opção IronPDF
config.TimeOut RenderingOptions.Timeout
config.PageOrientation = Landscape RenderingOptions.PaperOrientation = Landscape
config.PageSize = A4 RenderingOptions.PaperSize = PdfPaperSize.A4
config.MarginTop/Bottom/Left/Right RenderingOptions.MarginTop, etc.

Exemplos de migração de código

String HTML para PDF

Implementação simplificada do SDK para PDF:

// Reference BCL.easyPDF.PDFConverter.dll (or the .NetCore variant)
// installed by the easyPDF SDK MSI — there is no NuGet package.
using BCL.easyPDF;
using System;

class Program
{
    static void Main()
    {
        var pdf = new PDFDocument();
        var htmlConverter = new HTMLConverter();
        htmlConverter.ConvertHTML("<h1>Hello World</h1>", pdf);
        pdf.Save("output.pdf");
        pdf.Close();
    }
}
// Reference BCL.easyPDF.PDFConverter.dll (or the .NetCore variant)
// installed by the easyPDF SDK MSI — there is no NuGet package.
using BCL.easyPDF;
using System;

class Program
{
    static void Main()
    {
        var pdf = new PDFDocument();
        var htmlConverter = new HTMLConverter();
        htmlConverter.ConvertHTML("<h1>Hello World</h1>", pdf);
        pdf.Save("output.pdf");
        pdf.Close();
    }
}
Imports BCL.easyPDF
Imports System

Class Program
    Shared Sub Main()
        Dim pdf As New PDFDocument()
        Dim htmlConverter As New HTMLConverter()
        htmlConverter.ConvertHTML("<h1>Hello World</h1>", pdf)
        pdf.Save("output.pdf")
        pdf.Close()
    End Sub
End Class
$vbLabelText   $csharpLabel

Implementação do IronPDF:

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

class Program
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
        Dim renderer As New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF integra renderização HTML em uma única chamada de renderizador e permite que Dispose cuidem da limpeza, eliminando a etapa HTMLConverter separada e o padrão manual Close().

Conversão de URL para PDF

Implementação simplificada do SDK para PDF:

// Reference BCL.easyPDF.PDFConverter.dll (or the .NetCore variant)
// installed by the easyPDF SDK MSI — there is no NuGet package.
using BCL.easyPDF;
using System;

class Program
{
    static void Main()
    {
        var pdf = new PDFDocument();
        var htmlConverter = new HTMLConverter();
        htmlConverter.ConvertURL("https://example.com", pdf);
        pdf.Save("webpage.pdf");
        pdf.Close();
    }
}
// Reference BCL.easyPDF.PDFConverter.dll (or the .NetCore variant)
// installed by the easyPDF SDK MSI — there is no NuGet package.
using BCL.easyPDF;
using System;

class Program
{
    static void Main()
    {
        var pdf = new PDFDocument();
        var htmlConverter = new HTMLConverter();
        htmlConverter.ConvertURL("https://example.com", pdf);
        pdf.Save("webpage.pdf");
        pdf.Close();
    }
}
Imports BCL.easyPDF
Imports System

Class Program
    Shared Sub Main()
        Dim pdf As New PDFDocument()
        Dim htmlConverter As New HTMLConverter()
        htmlConverter.ConvertURL("https://example.com", pdf)
        pdf.Save("webpage.pdf")
        pdf.Close()
    End Sub
End Class
$vbLabelText   $csharpLabel

Implementação do IronPDF:

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

class Program
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
Imports IronPdf
Imports System

Module Program
    Sub Main()
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
        Dim renderer As New ChromePdfRenderer()
        Dim pdf = renderer.RenderUrlAsPdf("https://example.com")
        pdf.SaveAs("webpage.pdf")
    End Sub
End Module
$vbLabelText   $csharpLabel

Unir vários PDFs

Implementação simplificada do SDK para PDF:

// Reference BCL.easyPDF.PDFConverter.dll (or the .NetCore variant)
// installed by the easyPDF SDK MSI — there is no NuGet package.
using BCL.easyPDF;
using System;

class Program
{
    static void Main()
    {
        var pdf1 = new PDFDocument("document1.pdf");
        var pdf2 = new PDFDocument("document2.pdf");
        pdf1.Append(pdf2);
        pdf1.Save("merged.pdf");
        pdf1.Close();
        pdf2.Close();
    }
}
// Reference BCL.easyPDF.PDFConverter.dll (or the .NetCore variant)
// installed by the easyPDF SDK MSI — there is no NuGet package.
using BCL.easyPDF;
using System;

class Program
{
    static void Main()
    {
        var pdf1 = new PDFDocument("document1.pdf");
        var pdf2 = new PDFDocument("document2.pdf");
        pdf1.Append(pdf2);
        pdf1.Save("merged.pdf");
        pdf1.Close();
        pdf2.Close();
    }
}
Imports BCL.easyPDF
Imports System

Module Program
    Sub Main()
        Dim pdf1 As New PDFDocument("document1.pdf")
        Dim pdf2 As New PDFDocument("document2.pdf")
        pdf1.Append(pdf2)
        pdf1.Save("merged.pdf")
        pdf1.Close()
        pdf2.Close()
    End Sub
End Module
$vbLabelText   $csharpLabel

Implementação do IronPDF:

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

class Program
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
        var pdfs = new List<PdfDocument>
        {
            PdfDocument.FromFile("document1.pdf"),
            PdfDocument.FromFile("document2.pdf")
        };
        var merged = PdfDocument.Merge(pdfs);
        merged.SaveAs("merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
        var pdfs = new List<PdfDocument>
        {
            PdfDocument.FromFile("document1.pdf"),
            PdfDocument.FromFile("document2.pdf")
        };
        var merged = PdfDocument.Merge(pdfs);
        merged.SaveAs("merged.pdf");
    }
}
Imports IronPdf
Imports System
Imports System.Collections.Generic

Module Program
    Sub Main()
        IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
        Dim pdfs As New List(Of PdfDocument) From {
            PdfDocument.FromFile("document1.pdf"),
            PdfDocument.FromFile("document2.pdf")
        }
        Dim merged = PdfDocument.Merge(pdfs)
        merged.SaveAs("merged.pdf")
    End Sub
End Module
$vbLabelText   $csharpLabel

O método estático Merge do IronPDF aceita uma coleção de documentos diretamente, substituindo o padrão pareado Append.

Proteção por senha

Implementação do IronPDF:

using IronPdf;

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Confidential</h1>");

// Set security
pdf.SecuritySettings.UserPassword = "user123";
pdf.SecuritySettings.OwnerPassword = "owner456";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;

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

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Confidential</h1>");

// Set security
pdf.SecuritySettings.UserPassword = "user123";
pdf.SecuritySettings.OwnerPassword = "owner456";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit;

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

Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Confidential</h1>")

' Set security
pdf.SecuritySettings.UserPassword = "user123"
pdf.SecuritySettings.OwnerPassword = "owner456"
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserEdits = PdfEditSecurity.NoEdit

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

Cabeçalhos e rodapés

O SDK de PDF fácil não expõe APIs de cabeçalho/rodapé dedicadas em sua conversão HTML; cabeçalhos e rodapés normalmente são incorporados diretamente no HTML de origem.IronPDF fornece objetos de cabeçalho/rodapé dedicados:

using IronPdf;

var renderer = new ChromePdfRenderer();

renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter
{
    HtmlFragment = @"
        <div style='text-align:center; font-size:12px; font-family:Arial;'>
            Company Name - Confidential
        </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; font-family:Arial;'>
            Company Name - Confidential
        </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; font-family:Arial;'>
            Company Name - Confidential
        </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

Para mais opções, consulte a documentação sobre cabeçalhos e rodapés .

Geração assíncrona de PDF

O SDK de PDF fácil utiliza padrões assíncronos baseados em callbacks. O IronPDF oferece suporte nativo a async/await:

Implementação simplificada do SDK para PDF:

using BCL.easyPDF;

Printer printer = new Printer();

// BCL uses callback-based async
printer.BeginPrintToFile(
    "https://example.com",
    "output.pdf",
    OnPrintComplete,
    OnPrintError
);

Console.ReadLine();
printer.Dispose();
using BCL.easyPDF;

Printer printer = new Printer();

// BCL uses callback-based async
printer.BeginPrintToFile(
    "https://example.com",
    "output.pdf",
    OnPrintComplete,
    OnPrintError
);

Console.ReadLine();
printer.Dispose();
Imports BCL.easyPDF

Dim printer As New Printer()

' BCL uses callback-based async
printer.BeginPrintToFile( _
    "https://example.com", _
    "output.pdf", _
    AddressOf OnPrintComplete, _
    AddressOf OnPrintError _
)

Console.ReadLine()
printer.Dispose()
$vbLabelText   $csharpLabel

Implementação do IronPDF:

using IronPdf;
using System.Threading.Tasks;

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

        // Native async/await
        var pdf = await renderer.RenderUrlAsPdfAsync("https://example.com");
        await pdf.SaveAsAsync("output.pdf");

        Console.WriteLine("PDF created: output.pdf");
    }
}
using IronPdf;
using System.Threading.Tasks;

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

        // Native async/await
        var pdf = await renderer.RenderUrlAsPdfAsync("https://example.com");
        await pdf.SaveAsAsync("output.pdf");

        Console.WriteLine("PDF created: output.pdf");
    }
}
Imports IronPdf
Imports System.Threading.Tasks

Class Program
    Shared Async Function Main() As Task
        Dim renderer = New ChromePdfRenderer()

        ' Native async/await
        Dim pdf = Await renderer.RenderUrlAsPdfAsync("https://example.com")
        Await pdf.SaveAsAsync("output.pdf")

        Console.WriteLine("PDF created: output.pdf")
    End Function
End Class
$vbLabelText   $csharpLabel

Notas críticas sobre migração

Alteração do índice da página

O SDK de PDF fácil utiliza indexação baseada em 1. O IronPDF utiliza indexação baseada em zero:

// Easy PDF SDK: 1-based
doc.ExtractPages(1, 5);

// IronPDF: 0-based
pdf.CopyPages(0, 4);
// Easy PDF SDK: 1-based
doc.ExtractPages(1, 5);

// IronPDF: 0-based
pdf.CopyPages(0, 4);
' Easy PDF SDK: 1-based
doc.ExtractPages(1, 5)

' IronPDF: 0-based
pdf.CopyPages(0, 4)
$vbLabelText   $csharpLabel

Tempo limite em milissegundos

O SDK de PDF fácil usa segundos para os valores de tempo limite. O IronPDF usa milissegundos:

// Easy PDF SDK: seconds
config.TimeOut = 120;

// IronPDF: milliseconds
renderer.RenderingOptions.Timeout = 120000;
// Easy PDF SDK: seconds
config.TimeOut = 120;

// IronPDF: milliseconds
renderer.RenderingOptions.Timeout = 120000;
' Easy PDF SDK: seconds
config.TimeOut = 120

' IronPDF: milliseconds
renderer.RenderingOptions.Timeout = 120000
$vbLabelText   $csharpLabel

Integração com ASP.NET Core

O SDK de PDF fácil apresenta dificuldades em contextos web devido aos requisitos de sessão interativa.

Padrão 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.BinaryData, "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.BinaryData, "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.BinaryData, "application/pdf", "report.pdf")
    End Function
End Class
$vbLabelText   $csharpLabel

Implantação do Docker

O SDK de PDF fácil não foi projetado para contêineres Linux — sua configuração suportada é Windows com Microsoft Office, um driver de impressora virtual e (na maioria das configurações) uma sessão de desktop interativa, o que torna os fluxos de trabalho típicos em Docker baseados em Linux impraticáveis.

Configuração do IronPDF no Docker:

FROM mcr.microsoft.com/dotnet/aspnet:8.0

# Install Chromium dependencies
RUN apt-get update && apt-get install -y \
    libc6 libgdiplus libx11-6 libxcomposite1 \
    libxdamage1 libxrandr2 libxss1 libxtst6 \
    libnss3 libatk-bridge2.0-0 libgtk-3-0 \
    libgbm1 libasound2 fonts-liberation \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "MyApp.dll"]

Solução de problemas comuns de migração

Problema: Impressora não encontrada

Sintoma: Cannot find printer: BCL easyPDF Printer

Solução: O IronPDF não precisa de drivers de impressora:

// Just use the renderer directly
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
// Just use the renderer directly
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(html)
$vbLabelText   $csharpLabel

Problema: Erros de interoperabilidade COM

Sintoma: erros DLL error loading ou RCW

Solução: Remova todas as referências COM e utilize a API gerenciada do IronPDF.

Problema: Tempo limite excedido no servidor

Sintoma: A geração de PDFs trava no servidor web.

Solução: O IronPDF funciona sem interface gráfica, dispensando sessões interativas:

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.Timeout = 60000; // Reliable timeout
var pdf = renderer.RenderHtmlAsPdf(html);
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.Timeout = 60000; // Reliable timeout
var pdf = renderer.RenderHtmlAsPdf(html);
Dim renderer = New ChromePdfRenderer()
renderer.RenderingOptions.Timeout = 60000 ' Reliable timeout
Dim pdf = renderer.RenderHtmlAsPdf(html)
$vbLabelText   $csharpLabel

Problema: O fundo não está sendo impresso.

Sintoma: Ausência de fundos CSS

Solução: Ativar a impressão em segundo plano:

renderer.RenderingOptions.PrintHtmlBackgrounds = true;
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
renderer.RenderingOptions.PrintHtmlBackgrounds = True
$vbLabelText   $csharpLabel

Lista de verificação pós-migração

Após concluir a migração do código, verifique o seguinte:

  • Verifique a qualidade da saída em PDF com o mecanismo Chromium do IronPDF.
  • Teste todos os casos extremos com HTML/CSS complexo
  • Validar se a implantação do servidor funciona sem sessões interativas.
  • Testar a implantação de contêineres/Docker
  • Remover o instalador do BCL EasyPDF da implantação
  • Remover a instalação do Office dos servidores (não é mais necessária)
  • Atualize os pipelines de CI/CD com o novo pacote NuGet.

Recursos adicionais


Migrar do SDK de PDF fácil para IronPDF remove o driver de impressora virtual, a interoperabilidade COM e as restrições somente para Windows do caminho de geração de PDF. A renderização baseada em Chromium traz suporte moderno ao CSS3 e JavaScript, e a mesma base de código é executada no Docker, Kubernetes e em ambientes de nuvem baseados em Linux que são difíceis de direcionar com o modelo de implantação suportado pelo easyPDF SDK.

ObserveBCL easyPDF SDK, SDK de PDF fácil e Apryse são marcas registradas de seus respectivos proprietários. Este site não é afiliado, endossado ou patrocinado pela BCL Technologies ou Apryse. Todos os nomes de produtos, logotipos e marcas são propriedade de seus respectivos proprietários. As comparações são apenas para fins informativos e refletem informações disponíveis publicamente no momento da redação.

Curtis Chau
Redator Técnico

Curtis Chau é bacharel em Ciência da Computação (Universidade Carleton) e se especializa em desenvolvimento front-end, com experiência em Node.js, TypeScript, JavaScript e React. Apaixonado por criar interfaces de usuário intuitivas e esteticamente agradáveis, Curtis gosta de trabalhar com frameworks modernos e criar manuais ...

Leia mais

Equipe de Suporte Iron

Estamos online 24 horas por dia, 5 dias por semana.
Bater papo
E-mail
Liga para mim