Como migrar do Scryber.Core para o IronPDF em C#
Migrar do Scryber.Core para o IronPDF move seu fluxo de trabalho de geração de PDFs de um motor de layout customizado XHTML+CSS para um renderizador baseado em Cromo com suporte completo para CSS3 e JavaScript. Este guia fornece um caminho de migração passo a passo que cobre considerações de licenciamento LGPL v3, modelo de template estrito XHTML do Scryber e as diferenças de renderização entre os dois motores.
Por que migrar do Scryber.Core para o IronPDF?
Entendendo o Scryber.Core
Scryber.Core (mantido por Richard Hewitson, versão atual 9.3.1) é uma biblioteca de código aberto que analisa templates XHTML+CSS com seu próprio motor de layout — não um navegador. Ele suporta estilização CSS, ligação de dados no estilo Handlebars {{ }} via doc.Params, e SVG, tornando-o atraente para desenvolvedores que desejam PDFs orientados por HTML sem dependência de navegador.
Embora o Scryber.Core seja uma opção viável para geração de PDF baseada em template HTML, várias restrições fazem com que equipes migrem.
Principais razões para migrar
- Preocupações com a Licença LGPL v3: Obrigações de divulgação de código fonte se aplicam se você modificar o próprio Scryber; ligação estática em aplicativos de código fechado é permitida, mas os termos ainda restringem como você distribui modificações.
- Entrada XHTML-estrita: Os templates devem ser XML válido — a maioria do HTML do mundo real precisa de limpeza antes de o Scryber analisar.
- Renderizador Não-navegador: Um motor de layout XHTML/CSS customizado — CSS moderno (Grid,Flexboxcompleto, consultas de contêineres) e qualquerJavaScriptnão são executados.
- Comunidade Menor: Menos exemplos trabalhados do que as bibliotecas convencionais.
- Sem Execução de JavaScript: Apenas renderização estática — gráficos, SPAs e widgets dinâmicos devem ser pré-renderizados.
- Sem URL-nativo para PDF: Você deve buscar o HTML sozinho (por exemplo, com
HttpClient) e alimentá-lo. - Suporte da Comunidade: As opções de suporte comercial são limitadas.
Comparação entre Scryber.Core e IronPDF
| Aspecto | Scryber.Core | IronPDF |
|---|---|---|
| Licença | LGPL v3 | Comercial |
| Motor de renderização | Motor de layout customizado XHTML/CSS | Cromo |
| Suporte a CSS | Subconjunto (sem Grid,Flexboxparcial) | CSS3 completo |
| JavaScript | Não executado | Completo (Chromium V8) |
| Encadernação de modelo | Handebars no estilo {{ }} + <template> |
Padrão (Razor, RazorLight, etc.) |
| Rigor de Entrada | Requer XHTML bem formado | Aceita HTML do mundo real |
| Suporte assíncrono | PDFAsync auxiliar MVC; sync core |
API totalmente assíncrona |
| Documentação | Site de docs + amostras | Extenso |
| Apoio comunitário | Menor | Maior |
| Suporte comercial | Suporte pela comunidade | Suporte comercial disponível |
O IronPDF oferece suporte comercial, documentação e uma base de usuários maior em comparação ao Scryber.Core. A biblioteca é licenciada para uso comercial sem obrigações LGPL.
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 Scryber.Core
dotnet remove package Scryber.Core
# Install IronPDF
dotnet add package IronPdf
# Remove Scryber.Core
dotnet remove package Scryber.Core
# Install IronPDF
dotnet add package IronPdf
Configuração de licença
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Referência completa da API
Alterações de namespace
// Before: Scryber.Core
using Scryber.Components; // Document, Page, etc.
using Scryber.Drawing; // Units, colours
using Scryber.PDF; // RenderOptions / OutputCompressionType
using Scryber.Styles; // Style elements (older XML template usage)
// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
// Before: Scryber.Core
using Scryber.Components; // Document, Page, etc.
using Scryber.Drawing; // Units, colours
using Scryber.PDF; // RenderOptions / OutputCompressionType
using Scryber.Styles; // Style elements (older XML template usage)
// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
Imports Scryber.Components ' Document, Page, etc.
Imports Scryber.Drawing ' Units, colours
Imports Scryber.PDF ' RenderOptions / OutputCompressionType
Imports Scryber.Styles ' Style elements (older XML template usage)
' After: IronPDF
Imports IronPdf
Imports IronPdf.Rendering
Mapeamentos da API principal
| Scryber.Core | IronPDF |
|---|---|
Document.ParseDocument(reader, "", ParseSourceType.DynamicContent) |
renderer.RenderHtmlAsPdf(html) |
Document.ParseDocument(path) |
renderer.RenderHtmlFileAsPdf(path) |
doc.SaveAsPDF(path) |
pdf.SaveAs(path) |
doc.SaveAsPDF(stream) |
pdf.BinaryData (byte[]) |
doc.Info.Title |
pdf.MetaData.Title |
doc.Info.Author |
pdf.MetaData.Author |
@page CSS em template |
renderer.RenderingOptions.PaperSize / margens |
doc.RenderOptions |
renderer.RenderingOptions |
Handlebars {{value}} + doc.Params |
Razor / interpolação de string |
Exemplos de migração de código
Exemplo 1: Conversão básica de HTML para PDF
Antes (Scryber.Core):
// NuGet: Install-Package Scryber.Core
using Scryber.Components;
using System.IO;
class Program
{
static void Main()
{
// Scryber requires well-formed XHTML wrapped in an html root with the xhtml namespace
string html = @"<html xmlns='http://www.w3.org/1999/xhtml'>
<body><h1>Hello World</h1><p>This is a PDF document.</p></body>
</html>";
using (var reader = new StringReader(html))
using (var doc = Document.ParseDocument(reader, string.Empty, ParseSourceType.DynamicContent))
using (var stream = new FileStream("output.pdf", FileMode.Create))
{
doc.SaveAsPDF(stream);
}
}
}
// NuGet: Install-Package Scryber.Core
using Scryber.Components;
using System.IO;
class Program
{
static void Main()
{
// Scryber requires well-formed XHTML wrapped in an html root with the xhtml namespace
string html = @"<html xmlns='http://www.w3.org/1999/xhtml'>
<body><h1>Hello World</h1><p>This is a PDF document.</p></body>
</html>";
using (var reader = new StringReader(html))
using (var doc = Document.ParseDocument(reader, string.Empty, ParseSourceType.DynamicContent))
using (var stream = new FileStream("output.pdf", FileMode.Create))
{
doc.SaveAsPDF(stream);
}
}
}
Imports Scryber.Components
Imports System.IO
Class Program
Shared Sub Main()
' Scryber requires well-formed XHTML wrapped in an html root with the xhtml namespace
Dim html As String = "<html xmlns='http://www.w3.org/1999/xhtml'>" &
"<body><h1>Hello World</h1><p>This is a PDF document.</p></body>" &
"</html>"
Using reader As New StringReader(html),
doc As Document = Document.ParseDocument(reader, String.Empty, ParseSourceType.DynamicContent),
stream As New FileStream("output.pdf", FileMode.Create)
doc.SaveAsPDF(stream)
End Using
End Sub
End Class
Após (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
string html = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
string html = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer = New ChromePdfRenderer()
Dim html As String = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
End Sub
End Class
Scryber.Core envolve a string XHTML em um StringReader, entrega-a ao Document.ParseDocument com ParseSourceType.DynamicContent, e grava o PDF em um FileStream via SaveAsPDF. A declaração do namespace XHTML é necessária — o Scryber rejeitará o HTML que não for XML bem formado.
IronPDF usa uma instância ChromePdfRenderer com RenderHtmlAsPdf() para renderizar HTML diretamente, e salva com SaveAs(). HTML5 do mundo real é aceito como está. Veja a documentação de HTML para PDF para mais exemplos.
Exemplo 2: Conversão de URL para PDF
Antes (Scryber.Core):
// NuGet: Install-Package Scryber.Core
// Scryber has no native URL-to-PDF method — fetch the HTML yourself, then parse.
using Scryber.Components;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
string html = await client.GetStringAsync("https://www.example.com");
// Most live HTML is not valid XHTML; expect to clean it
// (e.g., HtmlAgilityPack) before Scryber will parse it.
using (var reader = new StringReader(html))
using (var doc = Document.ParseDocument(reader, string.Empty, ParseSourceType.DynamicContent))
using (var stream = new FileStream("webpage.pdf", FileMode.Create))
{
doc.SaveAsPDF(stream);
}
}
}
// NuGet: Install-Package Scryber.Core
// Scryber has no native URL-to-PDF method — fetch the HTML yourself, then parse.
using Scryber.Components;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
string html = await client.GetStringAsync("https://www.example.com");
// Most live HTML is not valid XHTML; expect to clean it
// (e.g., HtmlAgilityPack) before Scryber will parse it.
using (var reader = new StringReader(html))
using (var doc = Document.ParseDocument(reader, string.Empty, ParseSourceType.DynamicContent))
using (var stream = new FileStream("webpage.pdf", FileMode.Create))
{
doc.SaveAsPDF(stream);
}
}
}
Imports Scryber.Components
Imports System.IO
Imports System.Net.Http
Imports System.Threading.Tasks
Module Program
Async Function Main() As Task
Using client As New HttpClient()
Dim html As String = Await client.GetStringAsync("https://www.example.com")
' Most live HTML is not valid XHTML; expect to clean it
' (e.g., HtmlAgilityPack) before Scryber will parse it.
Using reader As New StringReader(html)
Using doc As Document = Document.ParseDocument(reader, String.Empty, ParseSourceType.DynamicContent)
Using stream As New FileStream("webpage.pdf", FileMode.Create)
doc.SaveAsPDF(stream)
End Using
End Using
End Using
End Using
End Function
End Module
Após (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
pdf.SaveAs("webpage.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
pdf.SaveAs("webpage.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderUrlAsPdf("https://www.example.com")
pdf.SaveAs("webpage.pdf")
End Sub
End Class
Scryber.Core não tem ponto de entrada nativo de URL-para-PDF. Você busca o HTML sozinho com HttpClient.GetStringAsync() e alimenta em Document.ParseDocument(). Porque o Scryber exige XHTML bem formado, a maioria das páginas ao vivo precisará de limpeza (por exemplo, via HtmlAgilityPack) antes que sejam analisadas.JavaScriptnão é executado, então qualquer conteúdo renderizado dinamicamente estará ausente.
O RenderUrlAsPdf() do IronPDF lida com fetch, execução deJavaScripte renderização de CSS em uma única chamada via seu mecanismo do Chromium. Saiba mais em nossos tutoriais.
Exemplo 3: Configurações de página personalizadas e margens
Antes (Scryber.Core):
// NuGet: Install-Package Scryber.Core
// Page size and margins are normally declared in the XHTML/CSS template;
// the runtime RenderOptions object exposes output-side settings such as compression.
using Scryber.Components;
using Scryber.PDF;
using System.IO;
class Program
{
static void Main()
{
// Page size and margins go in CSS @page; this is the Scryber idiom.
string html = @"<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<style>
@page { size: A4 portrait; margin: 40pt; }
</style>
</head>
<body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body>
</html>";
using (var reader = new StringReader(html))
using (var doc = Document.ParseDocument(reader, string.Empty, ParseSourceType.DynamicContent))
using (var stream = new FileStream("custom.pdf", FileMode.Create))
{
// Output-side options (compression / conformance) are on RenderOptions.
doc.RenderOptions.Compression = OutputCompressionType.FlateDecode;
doc.SaveAsPDF(stream);
}
}
}
// NuGet: Install-Package Scryber.Core
// Page size and margins are normally declared in the XHTML/CSS template;
// the runtime RenderOptions object exposes output-side settings such as compression.
using Scryber.Components;
using Scryber.PDF;
using System.IO;
class Program
{
static void Main()
{
// Page size and margins go in CSS @page; this is the Scryber idiom.
string html = @"<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<style>
@page { size: A4 portrait; margin: 40pt; }
</style>
</head>
<body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body>
</html>";
using (var reader = new StringReader(html))
using (var doc = Document.ParseDocument(reader, string.Empty, ParseSourceType.DynamicContent))
using (var stream = new FileStream("custom.pdf", FileMode.Create))
{
// Output-side options (compression / conformance) are on RenderOptions.
doc.RenderOptions.Compression = OutputCompressionType.FlateDecode;
doc.SaveAsPDF(stream);
}
}
}
Imports Scryber.Components
Imports Scryber.PDF
Imports System.IO
Module Program
Sub Main()
' Page size and margins go in CSS @page; this is the Scryber idiom.
Dim html As String = "<html xmlns='http://www.w3.org/1999/xhtml'>" &
"<head>" &
"<style>" &
"@page { size: A4 portrait; margin: 40pt; }" &
"</style>" &
"</head>" &
"<body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body>" &
"</html>"
Using reader As New StringReader(html),
doc As Document = Document.ParseDocument(reader, String.Empty, ParseSourceType.DynamicContent),
stream As New FileStream("custom.pdf", FileMode.Create)
' Output-side options (compression / conformance) are on RenderOptions.
doc.RenderOptions.Compression = OutputCompressionType.FlateDecode
doc.SaveAsPDF(stream)
End Using
End Sub
End Module
Após (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.MarginTop = 40;
renderer.RenderingOptions.MarginBottom = 40;
string html = "<html><body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("custom.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.MarginTop = 40;
renderer.RenderingOptions.MarginBottom = 40;
string html = "<html><body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body></html>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("custom.pdf");
}
}
Imports IronPdf
Imports IronPdf.Rendering
Class Program
Shared Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
renderer.RenderingOptions.MarginTop = 40
renderer.RenderingOptions.MarginBottom = 40
Dim html As String = "<html><body><h1>Custom PDF</h1><p>With custom margins and settings.</p></body></html>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("custom.pdf")
End Sub
End Class
No Scryber.Core, o tamanho da página e as margens são declarados no template via CSS @page, enquanto doc.RenderOptions expõe configurações do lado da saída, como compressão (OutputCompressionType.FlateDecode).
IronPDF move a geometria da página para RenderingOptions no renderizador: PaperSize (configurado para PdfPaperSize.A4), MarginTop, e MarginBottom em milímetros. A geometria da página vive na superfície da API em vez de dentro do template.
Padrões de Migração de Modelos
Migrando Ligação Scryber para Templates Padrão
Scryber.Core usa XHTML com vinculações no estilo Handlebars {{ }} (resolvidas via doc.Params) e uma construção <template data-bind='...'> para seções repetidas. Para migrar, reexprima isso em templates padrão .NET:
Ligação Scryber (XHTML + Handlebars):
<p>{{model.Name}}</p>
<p>Total: {{model.Total}}</p>
<template data-bind='{{model.Items}}'>
<p>{{.Name}}: {{.Price}}</p>
</template>
<p>{{model.Name}}</p>
<p>Total: {{model.Total}}</p>
<template data-bind='{{model.Items}}'>
<p>{{.Name}}: {{.Price}}</p>
</template>
IronPDF com interpolação de strings em C#:
var items = model.Items.Select(i => $"<li>{i.Name}: {i.Price:C}</li>");
var html = $@"
<p>{model.Name}</p>
<p>Total: {model.Total:C}</p>
<ul>
{string.Join("", items)}
</ul>";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
var items = model.Items.Select(i => $"<li>{i.Name}: {i.Price:C}</li>");
var html = $@"
<p>{model.Name}</p>
<p>Total: {model.Total:C}</p>
<ul>
{string.Join("", items)}
</ul>";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
Dim items = model.Items.Select(Function(i) $"<li>{i.Name}: {i.Price:C}</li>")
Dim html = $"
<p>{model.Name}</p>
<p>Total: {model.Total:C}</p>
<ul>
{String.Join("", items)}
</ul>"
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(html)
Porque o IronPDF aceita HTML puro, você pode usar qualquer mecanismo de template .NET — Razor, RazorLight, Handlebars.Net — em vez das construções {{ }} + <template> do Scryber.
Migração de cabeçalhos e rodapés
Scryber.Core (XHTML + caixas de margem @page):
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<style>
@page {
@top-center { content: 'Company Report'; }
@bottom-center { content: 'Page ' counter(page) ' of ' counter(pages); }
}
</style>
</head>
<body>
<h1>Content Here</h1>
</body>
</html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<style>
@page {
@top-center { content: 'Company Report'; }
@bottom-center { content: 'Page ' counter(page) ' of ' counter(pages); }
}
</style>
</head>
<body>
<h1>Content Here</h1>
</body>
</html>
IronPDF (cabeçalhos/rodapés HTML):
using IronPdf;
var renderer = new ChromePdfRenderer();
// HTML header with full CSS support
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter
{
HtmlFragment = @"
<div style='width: 100%; text-align: center; font-size: 12pt; border-bottom: 1px solid #ccc;'>
Company Report
</div>",
MaxHeight = 30
};
// HTML footer with page numbers
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
HtmlFragment = @"
<div style='width: 100%; text-align: center; font-size: 10pt;'>
Page {page} of {total-pages}
</div>",
MaxHeight = 25
};
var pdf = renderer.RenderHtmlAsPdf("<h1>Content Here</h1>");
pdf.SaveAs("report.pdf");
using IronPdf;
var renderer = new ChromePdfRenderer();
// HTML header with full CSS support
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter
{
HtmlFragment = @"
<div style='width: 100%; text-align: center; font-size: 12pt; border-bottom: 1px solid #ccc;'>
Company Report
</div>",
MaxHeight = 30
};
// HTML footer with page numbers
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
HtmlFragment = @"
<div style='width: 100%; text-align: center; font-size: 10pt;'>
Page {page} of {total-pages}
</div>",
MaxHeight = 25
};
var pdf = renderer.RenderHtmlAsPdf("<h1>Content Here</h1>");
pdf.SaveAs("report.pdf");
Imports IronPdf
Dim renderer As New ChromePdfRenderer()
' HTML header with full CSS support
renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter With {
.HtmlFragment = "
<div style='width: 100%; text-align: center; font-size: 12pt; border-bottom: 1px solid #ccc;'>
Company Report
</div>",
.MaxHeight = 30
}
' HTML footer with page numbers
renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter With {
.HtmlFragment = "
<div style='width: 100%; text-align: center; font-size: 10pt;'>
Page {page} of {total-pages}
</div>",
.MaxHeight = 25
}
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Content Here</h1>")
pdf.SaveAs("report.pdf")
Scryber.Core define cabeçalhos e rodapés via caixas de margem @page no CSS, usando counter(page) e counter(pages) para números de página.IronPDF usa HtmlHeaderFooter com HTML/CSS completo para cabeçalhos e rodapés e os espaços reservados {page} e {total-pages}.
Novas funcionalidades após a migração
Após migrar para o IronPDF, você obtém recursos que o Scryber.Core não pode fornecer:
Fusão de PDFs
var pdf1 = PdfDocument.FromFile("chapter1.pdf");
var pdf2 = PdfDocument.FromFile("chapter2.pdf");
var pdf3 = PdfDocument.FromFile("chapter3.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2, pdf3);
merged.SaveAs("complete_book.pdf");
var pdf1 = PdfDocument.FromFile("chapter1.pdf");
var pdf2 = PdfDocument.FromFile("chapter2.pdf");
var pdf3 = PdfDocument.FromFile("chapter3.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2, pdf3);
merged.SaveAs("complete_book.pdf");
Dim pdf1 = PdfDocument.FromFile("chapter1.pdf")
Dim pdf2 = PdfDocument.FromFile("chapter2.pdf")
Dim pdf3 = PdfDocument.FromFile("chapter3.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2, pdf3)
merged.SaveAs("complete_book.pdf")
Segurança e metadados
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Confidential</h1>");
// Metadata
pdf.MetaData.Title = "My Document";
pdf.MetaData.Author = "John Doe";
pdf.MetaData.Subject = "Annual Report";
pdf.MetaData.Keywords = "report, annual, confidential";
// Security
pdf.SecuritySettings.OwnerPassword = "owner123";
pdf.SecuritySettings.UserPassword = "user456";
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
pdf.SaveAs("protected.pdf");
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Confidential</h1>");
// Metadata
pdf.MetaData.Title = "My Document";
pdf.MetaData.Author = "John Doe";
pdf.MetaData.Subject = "Annual Report";
pdf.MetaData.Keywords = "report, annual, confidential";
// Security
pdf.SecuritySettings.OwnerPassword = "owner123";
pdf.SecuritySettings.UserPassword = "user456";
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
pdf.SaveAs("protected.pdf");
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Confidential</h1>")
' Metadata
pdf.MetaData.Title = "My Document"
pdf.MetaData.Author = "John Doe"
pdf.MetaData.Subject = "Annual Report"
pdf.MetaData.Keywords = "report, annual, confidential"
' Security
pdf.SecuritySettings.OwnerPassword = "owner123"
pdf.SecuritySettings.UserPassword = "user456"
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights
pdf.SaveAs("protected.pdf")
Resumo da comparação de recursos
| Recurso | Scryber.Core | IronPDF |
|---|---|---|
| HTML para PDF | XHTML+CSS via motor de layout customizado | Cromo completo |
| URL para PDF | Somente busca manual | Nativo RenderUrlAsPdf |
| Grade CSS | Não suportado | Suporte total |
| Flexbox | Parcial | Suporte total |
| JavaScript | Não executado | Completo (V8) |
| Vinculação de dados | {{ }} Handlebars + doc.Params |
Razor / RazorLight / interpolation |
| Cabeçalhos/Rodapés | @page caixas de margem / seções de template |
HtmlHeaderFooter com {page} {total-pages} |
| Mesclar PDFs | Não suportado | Embutido PdfDocument.Merge |
| Dividir PDFs | Não suportado | Sim |
| Marcas d'água | Via HTML sobreposto no template | Nativo ApplyStamp / ApplyWatermark |
| Assinaturas digitais | Não suportado | Sim |
| PDF/A | Não suportado | Sim (PDF/A-1b, PDF/A-3) |
| Proteção por senha | Não suportado | Completo (usuário/proprietário + permissões) |
| Suporte assíncrono | PDFAsync auxiliar MVC; sync core |
Superfície totalmente assíncrona |
| Multiplataforma | Sim (.NET Std 2.0/2.1, .NET 8/9/10) | Sim |
Lista de verificação para migração
Pré-migração
- Auditar todos os templates Scryber para padrões XHTML/ligação
- Padrões de ligação de dados de documento usados (
{{model.Property}}) - Identificar estilos personalizados que precisam de conversão para CSS.
- Obtenha a chave de licença do IronPDF em IronPDF
Atualizações de código
- Remover pacote NuGet
Scryber.Core - Instalar pacote NuGet
IronPdf - Atualizar importações de namespace (
using Scryber.Components;/Scryber.Drawing;/Scryber.PDF;→using IronPdf;) - Substituir
Document.ParseDocument(reader, "", ParseSourceType.DynamicContent)porrenderer.RenderHtmlAsPdf(html) - Substituir
doc.SaveAsPDF(stream)porpdf.SaveAs(path)oupdf.BinaryData - Converter templates XHTML para HTML5 simples (sem requisito de namespace)
- Substituir vinculação Handlebars
{{ }}por modelagem padrão (Razor / interpolação de string) - Mover CSS
@pagepararenderer.RenderingOptions(Tamanho do Papel, Margem Superior, etc.) - Converter cabeçalhos/rodapés de caixas de margem
@pageparaHtmlHeaderFootercom os espaços reservados{page}e{total-pages} - Adicionar inicialização de licença na inicialização do aplicativo
Testando
- Testar todos os modelos de documento
- Verificar se os estilos correspondem (aproveitar ao máximo o suporte a CSS)
- Testar a vinculação de dados com novos modelos
- Verificar quebras de página
- Testar cabeçalhos/rodapés com marcadores de posição para números de página
- Comparação de desempenho

