Cómo firmar archivos PDF en C# usando IronPDF
Migrar de Nutrient (anteriormente PSPDFKit) a IronPDF simplifica su flujo de trabajo en PDF con .NET al cambiar de un conjunto de herramientas amplio de imágenes y PDF a una biblioteca enfocada en PDF. La oferta del lado del servidor de Nutrient for .NET es GdPicture.NET, el conjunto de herramientas adquirido de ORPALIS y reposicionado como el 'Nutrient .NET SDK', que se envía como el paquete NuGet GdPicture bajo el espacio de nombres GdPicture14. Esta guía repasa un camino de migración paso a paso que intercambia el conjunto de herramientas procedural y de múltiples propósitos por una biblioteca solo de PDF con un área de superficie más pequeña.
Por qué migrar de Nutrient a IronPDF
El problema de la superficie del conjunto de herramientas
Nutrient (anteriormente PSPDFKit, renombrado el 23-10-2024) vende una familia de múltiples productos: Document Engine (microservicio Docker), SDK web, SDKs móviles y un SDK de .NET del lado del servidor que es GdPicture internamente. Para los equipos que necesitan operaciones PDF simples sin el resto del conjunto de herramientas, la superficie se manifiesta de algunas maneras concretas:
-
Alcance del conjunto de herramientas amplio: El SDK de .NET cubre PDF, OCR, códigos de barras, escaneo TWAIN, procesamiento de imágenes y conversión a más de 100 formatos de archivo. Útil si necesitas esa amplitud, más área de superficie de la que un proyecto solo de PDF necesita si no.
-
Precios guiados por ventas: La página
nutrient.io/sdk/pricinglleva a un formulario de contacto en lugar de publicar tarifas por desarrollador, lo que hace más difícil la comparación de costos lado a lado para equipos pequeños. -
Rotación de marca y paquete: PSPDFKit → Nutrient (23-10-2024), además de la adquisición de GdPicture, significa tres nombres para rastrear en códigos más antiguos. El SDK de .NET todavía se envía como el paquete NuGet
GdPicture, espacio de nombresGdPicture14, con nombres de clases comoGdPicturePDFyGdPictureDocumentConverterque no coinciden con las marcas 'Nutrient' o 'PSPDFKit'. -
Dependencia de navegador externo para HTML-a-PDF: El renderizador HTML del SDK de .NET depende de un Chrome o Edge instalado en el sistema (o una ruta portable que configuras a través de
SetWebBrowserPath).IronPDF envía su propio Chromium integrado. - API de PDF procedural: Las marcas de agua componen
SetFillAlpha,DrawTextBox, y marcadores de capa OCG; los encabezados y pies de página se dibujan por página en un bucle. Componer operaciones PDF comunes a partir de primitivas significa más código por tarea.
Comparación del Nutrient .NET SDK vs IronPDF
| Aspecto | Nutrient .NET SDK (GdPicture) | IronPDF |
|---|---|---|
| Alcance | PDF + OCR + código de barras + escaneo + imágenes | Biblioteca PDF |
| Precios | Guiados por ventas (contactar para cotización) | Transparente, publicado |
| Paquete NuGet | GdPicture |
IronPdf |
| Espacio de nombres raíz | GdPicture14 |
IronPdf |
| Estilo de API | Principalmente sincrónico, llamadas de dibujo procedurales | Sincrónico con opción asincrónica, fluido |
| Renderizado HTML | Requiere Chrome / Edge del sistema | Chromium integrado |
| Indexación de página | Con base en 1 | Con base en 0 |
| Usuarios objetivo | Equipos que necesitan imágenes + escaneo + PDF en un solo conjunto de herramientas | Equipos que solo necesitan PDF |
Para equipos en .NET moderno que solo necesitan PDF,IronPDF proporciona una base más pequeña enfocada en PDF que se integra limpiamente sin las capas adicionales de imágenes / escaneo / OCR.
Antes de comenzar
Requisitos previos
- .NET Environment: .NET Framework 4.6.2+ or .NET Core 3.1+ / .NET 5/6/7/8/9+
- Acceso a NuGet: Capacidad para instalar paquetes NuGet
- Licencia de IronPDF: Obtén tu clave de licencia de ironpdf.com
Cambios en el paquete NuGet
# Remove theNutrient .NET SDK (GdPicture)and any legacy PSPDFKit-branded packages
dotnet remove package GdPicture
dotnet remove package GdPicture.WPF
dotnet remove package GdPicture.WinForms
dotnet remove package PSPDFKit.NET
# Install IronPDF
dotnet add package IronPdf
# Remove theNutrient .NET SDK (GdPicture)and any legacy PSPDFKit-branded packages
dotnet remove package GdPicture
dotnet remove package GdPicture.WPF
dotnet remove package GdPicture.WinForms
dotnet remove package PSPDFKit.NET
# Install IronPDF
dotnet add package IronPdf
El actual SDK de Nutrient .NET se envía bajo el ID de NuGet GdPicture (último 14.x, propietario ORPALIS, una filial de Nutrient). El antiguo paquete con la marca PSPDFKit PSPDFKit.NET está descontinuado; elimínelo si está presente.
Configuración de la licencia
// 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 el uso del Nutrient .NET SDK
# Find GdPicture / Nutrient / PSPDFKit usage
grep -rE "GdPicture14|GdPicturePDF|GdPictureDocumentConverter|PSPDFKit|Nutrient" --include="*.cs" .
# Find GdPicture / Nutrient / PSPDFKit usage
grep -rE "GdPicture14|GdPicturePDF|GdPictureDocumentConverter|PSPDFKit|Nutrient" --include="*.cs" .
Referencia completa de la API
Mapeos de inicialización
| Nutrient .NET SDK (GdPicture) | IronPDF |
|---|---|
new GdPicturePDF() |
new PdfDocument(...) / PdfDocument.FromFile(...) |
new GdPictureDocumentConverter() |
new ChromePdfRenderer() |
pdf.Dispose() (IDisposable) |
pdf.Dispose() (IDisposable) |
Mapeos de carga de documentos
| Nutrient .NET SDK (GdPicture) | IronPDF |
|---|---|
pdf.LoadFromFile(path) |
PdfDocument.FromFile(path) |
pdf.LoadFromStream(stream) |
PdfDocument.FromStream(stream) |
pdf.LoadFromByteArray(bytes) |
new PdfDocument(bytes) / PdfDocument.FromBinaryData(bytes) |
Mapeos de generación de PDF
| Nutrient .NET SDK (GdPicture) | IronPDF |
|---|---|
Cadena HTML: escribir a archivo temporal, luego converter.LoadFromFile(path, DocumentFormat.DocumentFormatHTML) + SaveAsPDF(out) |
renderer.RenderHtmlAsPdf(html) |
converter.LoadFromHttp(url) + SaveAsPDF(out) |
renderer.RenderUrlAsPdf(url) |
converter.LoadFromFile(htmlPath, DocumentFormat.DocumentFormatHTML) + SaveAsPDF(out) |
renderer.RenderHtmlFileAsPdf(path) |
Mapeos de operaciones de documentos
| Nutrient .NET SDK (GdPicture) | IronPDF |
|---|---|
converter.CombineToPDF(paths, out, PdfConformance.PDF) |
PdfDocument.Merge(pdfs) |
pdf.GetPageCount() |
pdf.PageCount |
pdf.SaveToFile(path) |
pdf.SaveAs(path) |
pdf.SaveToByteArray(out bytes) |
pdf.BinaryData |
Mapeos de marcas de agua
| Nutrient .NET SDK (GdPicture) | IronPDF |
|---|---|
pdf.SetFillAlpha(...) + pdf.DrawTextBox(...) por página |
pdf.ApplyWatermark(html, rotation, vAlign, hAlign) |
pdf.AddStandardFont(...) + llamadas de dibujo |
HTML/CSS en cadena de marca de agua |
SetFillAlpha(128) (escala de bytes 0–255) |
Marca de agua Opacity 0–100 (int) o CSS opacity |
pdf.SetTextSize(48) |
CSS font-size: 48px |
Ejemplos de migración de código
Ejemplo 1: Conversión de HTML a PDF
Before (Nutrient .NET SDK / GdPicture):
// NuGet: Install-Package GdPicture
using GdPicture14;
using System.IO;
class Program
{
static void Main()
{
var htmlContent = "<html><body><h1>Hello World</h1></body></html>";
// GdPicture's HTML loader is file-based, so stage the string to disk first.
File.WriteAllText("input.html", htmlContent);
using var converter = new GdPictureDocumentConverter();
converter.LoadFromFile("input.html", DocumentFormat.DocumentFormatHTML);
converter.SaveAsPDF("output.pdf");
}
}
// NuGet: Install-Package GdPicture
using GdPicture14;
using System.IO;
class Program
{
static void Main()
{
var htmlContent = "<html><body><h1>Hello World</h1></body></html>";
// GdPicture's HTML loader is file-based, so stage the string to disk first.
File.WriteAllText("input.html", htmlContent);
using var converter = new GdPictureDocumentConverter();
converter.LoadFromFile("input.html", DocumentFormat.DocumentFormatHTML);
converter.SaveAsPDF("output.pdf");
}
}
Imports GdPicture14
Imports System.IO
Class Program
Shared Sub Main()
Dim htmlContent As String = "<html><body><h1>Hello World</h1></body></html>"
' GdPicture's HTML loader is file-based, so stage the string to disk first.
File.WriteAllText("input.html", htmlContent)
Using converter As New GdPictureDocumentConverter()
converter.LoadFromFile("input.html", DocumentFormat.DocumentFormatHTML)
converter.SaveAsPDF("output.pdf")
End Using
End Sub
End Class
Después (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var htmlContent = "<html><body><h1>Hello World</h1></body></html>";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var htmlContent = "<html><body><h1>Hello World</h1></body></html>";
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
Dim htmlContent As String = "<html><body><h1>Hello World</h1></body></html>"
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
pdf.SaveAs("output.pdf")
End Sub
End Class
El enfoque de GdPicture requiere algunos pasos adicionales: el cargador de HTML se basa en archivos/URL, por lo que una cadena HTML en memoria debe prepararse en disco primero, luego se llama converter.LoadFromFile(...) con DocumentFormat.DocumentFormatHTML, seguido por SaveAsPDF. El renderizado HTML depende de un Chrome o Edge instalado en el sistema (o una ruta portable suministrada a través de SetWebBrowserPath).
IronPDF acepta la cadena HTML directamente. Crea un ChromePdfRenderer, llama RenderHtmlAsPdf(), y guarda con SaveAs(). Sin archivo temporal, sin dependencia de navegador host:IronPDFenvía su propio Chromium integrado. Consulta la documentación de HTML a PDF para opciones de renderizado adicionales.
Ejemplo 2: Combinación de múltiples PDFs
Before (Nutrient .NET SDK / GdPicture):
// NuGet: Install-Package GdPicture
using GdPicture14;
using System.Collections.Generic;
class Program
{
static void Main()
{
IEnumerable<string> sourceFiles = new List<string>
{
"document1.pdf",
"document2.pdf"
};
using var converter = new GdPictureDocumentConverter();
converter.CombineToPDF(sourceFiles, "merged.pdf", PdfConformance.PDF);
}
}
// NuGet: Install-Package GdPicture
using GdPicture14;
using System.Collections.Generic;
class Program
{
static void Main()
{
IEnumerable<string> sourceFiles = new List<string>
{
"document1.pdf",
"document2.pdf"
};
using var converter = new GdPictureDocumentConverter();
converter.CombineToPDF(sourceFiles, "merged.pdf", PdfConformance.PDF);
}
}
Imports GdPicture14
Imports System.Collections.Generic
Class Program
Shared Sub Main()
Dim sourceFiles As IEnumerable(Of String) = New List(Of String) From {
"document1.pdf",
"document2.pdf"
}
Using converter As New GdPictureDocumentConverter()
converter.CombineToPDF(sourceFiles, "merged.pdf", PdfConformance.PDF)
End Using
End Sub
End Class
Después (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
}
}
Imports IronPdf
Class Program
Shared Sub Main()
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
merged.SaveAs("merged.pdf")
End Sub
End Class
La fusión de GdPicture toma un IEnumerable<string> basado en ruta a través de converter.CombineToPDF, con un valor PdfConformance seleccionando el nivel de conformidad del output.
IronPDF trabaja a nivel de documento: carga cada PDF con PdfDocument.FromFile(), combina con el método estático PdfDocument.Merge(), y guarda. Los documentos pueden pasarse directamente o como un enumerable. Aprende más sobre fusión y división de PDFs.
Ejemplo 3: Agregar marcas de agua
Before (Nutrient .NET SDK / GdPicture):
// NuGet: Install-Package GdPicture
using GdPicture14;
class Program
{
static void Main()
{
using var pdf = new GdPicturePDF();
pdf.LoadFromFile("document.pdf");
pdf.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint);
var font = pdf.AddStandardFont(PdfStandardFont.PdfStandardFontHelveticaBold);
int pageCount = pdf.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
pdf.SelectPage(i);
pdf.SetFillAlpha(128); // ~50% (0..255)
pdf.SetTextSize(48);
pdf.SetOriginRotationInDegrees(45);
pdf.DrawTextBox(font, 100, 300, 500, 400, "CONFIDENTIAL",
PdfHorizontalAlignment.PdfHorizontalAlignmentCenter,
PdfVerticalAlignment.PdfVerticalAlignmentMiddle);
}
pdf.SaveToFile("watermarked.pdf");
}
}
// NuGet: Install-Package GdPicture
using GdPicture14;
class Program
{
static void Main()
{
using var pdf = new GdPicturePDF();
pdf.LoadFromFile("document.pdf");
pdf.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint);
var font = pdf.AddStandardFont(PdfStandardFont.PdfStandardFontHelveticaBold);
int pageCount = pdf.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
pdf.SelectPage(i);
pdf.SetFillAlpha(128); // ~50% (0..255)
pdf.SetTextSize(48);
pdf.SetOriginRotationInDegrees(45);
pdf.DrawTextBox(font, 100, 300, 500, 400, "CONFIDENTIAL",
PdfHorizontalAlignment.PdfHorizontalAlignmentCenter,
PdfVerticalAlignment.PdfVerticalAlignmentMiddle);
}
pdf.SaveToFile("watermarked.pdf");
}
}
Imports GdPicture14
Class Program
Shared Sub Main()
Using pdf As New GdPicturePDF()
pdf.LoadFromFile("document.pdf")
pdf.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint)
Dim font = pdf.AddStandardFont(PdfStandardFont.PdfStandardFontHelveticaBold)
Dim pageCount As Integer = pdf.GetPageCount()
For i As Integer = 1 To pageCount
pdf.SelectPage(i)
pdf.SetFillAlpha(128) ' ~50% (0..255)
pdf.SetTextSize(48)
pdf.SetOriginRotationInDegrees(45)
pdf.DrawTextBox(font, 100, 300, 500, 400, "CONFIDENTIAL", PdfHorizontalAlignment.PdfHorizontalAlignmentCenter, PdfVerticalAlignment.PdfVerticalAlignmentMiddle)
Next
pdf.SaveToFile("watermarked.pdf")
End Using
End Sub
End Class
Después (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
class Program
{
static void Main()
{
var pdf = PdfDocument.FromFile("document.pdf");
pdf.ApplyWatermark("<h1 style='color:gray;opacity:0.5;'>CONFIDENTIAL</h1>",
45,
VerticalAlignment.Middle,
HorizontalAlignment.Center);
pdf.SaveAs("watermarked.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
class Program
{
static void Main()
{
var pdf = PdfDocument.FromFile("document.pdf");
pdf.ApplyWatermark("<h1 style='color:gray;opacity:0.5;'>CONFIDENTIAL</h1>",
45,
VerticalAlignment.Middle,
HorizontalAlignment.Center);
pdf.SaveAs("watermarked.pdf");
}
}
Imports IronPdf
Imports IronPdf.Editing
Class Program
Shared Sub Main()
Dim pdf = PdfDocument.FromFile("document.pdf")
pdf.ApplyWatermark("<h1 style='color:gray;opacity:0.5;'>CONFIDENTIAL</h1>",
45,
VerticalAlignment.Middle,
HorizontalAlignment.Center)
pdf.SaveAs("watermarked.pdf")
End Sub
End Class
Este ejemplo destaca una diferencia arquitectónica fundamental. GdPicture usa un enfoque de llamadas de dibujo procedural: añade una fuente estándar, luego itera (con base en 1) a través de cada página llamando SelectPage, SetFillAlpha, SetTextSize, SetOriginRotationInDegrees, y DrawTextBox. Alfa está en una escala de bytes 0–255, la rotación se establece como una propiedad de estado gráfico, y el posicionamiento se maneja a través de coordenadas explícitas.
IronPDF utiliza un enfoque basado en HTML: el método ApplyWatermark() acepta una cadena HTML con CSS estilo y la aplica a todas las páginas en una sola llamada. Controlas la apariencia a través de propiedades CSS familiares (color, opacity, font-size) en lugar de llamadas gráficas primitivas. Este enfoque también soporta contenido más rico: gradientes, imágenes y disposiciones más complejas, en la misma cadena. Consulta la documentación de marca de agua para ejemplos avanzados.
Notas críticas de migración
Superficie de entrada de HTML
El cargador de HTML de GdPicture está basado en archivo/URL;IronPDF acepta cadenas HTML directamente:
// Nutrient .NET SDK (string -> file -> PDF):
File.WriteAllText("input.html", html);
converter.LoadFromFile("input.html", DocumentFormat.DocumentFormatHTML);
converter.SaveAsPDF("output.pdf");
//IronPDF(string -> PDF):
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
// Nutrient .NET SDK (string -> file -> PDF):
File.WriteAllText("input.html", html);
converter.LoadFromFile("input.html", DocumentFormat.DocumentFormatHTML);
converter.SaveAsPDF("output.pdf");
//IronPDF(string -> PDF):
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
' Nutrient .NET SDK (string -> file -> PDF):
File.WriteAllText("input.html", html)
converter.LoadFromFile("input.html", DocumentFormat.DocumentFormatHTML)
converter.SaveAsPDF("output.pdf")
' IronPDF(string -> PDF):
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
Si necesitas operaciones asincrónicas,IronPDF proporciona variantes asincrónicas como RenderHtmlAsPdfAsync().
Dependencia de navegador externo
El renderizador HTML de GdPicture depende de una instalación de Chrome o Edge en el sistema (o una ruta portable que configuras a través de SetWebBrowserPath).IronPDF envía su propio Chromium integrado:
// Nutrient .NET SDK: optionally point to a portable Chrome
converter.SetWebBrowserPath(@"C:\Tools\chrome\chrome.exe");
// IronPDF: nothing to configure
var pdf = renderer.RenderHtmlAsPdf(html);
// Nutrient .NET SDK: optionally point to a portable Chrome
converter.SetWebBrowserPath(@"C:\Tools\chrome\chrome.exe");
// IronPDF: nothing to configure
var pdf = renderer.RenderHtmlAsPdf(html);
' Nutrient .NET SDK: optionally point to a portable Chrome
converter.SetWebBrowserPath("C:\Tools\chrome\chrome.exe")
' IronPDF: nothing to configure
Dim pdf = renderer.RenderHtmlAsPdf(html)
Cambio de patrón de configuración
GdPicture expone configuraciones de diseño como valores por propiedad en el convertidor (ancho/alto de página HTML en pulgadas, márgenes individuales).IronPDF los agrupa en una bolsa RenderingOptions con tamaños de papel nombrados:
// Nutrient .NET SDK: properties on the converter (inches)
using var converter = new GdPictureDocumentConverter();
converter.HtmlPageWidth = 8.27f; // A4 width (inches)
converter.HtmlPageHeight = 11.69f; // A4 height (inches)
converter.HtmlMarginTop = 0.78f;
converter.HtmlMarginBottom = 0.78f;
converter.HtmlMarginLeft = 0.78f;
converter.HtmlMarginRight = 0.78f;
// IronPDF: properties on RenderingOptions (millimetres)
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.MarginTop = 20;
renderer.RenderingOptions.MarginBottom = 20;
renderer.RenderingOptions.MarginLeft = 20;
renderer.RenderingOptions.MarginRight = 20;
var pdf = renderer.RenderHtmlAsPdf(html);
// Nutrient .NET SDK: properties on the converter (inches)
using var converter = new GdPictureDocumentConverter();
converter.HtmlPageWidth = 8.27f; // A4 width (inches)
converter.HtmlPageHeight = 11.69f; // A4 height (inches)
converter.HtmlMarginTop = 0.78f;
converter.HtmlMarginBottom = 0.78f;
converter.HtmlMarginLeft = 0.78f;
converter.HtmlMarginRight = 0.78f;
// IronPDF: properties on RenderingOptions (millimetres)
var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.MarginTop = 20;
renderer.RenderingOptions.MarginBottom = 20;
renderer.RenderingOptions.MarginLeft = 20;
renderer.RenderingOptions.MarginRight = 20;
var pdf = renderer.RenderHtmlAsPdf(html);
Imports GdPicture14
Imports IronPdf
' Nutrient .NET SDK: properties on the converter (inches)
Using converter As New GdPictureDocumentConverter()
converter.HtmlPageWidth = 8.27F ' A4 width (inches)
converter.HtmlPageHeight = 11.69F ' A4 height (inches)
converter.HtmlMarginTop = 0.78F
converter.HtmlMarginBottom = 0.78F
converter.HtmlMarginLeft = 0.78F
converter.HtmlMarginRight = 0.78F
End Using
' IronPDF: properties on RenderingOptions (millimetres)
Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
renderer.RenderingOptions.MarginTop = 20
renderer.RenderingOptions.MarginBottom = 20
renderer.RenderingOptions.MarginLeft = 20
renderer.RenderingOptions.MarginRight = 20
Dim pdf = renderer.RenderHtmlAsPdf(html)
De marcas de agua procedurales a HTML
Reemplaza llamadas de dibujo primitivas con una sola cadena HTML/CSS:
// Nutrient .NET SDK: SetFillAlpha + SetTextSize + DrawTextBox in a per-page loop
pdf.SetFillAlpha(128);
pdf.SetTextSize(48);
pdf.SetOriginRotationInDegrees(45);
pdf.DrawTextBox(font, 100, 300, 500, 400, "CONFIDENTIAL",
PdfHorizontalAlignment.PdfHorizontalAlignmentCenter,
PdfVerticalAlignment.PdfVerticalAlignmentMiddle);
// IronPDF: one HTML/CSS string
pdf.ApplyWatermark("<h1 style='opacity:0.5; font-size:48px;'>CONFIDENTIAL</h1>",
45, VerticalAlignment.Middle, HorizontalAlignment.Center);
// Nutrient .NET SDK: SetFillAlpha + SetTextSize + DrawTextBox in a per-page loop
pdf.SetFillAlpha(128);
pdf.SetTextSize(48);
pdf.SetOriginRotationInDegrees(45);
pdf.DrawTextBox(font, 100, 300, 500, 400, "CONFIDENTIAL",
PdfHorizontalAlignment.PdfHorizontalAlignmentCenter,
PdfVerticalAlignment.PdfVerticalAlignmentMiddle);
// IronPDF: one HTML/CSS string
pdf.ApplyWatermark("<h1 style='opacity:0.5; font-size:48px;'>CONFIDENTIAL</h1>",
45, VerticalAlignment.Middle, HorizontalAlignment.Center);
' Nutrient .NET SDK: SetFillAlpha + SetTextSize + DrawTextBox in a per-page loop
pdf.SetFillAlpha(128)
pdf.SetTextSize(48)
pdf.SetOriginRotationInDegrees(45)
pdf.DrawTextBox(font, 100, 300, 500, 400, "CONFIDENTIAL", PdfHorizontalAlignment.PdfHorizontalAlignmentCenter, PdfVerticalAlignment.PdfVerticalAlignmentMiddle)
' IronPDF: one HTML/CSS string
pdf.ApplyWatermark("<h1 style='opacity:0.5; font-size:48px;'>CONFIDENTIAL</h1>", 45, VerticalAlignment.Middle, HorizontalAlignment.Center)
Manejo de números de página
GdPicture no tiene un modelo de encabezado/pie de página de primera clase: los números de página se dibujan por página en un bucle.IronPDF expone los marcadores {page} / {total-pages} integrados:
// Nutrient .NET SDK: per-page DrawText loop (1-based)
for (int i = 1; i <= pdf.GetPageCount(); i++)
{
pdf.SelectPage(i);
pdf.DrawText(font, x, y, $"Page {i} of {pdf.GetPageCount()}");
}
// IronPDF: built-in placeholders
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
HtmlFragment = "Page {page} of {total-pages}"
};
// Nutrient .NET SDK: per-page DrawText loop (1-based)
for (int i = 1; i <= pdf.GetPageCount(); i++)
{
pdf.SelectPage(i);
pdf.DrawText(font, x, y, $"Page {i} of {pdf.GetPageCount()}");
}
// IronPDF: built-in placeholders
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
HtmlFragment = "Page {page} of {total-pages}"
};
' Nutrient .NET SDK: per-page DrawText loop (1-based)
For i As Integer = 1 To pdf.GetPageCount()
pdf.SelectPage(i)
pdf.DrawText(font, x, y, $"Page {i} of {pdf.GetPageCount()}")
Next
' IronPDF: built-in placeholders
renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter With {
.HtmlFragment = "Page {page} of {total-pages}"
}
Indexación de páginas
GdPicture es con base en 1 (SelectPage(1) es la primera página).IronPDFpdf.Pages y pdf.RemovePages(int) son con base en 0. El error más común al portear es el de una posición:
// Nutrient .NET SDK (1-based):
pdf.SelectPage(1);
pdf.DeletePage();
//IronPDF(0-based):
pdf.RemovePages(0);
// Nutrient .NET SDK (1-based):
pdf.SelectPage(1);
pdf.DeletePage();
//IronPDF(0-based):
pdf.RemovePages(0);
' Nutrient .NET SDK (1-based):
pdf.SelectPage(1)
pdf.DeletePage()
' IronPDF(0-based):
pdf.RemovePages(0)
Solución de problemas
Problema 1: GdPictureDocumentConverter no encontrado
Problem: GdPictureDocumentConverter class doesn't exist in IronPDF.
Solución: Utiliza ChromePdfRenderer para HTML/URL → PDF:
// Nutrient .NET SDK
using var converter = new GdPictureDocumentConverter();
// IronPDF
var renderer = new ChromePdfRenderer();
// Nutrient .NET SDK
using var converter = new GdPictureDocumentConverter();
// IronPDF
var renderer = new ChromePdfRenderer();
Imports GdPicture14
Imports IronPdf
' Nutrient .NET SDK
Using converter As New GdPictureDocumentConverter()
' Your code here
End Using
' IronPDF
Dim renderer As New ChromePdfRenderer()
Problema 2: GdPicturePDF no encontrado
Problem: GdPicturePDF class doesn't exist in IronPDF.
Solución: Utilice PdfDocument:
// Nutrient .NET SDK
using var pdf = new GdPicturePDF();
pdf.LoadFromFile("input.pdf");
// IronPDF
var pdf = PdfDocument.FromFile("input.pdf");
// Nutrient .NET SDK
using var pdf = new GdPicturePDF();
pdf.LoadFromFile("input.pdf");
// IronPDF
var pdf = PdfDocument.FromFile("input.pdf");
Imports GdPicture14
Imports IronPdf
' Nutrient .NET SDK
Using pdf As New GdPicturePDF()
pdf.LoadFromFile("input.pdf")
End Using
' IronPDF
Dim pdfDocument = PdfDocument.FromFile("input.pdf")
Problema 3: DrawTextBox / SetFillAlpha no encontrado
Problema: Las llamadas de dibujo primitivas no existen en IronPDF.
Solución: Usa marcas de agua basadas en HTML:
// Nutrient .NET SDK
pdf.SetFillAlpha(128);
pdf.DrawTextBox(font, 100, 300, 500, 400, "DRAFT",
PdfHorizontalAlignment.PdfHorizontalAlignmentCenter,
PdfVerticalAlignment.PdfVerticalAlignmentMiddle);
// IronPDF
pdf.ApplyWatermark("<div style='opacity:0.5;'>DRAFT</div>",
45, VerticalAlignment.Middle, HorizontalAlignment.Center);
// Nutrient .NET SDK
pdf.SetFillAlpha(128);
pdf.DrawTextBox(font, 100, 300, 500, 400, "DRAFT",
PdfHorizontalAlignment.PdfHorizontalAlignmentCenter,
PdfVerticalAlignment.PdfVerticalAlignmentMiddle);
// IronPDF
pdf.ApplyWatermark("<div style='opacity:0.5;'>DRAFT</div>",
45, VerticalAlignment.Middle, HorizontalAlignment.Center);
' Nutrient .NET SDK
pdf.SetFillAlpha(128)
pdf.DrawTextBox(font, 100, 300, 500, 400, "DRAFT", PdfHorizontalAlignment.PdfHorizontalAlignmentCenter, PdfVerticalAlignment.PdfVerticalAlignmentMiddle)
' IronPDF
pdf.ApplyWatermark("<div style='opacity:0.5;'>DRAFT</div>", 45, VerticalAlignment.Middle, HorizontalAlignment.Center)
Problema 4: CombineToPDF no encontrado
Problema: El método combinatorio basado en ruta no existe.
Solución: Carga cada PDF como un PdfDocument y usa el PdfDocument.Merge() estático:
// Nutrient .NET SDK
converter.CombineToPDF(paths, "merged.pdf", PdfConformance.PDF);
// IronPDF
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
// Nutrient .NET SDK
converter.CombineToPDF(paths, "merged.pdf", PdfConformance.PDF);
// IronPDF
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
' Nutrient .NET SDK
converter.CombineToPDF(paths, "merged.pdf", PdfConformance.PDF)
' IronPDF
Dim merged = PdfDocument.Merge(pdf1, pdf2)
merged.SaveAs("merged.pdf")
Problema 5: Índice de página con diferencia de una posición
Problema: GdPicture utiliza índices de páginas con base en 1;IronPDF utiliza índices con base en 0. Los puertos directos de SelectPage(1) a pdf.Pages[1] omiten la primera página.
Solución: Resta uno al portar índices de página:
// Nutrient .NET SDK (first page)
pdf.SelectPage(1);
//IronPDF(first page)
var firstPage = pdf.Pages[0];
// Nutrient .NET SDK (first page)
pdf.SelectPage(1);
//IronPDF(first page)
var firstPage = pdf.Pages[0];
' Nutrient .NET SDK (first page)
pdf.SelectPage(1)
' IronPDF(first page)
Dim firstPage = pdf.Pages(0)
Lista de verificación de migración
Pre-migración
- Inventario de todas las utilizaciones de GdPicture / PSPDFKit / Nutrient en el código base
- Nota de indexación de página con base en 1 vs con base en 0 en el código GdPicture existente
- Lista de configuraciones establecidas en
GdPictureDocumentConverter(dimensiones de página HTML, márgenes) - Identificar dibujo procedural para marcas de agua y encabezados (
SetFillAlpha,DrawTextBox) - Revisar el código de campos de formulario que utiliza acceso basado en índices (
GetFormFieldName(i)) - Obtener clave de licencia de IronPDF
Cambios en el paquete
- Retirar el paquete NuGet
GdPicture(yGdPicture.WPF/GdPicture.WinFormssi están presentes) - Retirar el paquete
PSPDFKit.NETheredado si está presente - Instalar el paquete NuGet
IronPdf:dotnet add package IronPdf - Actualizar importaciones del espacio de nombres (
using GdPicture14;→using IronPdf;)
Cambios en el código
- Añadir configuración de clave de licencia al inicio
- Reemplazar
new GdPictureDocumentConverter()connew ChromePdfRenderer()para HTML/URL → PDF - Reemplazar
new GdPicturePDF()+LoadFromFileconPdfDocument.FromFile() - Reemplazar
converter.CombineToPDF(paths, ...)conPdfDocument.Merge() - Convertir llamadas de dibujo de marcas de agua procedurales a
pdf.ApplyWatermark(html, ...) - Reemplazar propiedades del convertidor con
RenderingOptions(tamaños de papel nombrados, márgenes en mm) - Actualizar encabezados/pies de página a
HtmlHeaderFootercon{page}/{total-pages}marcadores - Convertir índices de página con base en 1 a índices con base en 0 en todo
Post-migración
- Retirar la dependencia de Chrome / Edge del sistema de las imágenes de despliegue si sólo estaba allí para GdPicture
- Ejecutar pruebas de regresión comparando el output de PDF
- Verificar encabezados/pies de página con números de página
- Probar el renderizado de marcas de agua
- Actualizar la tubería CI/CD
[{(i: Nutrient, PSPDFKit, GdPicture y ORPALIS son marcas comerciales de sus respectivos propietarios. Este sitio no está afiliado, respaldado ni patrocinado por Nutrient, PSPDFKit, GdPicture ni ORPALIS. Todos los nombres de productos, logotipos y marcas son propiedad de sus respectivos dueños. Las comparaciones son solo para fines informativos y reflejan la información públicamente disponible en el momento de la escritura.)}]

