Como migrar do PDFPrinting.NET para o IronPDF em C#
A migração do PDFPrinting .NET para o IronPDF expande suas capacidades de PDF, transformando-o de uma biblioteca voltada apenas para impressão em uma solução abrangente que lida com todo o ciclo de vida do PDF, incluindo criação, manipulação, extração, segurança e impressão. Este guia fornece um caminho de migração completo, passo a passo, que preserva seus fluxos de trabalho de impressão existentes, ao mesmo tempo que adiciona recursos de geração de PDF, conversão para HTML e suporte multiplataforma.
Por que migrar do PDFPrinting .NET para o IronPDF?
Entendendo a impressão em PDF no .NET
PDFPrinting.NET (Terminalworks; NuGet PdfPrintingNet) é uma biblioteca especializada focada em impressão silenciosa de PDF em ambientes Windows. Como uma ferramenta dedicada focada na impressão silenciosa de PDFs existentes, simplifica a tarefa de enviar documentos para uma impressora programaticamente sem intervenção do usuário. O novo ponto de entrada é a classe PdfPrint; códigos mais antigos ainda podem referenciar o legado TerminalWorks.PDFPrinting.PDFPrinter.
Um ponto forte central é a impressão silenciosa — ignorar as janelas de diálogo de impressão usuais para que os fluxos de trabalho totalmente automatizados possam ser executados sem intervenção.
A Limitação Centrada na Impressão
PDFPrinting.NET concentra-se em um conjunto estreito de operações e não autoriza novo conteúdo PDF. Seu escopo é imprimir, visualizar, editar basicamente e rasterizar documentos existentes:
-
Centricidade na impressão: Não autoriza novo conteúdo PDF — apenas imprime, visualiza, edita e rasteriza PDFs pré-existentes.
-
Impressão apenas em Windows: Amarrado à infraestrutura de impressão do Windows, o que limita a usabilidade multiplataforma.
-
Sem API de HTML/URL para PDF: Não há
HtmlToPdfConvertere não há classeWebPageToPdfConverter— esses recursos não existem na superfície da API. -
Manipulação limitada: Mesclagem/divisão/extração básica está disponível através de
PdfPrintDocument; não há marca d'água ou autoria de conteúdo moderno. -
Sem superfície abrangente de extração de texto.
- Sem preenchimento ou achatamento de formulário.
Comparação entre PDFPrinting .NET e IronPDF
| Recurso | PDFPrinting.NET | IronPDF |
|---|---|---|
| Funcionalidade principal | Impressão silenciosa de PDF | Manipulação completa do ciclo (criar, editar, imprimir) |
| Suporte da plataforma | Somente para Windows | Multiplataforma |
| Capacidade de criação/manipulação de PDFs | Não | Sim |
| Conversão de HTML para PDF | Não | Sim |
| Adequação para fluxos de trabalho automatizados | Alto | Alto |
| Dependências adicionais | Depende de impressoras do Windows | Mecanismo de navegador interno para renderização |
| Impressão silenciosa | Sim | Sim |
| Extração de texto | Não suportado | Apoiado |
| Licenciamento | Comercial | Comercial |
O IronPDF apresenta uma solução mais abrangente, abordando todo o ciclo de vida do processamento de PDFs. Facilita a criação, edição, conversão e impressão de documentos PDF, oferecendo aos desenvolvedores um conjunto completo de recursos por meio de uma API unificada. Diferentemente do PDFPrinting .NET, o IronPDF pode ser implementado em diferentes plataformas, tornando-se uma opção versátil para aplicações que operam em diversos ambientes.
Para equipes em .NET moderno, o IronPDF oferece uma solução completa de PDF que funciona em ambientes Windows, Linux e macOS.
Antes de começar
Pré-requisitos
- Ambiente .NET : .NET Framework 4.6.2+ ou .NET Core 3.1+ / .NET 5/6/7/8/9+
- Acesso ao NuGet : Capacidade de instalar pacotes NuGet.
- Licença do IronPDF: Obtenha sua chave de licença em IronPDF
Alterações no pacote NuGet
# Remove PDFPrinting.NET (the actual NuGet ID is PdfPrintingNet)
dotnet remove package PdfPrintingNet
# Install IronPDF
dotnet add package IronPdf
# Remove PDFPrinting.NET (the actual NuGet ID is PdfPrintingNet)
dotnet remove package PdfPrintingNet
# Install IronPDF
dotnet add package IronPdf
Configuração de licença
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup (Program.vb or Startup.vb)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Identificar o uso do PDFPrinting .NET
# Find PDFPrinting.NET usage (newer + legacy namespaces)
grep -rE "PdfPrintingNet|TerminalWorks\.PDFPrinting|PdfPrint\b|PdfPrintDocument|PDFPrinter" --include="*.cs" .
# Find print-related code
grep -r "\.Print(\|PrinterName\|GetPrintDocument" --include="*.cs" .
# Find PDFPrinting.NET usage (newer + legacy namespaces)
grep -rE "PdfPrintingNet|TerminalWorks\.PDFPrinting|PdfPrint\b|PdfPrintDocument|PDFPrinter" --include="*.cs" .
# Find print-related code
grep -r "\.Print(\|PrinterName\|GetPrintDocument" --include="*.cs" .
Referência completa da API
Alterações de namespace
// Before: PDFPrinting.NET
// Newer API:
using PdfPrintingNet;
// Older code may use:
using TerminalWorks.PDFPrinting;
// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Printing;
// Before: PDFPrinting.NET
// Newer API:
using PdfPrintingNet;
// Older code may use:
using TerminalWorks.PDFPrinting;
// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Printing;
' Before: PDFPrinting.NET
' Newer API:
Imports PdfPrintingNet
' Older code may use:
Imports TerminalWorks.PDFPrinting
' After: IronPDF
Imports IronPdf
Imports IronPdf.Rendering
Imports IronPdf.Printing
Mapeamentos de Classes Principais
| PDFPrinting.NET | IronPDF |
|---|---|
PdfPrint (mais recente) / PDFPrinter (legado) |
PdfDocument + Print() |
PdfPrintDocument |
PdfDocument |
| (nenhuma classe HTML-to-PDF existe) | ChromePdfRenderer.RenderHtmlAsPdf |
| (nenhuma classe URL-to-PDF existe) | ChromePdfRenderer.RenderUrlAsPdf |
| Propriedades de configurações de impressão | PrintSettings |
Mapeamentos de Métodos de Impressão
| PDFPrinting.NET | IronPDF |
|---|---|
pdfPrint.Print(filePath) |
pdf.Print() |
pdfPrint.PrinterName = "..."; pdfPrint.Print(caminho) |
pdf.Print(printerName) |
new PdfPrintDocument(...) |
pdf.GetPrintDocument() |
pdfPrint.Copies = n |
printSettings.NumberOfCopies = n |
pdfPrint.Duplex = true |
printSettings.DuplexMode = Duplex.Vertical |
pdfPrint.Collate = true |
printSettings.Collate = true |
Novos recursos não disponíveis no PDFPrinting .NET
| Recurso IronPDF | Descrição |
|---|---|
renderer.RenderHtmlAsPdf(html) |
Conversão de HTML para PDF |
renderer.RenderUrlAsPdf(url) |
Conversão de URL para PDF |
PdfDocument.Merge(pdfs) |
Mesclar vários PDFs |
pdf.ApplyWatermark(html) |
Adicionar marcas d'água |
pdf.SecuritySettings.UserPassword |
Proteção por senha |
pdf.ExtractAllText() |
Extração de texto |
Exemplos de migração de código
Exemplo 1: Conversão de HTML para PDF
Antes (PDFPrinting.NET): PDFPrinting.NET não possui API de HTML para PDF — não há classe HtmlToPdfConverter. O fluxo de trabalho mais próximo é gerar o PDF com outra biblioteca e depois imprimir ou entregar o arquivo:
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;
class Program
{
static void Main()
{
// Step 1: Produce the PDF with another library (PDFPrinting.NET cannot).
// Step 2: Print the existing PDF file.
var pdfPrint = new PdfPrint("license-owner", "license-key");
var status = pdfPrint.Print("output.pdf");
Console.WriteLine($"Printed: {status}");
}
}
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;
class Program
{
static void Main()
{
// Step 1: Produce the PDF with another library (PDFPrinting.NET cannot).
// Step 2: Print the existing PDF file.
var pdfPrint = new PdfPrint("license-owner", "license-key");
var status = pdfPrint.Print("output.pdf");
Console.WriteLine($"Printed: {status}");
}
}
Imports PdfPrintingNet
Imports System
Class Program
Shared Sub Main()
' Step 1: Produce the PDF with another library (PDFPrinting.NET cannot).
' Step 2: Print the existing PDF file.
Dim pdfPrint = New PdfPrint("license-owner", "license-key")
Dim status = pdfPrint.Print("output.pdf")
Console.WriteLine($"Printed: {status}")
End Sub
End Class
Após (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
string html = "<html><body><h1>Hello World</h1></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
string html = "<html><body><h1>Hello World</h1></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully");
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer As New ChromePdfRenderer()
Dim html As String = "<html><body><h1>Hello World</h1></body></html>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
Console.WriteLine("PDF created successfully")
End Sub
End Class
Como o PDFPrinting.NET não pode autorar PDFs de forma alguma, a migração não é uma troca de classe um-para-um — é adotar uma nova capacidade. IronPDF's ChromePdfRenderer.RenderHtmlAsPdf() retorna um PdfDocument que você pode manipular (marca d'água, mesclagem, segurança) antes de salvar com SaveAs(). Aproveitando um motor baseado em Chromium, o IronPDF replica a renderização moderna de CSS e JavaScript com alta fidelidade. Consulte a documentação de conversão de HTML para PDF para obter exemplos completos.
Exemplo 2: Conversão de URL para PDF
Antes (PDFPrinting.NET): Não há classe WebPageToPdfConverter — PDFPrinting.NET não faz download nem renderiza páginas web. Uma biblioteca separada deve capturar a URL como PDF primeiro; o PDFPrinting.NET pode então imprimir o arquivo resultante:
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;
class Program
{
static void Main()
{
// Step 1: Capture the URL with another library (PDFPrinting.NET cannot).
// Step 2: Print the resulting PDF.
var pdfPrint = new PdfPrint("license-owner", "license-key");
var status = pdfPrint.Print("webpage.pdf");
Console.WriteLine($"Printed: {status}");
}
}
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;
class Program
{
static void Main()
{
// Step 1: Capture the URL with another library (PDFPrinting.NET cannot).
// Step 2: Print the resulting PDF.
var pdfPrint = new PdfPrint("license-owner", "license-key");
var status = pdfPrint.Print("webpage.pdf");
Console.WriteLine($"Printed: {status}");
}
}
Imports PdfPrintingNet
Imports System
Class Program
Shared Sub Main()
' Step 1: Capture the URL with another library (PDFPrinting.NET cannot).
' Step 2: Print the resulting PDF.
Dim pdfPrint As New PdfPrint("license-owner", "license-key")
Dim status = pdfPrint.Print("webpage.pdf")
Console.WriteLine($"Printed: {status}")
End Sub
End Class
Após (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
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");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
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
Module Program
Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer As 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 Module
IronPDF usa uma única classe ChromePdfRenderer tanto para strings HTML quanto para URLs, com RenderUrlAsPdf() lidando com a captura da web em uma única chamada. Saiba mais em nossos tutoriais .
Exemplo 3: Cabeçalhos e Rodapés
Antes (PDFPrinting.NET): PDFPrinting.NET não pode autorar cabeçalhos ou rodapés — não gera PDFs a partir de HTML ou qualquer outra fonte, e não oferece API de composição de cabeçalho/rodapé. Se o seu PDF já os contiver, a biblioteca pode imprimi-lo:
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;
class Program
{
static void Main()
{
// Headers/footers must already be baked into the PDF.
var pdfPrint = new PdfPrint("license-owner", "license-key");
pdfPrint.Print("report.pdf");
Console.WriteLine("PDF with pre-existing headers/footers printed");
}
}
// NuGet: Install-Package PdfPrintingNet
using PdfPrintingNet;
using System;
class Program
{
static void Main()
{
// Headers/footers must already be baked into the PDF.
var pdfPrint = new PdfPrint("license-owner", "license-key");
pdfPrint.Print("report.pdf");
Console.WriteLine("PDF with pre-existing headers/footers printed");
}
}
Imports PdfPrintingNet
Imports System
Module Program
Sub Main()
' Headers/footers must already be baked into the PDF.
Dim pdfPrint As New PdfPrint("license-owner", "license-key")
pdfPrint.Print("report.pdf")
Console.WriteLine("PDF with pre-existing headers/footers printed")
End Sub
End Module
Após (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
HtmlFragment = "<div style='text-align:center'>Company Report</div>"
};
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
{
HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
};
string html = "<html><body><h1>Document Content</h1></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("report.pdf");
Console.WriteLine("PDF with headers/footers created");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
HtmlFragment = "<div style='text-align:center'>Company Report</div>"
};
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
{
HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
};
string html = "<html><body><h1>Document Content</h1></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("report.pdf");
Console.WriteLine("PDF with headers/footers created");
}
}
Imports IronPdf
Imports IronPdf.Rendering
Imports System
Module Program
Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {
.HtmlFragment = "<div style='text-align:center'>Company Report</div>"
}
renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter() With {
.HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages}</div>"
}
Dim html As String = "<html><body><h1>Document Content</h1></body></html>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("report.pdf")
Console.WriteLine("PDF with headers/footers created")
End Sub
End Module
IronPDF usa objetos HtmlHeaderFooter com uma propriedade HtmlFragment que aceita HTML completo, permitindo estilização rica com CSS. Marcadores como {page} e {total-pages} são substituídos em tempo de renderização.
Notas críticas sobre migração
Espaços Reservados de Cabeçalho/Rodapé São um Recurso Exclusivo do IronPDF
PDFPrinting.NET não possui API de autoria de cabeçalho ou rodapé, de modo que não há sintaxe de espaço reservado para migrar.IronPDF suporta marcadores {page} e {total-pages} dentro de HtmlHeaderFooter.HtmlFragment:
//IronPDF placeholders
"Page {page} of {total-pages}"
//IronPDF placeholders
"Page {page} of {total-pages}"
Padrão de Carregar e Imprimir
PDFPrinting.NET passa caminhos de arquivo diretamente para Print();IronPDF carrega o documento primeiro:
// PDFPrinting.NET: Direct path to Print()
pdfPrint.Print("document.pdf");
// IronPDF: Load first, then operate
var pdf = PdfDocument.FromFile("document.pdf");
pdf.Print();
// PDFPrinting.NET: Direct path to Print()
pdfPrint.Print("document.pdf");
// IronPDF: Load first, then operate
var pdf = PdfDocument.FromFile("document.pdf");
pdf.Print();
' PDFPrinting.NET: Direct path to Print()
pdfPrint.Print("document.pdf")
' IronPDF: Load first, then operate
Dim pdf = PdfDocument.FromFile("document.pdf")
pdf.Print()
Migração de configurações de impressão
PDFPrinting.NET usa propriedades em PdfPrint; O IronPDF utiliza um objeto de configurações:
// PDFPrinting.NET: Properties on PdfPrint
pdfPrint.Copies = 2;
pdfPrint.Duplex = true;
// IronPDF: Settings object
var settings = new PrintSettings
{
NumberOfCopies = 2,
DuplexMode = System.Drawing.Printing.Duplex.Vertical
};
pdf.Print(settings);
// PDFPrinting.NET: Properties on PdfPrint
pdfPrint.Copies = 2;
pdfPrint.Duplex = true;
// IronPDF: Settings object
var settings = new PrintSettings
{
NumberOfCopies = 2,
DuplexMode = System.Drawing.Printing.Duplex.Vertical
};
pdf.Print(settings);
' PDFPrinting.NET: Properties on PdfPrint
pdfPrint.Copies = 2
pdfPrint.Duplex = True
' IronPDF: Settings object
Dim settings As New PrintSettings With {
.NumberOfCopies = 2,
.DuplexMode = System.Drawing.Printing.Duplex.Vertical
}
pdf.Print(settings)
Novas funcionalidades após a migração
Após migrar para o IronPDF, você obtém recursos que o PDFPrinting .NET não pode fornecer:
Fusão de PDFs
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
merged.SaveAs("merged.pdf")
Marcas d'água
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>")
Proteção por senha
pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SecuritySettings.UserPassword = "userpassword"
pdf.SecuritySettings.OwnerPassword = "ownerpassword"
Extração de texto
string text = pdf.ExtractAllText();
string text = pdf.ExtractAllText();
Dim text As String = pdf.ExtractAllText()
Fluxo de trabalho Gerar e Imprimir
Com o IronPDF, você pode gerar PDFs e imprimi-los em um único fluxo de trabalho:
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Invoice</h1>");
pdf.Print("Invoice Printer");
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Invoice</h1>");
pdf.Print("Invoice Printer");
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Invoice</h1>")
pdf.Print("Invoice Printer")
Impressão multiplataforma
O PDFPrinting .NET é exclusivo para Windows. O IronPDF funciona em várias plataformas:
Windows
pdf.Print("HP LaserJet");
pdf.Print("HP LaserJet");
pdf.Print("HP LaserJet")
Linux
// Requires CUPS (Common Unix Printing System)
// Install: apt-get install cups
pdf.Print("HP_LaserJet"); // CUPS uses underscores instead of spaces
// Requires CUPS (Common Unix Printing System)
// Install: apt-get install cups
pdf.Print("HP_LaserJet"); // CUPS uses underscores instead of spaces
macOS
pdf.Print("HP LaserJet");
pdf.Print("HP LaserJet");
pdf.Print("HP LaserJet")
Resumo da comparação de recursos
| Recurso | PDFPrinting.NET | IronPDF |
|---|---|---|
| Impressão silenciosa | ✓ | ✓ |
| Configurações de impressão | ✓ | ✓ |
| HTML para PDF | ✗ | ✓ |
| URL para PDF | ✗ | ✓ |
| Cabeçalhos/Rodapés | Básico | HTML completo |
| Mesclar PDFs | ✗ | ✓ |
| Dividir PDFs | ✗ | ✓ |
| Marcas d'água | ✗ | ✓ |
| Extração de texto | ✗ | ✓ |
| Proteção por senha | ✗ | ✓ |
| Multiplataforma | ✗ | ✓ |
Lista de verificação para migração
Pré-migração
- Inventariar todo o uso de PDFPrinting .NET no código-fonte.
- Documente todos os nomes de impressoras atualmente em uso.
- Anote todas as configurações de impressão.
- Identificar se é necessário suporte multiplataforma
- Planeje o armazenamento da chave de licença do IronPDF(variáveis de ambiente recomendadas)
- Teste primeiro com a licença de avaliação do IronPDF
Alterações no pacote
- Remova o pacote NuGet
PdfPrintingNet - Instale o pacote NuGet
IronPdf:dotnet add package IronPdf
Alterações no código
- Atualize as importações de namespace (
PdfPrintingNet/ legadoTerminalWorks.PDFPrinting→IronPdf) - Converta chamadas
pdfPrint.Print(caminho)para o padrãoPdfDocument.FromFile(path).Print() - Mova propriedades por impressão (
Copies,Duplex,Collate,PrinterName) para um objetoPrintSettings - Adote novas capacidades: use
ChromePdfRenderer.RenderHtmlAsPdf/RenderUrlAsPdfpara entradas HTML e URL (não existia equivalente no PDFPrinting.NET) - Configure cabeçalhos/rodapés via
RenderingOptions.HtmlHeadereHtmlFooter(nova capacidade) - Defina
IronPdf.License.LicenseKeyna inicialização do aplicativo
Pós-migração
- Teste de impressão em todas as plataformas de destino
- Verificar a renderização do cabeçalho/rodapé
- Considere adicionar a geração de PDFs para documentos dinâmicos.
- Adicionar novas funcionalidades (fusão, marcas d'água, segurança) conforme necessário.

