Pruebe en producción sin marcas de agua.
Funciona donde lo necesite.
Obtén 30 días de producto totalmente funcional.
Ténlo en funcionamiento en minutos.
Acceso completo a nuestro equipo de asistencia técnica durante la prueba del producto
IronPDF y EvoPdf son dos bibliotecas .NET destacadas utilizadas para crear, editar y gestionar documentos PDF. Cada uno tiene fortalezas y características únicas adaptadas a los desarrolladores que trabajan en plataformas .NET. Este artículo proporcionará una comparación detallada de estas dos bibliotecas, centrándose en sus características, compatibilidad, licencias, soporte y más.
Con suerte, al final de este artículo, podrás identificar qué biblioteca se adapta mejor a tus necesidades de PDF y podrás hacer una comparación por tu cuenta si deseas investigar más opciones de bibliotecas de PDF.
IronPDF es una biblioteca PDF de .NET que permite a los desarrolladores crear, editar y manipular documentos PDF de forma programática. Se conoce por su facilidad de uso, amplia compatibilidad con versiones de .NET y su capacidad para convertir archivos HTML, ASPX e imágenes a PDF manteniendo una alta fidelidad al contenido original. La extensa documentación de IronPDF, su sólido soporte al cliente y su amplio conjunto de funcionalidades lo convierten en la opción preferida para los desarrolladores que buscan integrar la funcionalidad PDF en sus aplicaciones .NET.
EvoPdf es otra biblioteca .NET diseñada para la conversión de HTML a PDF y otras tareas de manipulación de PDF. Ofrece soporte avanzado para etiquetas HTML, CSS, JavaScript y otras tecnologías web modernas, lo que permite la generación de documentos PDF de alta calidad a partir de contenido web. EvoPdf es apreciado por sus capacidades de renderizado y su amplio soporte para los estándares web, lo que lo convierte en una herramienta valiosa para los desarrolladores enfocados en la conversión de web a PDF.
IronPDF ofrece una amplia compatibilidad multiplataforma, lo que lo convierte en una herramienta versátil para diversos entornos:
Versiones de .NET:
Totalmente escrito en y compatible con C#, VB.NET y F#
.NET Core (8, 7, 6, 5 y 3.1+)
Sistemas operativos y procesadores: Soporta varios sistemas operativos y procesadores diferentes, incluyendo Windows, Mac, Linux, x64, x86, ARM
Para obtener más detalles sobre la compatibilidad de IronPDF, visite Compatibilidad de IronPDF.
Versiones de .NET:
.NET Core (8, 7, 6 y 5)
IronPDF y EvoPdf ofrecen potentes funciones de manipulación de PDF, pero existen diferencias distintivas que los desarrolladores deberían considerar:
Integración: Se integra perfectamente con ASP.NET y aplicaciones MVC.
Para obtener una lista exhaustiva de las características de IronPDF, visite Características de IronPDF.
A continuación se presenta una comparación detallada de las principales características entre IronPDF y EvoPdf, con ejemplos de código específicos para demostrar su uso.
IronPDF:
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
Imports IronPdf
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
' Create a PDF from an HTML string using C#
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
' Export to a file or Stream
pdf.SaveAs("output.pdf")
EvoPdf:
using EvoPdf;
// create the converter object in your code where you want to run conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();
// convert the HTML string to a PDF file
converter.ConvertHtmlToFile("<b>Hello World</b> from EVO PDF !", null, "HtmlToFile.pdf");
// convert HTML pages from URL to a PDF file
string htmlPageURL = "http://www.evopdf.com";
converter.ConvertUrlToFile(htmlPageURL, "UrlToFile.pdf");
using EvoPdf;
// create the converter object in your code where you want to run conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();
// convert the HTML string to a PDF file
converter.ConvertHtmlToFile("<b>Hello World</b> from EVO PDF !", null, "HtmlToFile.pdf");
// convert HTML pages from URL to a PDF file
string htmlPageURL = "http://www.evopdf.com";
converter.ConvertUrlToFile(htmlPageURL, "UrlToFile.pdf");
Imports EvoPdf
' create the converter object in your code where you want to run conversion
Private converter As New HtmlToPdfConverter()
' convert the HTML string to a PDF file
converter.ConvertHtmlToFile("<b>Hello World</b> from EVO PDF !", Nothing, "HtmlToFile.pdf")
' convert HTML pages from URL to a PDF file
Dim htmlPageURL As String = "http://www.evopdf.com"
converter.ConvertUrlToFile(htmlPageURL, "UrlToFile.pdf")
La conversión de HTML a PDF es una tarea común relacionada con PDF, y como puedes ver en los ejemplos de código anteriores, tanto IronPDF como EvoPdf pueden abordar fácilmente este trabajo. IronPDF proporciona una representación de píxeles perfectos del contenido HTML gracias a su soporte web moderno, de modo que puedes crear documentos PDF en sólo unas pocas líneas de código manteniendo la calidad de renderización original.
IronPDF:
using IronPdf;
using System;
// Open an Encrypted File, alternatively create a new PDF from Html
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
// Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = DateTime.Now;
// Edit file security settings
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
using IronPdf;
using System;
// Open an Encrypted File, alternatively create a new PDF from Html
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
// Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = DateTime.Now;
// Edit file security settings
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
Imports IronPdf
Imports System
' Open an Encrypted File, alternatively create a new PDF from Html
Private pdf = PdfDocument.FromFile("encrypted.pdf", "password")
' Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto"
pdf.MetaData.Keywords = "SEO, Friendly"
pdf.MetaData.ModifiedDate = DateTime.Now
' Edit file security settings
pdf.SecuritySettings.RemovePasswordsAndEncryption()
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key")
pdf.SecuritySettings.AllowUserAnnotations = False
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserFormData = False
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights
' change or set the document encryption password
pdf.Password = "my-password"
pdf.SaveAs("secured.pdf")
EvoPdf:
PdfSecurityOptions securityOptions = new PdfSecurityOptions();
securityOptions.CanAssembleDocument = canAssembleDocument;
securityOptions.CanCopyContent = canCopyContent;
securityOptions.CanEditAnnotations = canEditAnnotations;
securityOptions.CanEditContent = canEditContent;
securityOptions.CanFillFormFields = canFillFormFields;
securityOptions.CanPrint = canPrint;
securityOptions.KeySize = keySize;
securityOptions.UserPassword = userPassword;
securityOptions.OwnerPassword = ownerPassword;
PdfSecurityManager securityManager = new PdfSecurityManager(securityOptions);
if (removeSecurity)
securityManager.SaveUnSecuredPdfToFile(srcPdfFile, outFile, removeSecurityPswd);
else
securityManager.SaveSecuredPdfToFile(srcPdfFile, outFile);
PdfSecurityOptions securityOptions = new PdfSecurityOptions();
securityOptions.CanAssembleDocument = canAssembleDocument;
securityOptions.CanCopyContent = canCopyContent;
securityOptions.CanEditAnnotations = canEditAnnotations;
securityOptions.CanEditContent = canEditContent;
securityOptions.CanFillFormFields = canFillFormFields;
securityOptions.CanPrint = canPrint;
securityOptions.KeySize = keySize;
securityOptions.UserPassword = userPassword;
securityOptions.OwnerPassword = ownerPassword;
PdfSecurityManager securityManager = new PdfSecurityManager(securityOptions);
if (removeSecurity)
securityManager.SaveUnSecuredPdfToFile(srcPdfFile, outFile, removeSecurityPswd);
else
securityManager.SaveSecuredPdfToFile(srcPdfFile, outFile);
Dim securityOptions As New PdfSecurityOptions()
securityOptions.CanAssembleDocument = canAssembleDocument
securityOptions.CanCopyContent = canCopyContent
securityOptions.CanEditAnnotations = canEditAnnotations
securityOptions.CanEditContent = canEditContent
securityOptions.CanFillFormFields = canFillFormFields
securityOptions.CanPrint = canPrint
securityOptions.KeySize = keySize
securityOptions.UserPassword = userPassword
securityOptions.OwnerPassword = ownerPassword
Dim securityManager As New PdfSecurityManager(securityOptions)
If removeSecurity Then
securityManager.SaveUnSecuredPdfToFile(srcPdfFile, outFile, removeSecurityPswd)
Else
securityManager.SaveSecuredPdfToFile(srcPdfFile, outFile)
End If
IronPDF ofrece una API completa para gestionar la cifrado configuraciones, dándote control total sobre el proceso y diversas configuraciones de seguridad. La herramienta de cifrado de EvoPdf ofrece un nivel similar de control sobre el proceso, lo que la convierte en otra fuerte competidora para el cifrado de PDF.
IronPDF:
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are")
pdf.SaveAs("redacted.pdf")
EvoPdf: No cuenta con soporte incorporado para el redactado de texto.
IronPDF le proporciona una potente herramienta de redacción de PDF capaz de redactar el contenido especificado de su archivo PDF con solo unas pocas líneas de código. Por otro lado, EvoPdf no ofrece ninguna herramienta de redacción de PDF integrada.
IronPDF:
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>foo</h1>")
' Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
Private cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create PdfSignature object
Private sig = New PdfSignature(cert)
' Sign PDF document
pdf.Sign(sig)
pdf.SaveAs("signed.pdf")
EvoPdf:
protected void convertToPdfButton_Click(object sender, EventArgs e)
{
// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
// Set license key received after purchase to use the converter in licensed mode
// Leave it not set to use the converter in demo mode
htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=";
Document pdfDocument = null;
try
{
string htmlWithDigitalSignatureMarker = htmlStringTextBox.Text;
string baseUrl = baseUrlTextBox.Text;
// Convert a HTML string with a marker for digital signature to a PDF document object
pdfDocument = htmlToPdfConverter.ConvertHtmlToPdfDocumentObject(htmlWithDigitalSignatureMarker, baseUrl);
// Make the HTML element with 'digital_signature_element' mapping ID a link to digital signature properties
HtmlElementMapping digitalSignatureMapping = htmlToPdfConverter.HtmlElementsMappingOptions.HtmlElementsMappingResult.GetElementByMappingId("digital_signature_element");
if (digitalSignatureMapping != null)
{
PdfPage digitalSignaturePage = digitalSignatureMapping.PdfRectangles[0].PdfPage;
RectangleF digitalSignatureRectangle = digitalSignatureMapping.PdfRectangles[0].Rectangle;
string certificateFilePath = Server.MapPath("~/DemoAppFiles/Input/Certificates/evopdf.pfx");
// Get the certificate from password protected PFX file
DigitalCertificatesCollection certificates = DigitalCertificatesStore.GetCertificates(certificateFilePath, "evopdf");
DigitalCertificate certificate = certificates[0];
// Create the digital signature
DigitalSignatureElement signature = new DigitalSignatureElement(digitalSignatureRectangle, certificate);
signature.Reason = "Protect the document from unwanted changes";
signature.ContactInfo = "The contact email is support@evopdf.com";
signature.Location = "Development server";
digitalSignaturePage.AddElement(signature);
}
// Save the PDF document in a memory buffer
byte[] outPdfBuffer = pdfDocument.Save();
// Send the PDF as response to browser
// Set response content type
Response.AddHeader("Content-Type", "application/pdf");
// Instruct the browser to open the PDF file as an attachment or inline
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Digital_Signatures.pdf; size={0}", outPdfBuffer.Length.ToString()));
// Write the PDF document buffer to HTTP response
Response.BinaryWrite(outPdfBuffer);
// End the HTTP response and stop the current page processing
Response.End();
}
finally
{
// Close the PDF document
if (pdfDocument != null)
pdfDocument.Close();
}
}
protected void convertToPdfButton_Click(object sender, EventArgs e)
{
// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
// Set license key received after purchase to use the converter in licensed mode
// Leave it not set to use the converter in demo mode
htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=";
Document pdfDocument = null;
try
{
string htmlWithDigitalSignatureMarker = htmlStringTextBox.Text;
string baseUrl = baseUrlTextBox.Text;
// Convert a HTML string with a marker for digital signature to a PDF document object
pdfDocument = htmlToPdfConverter.ConvertHtmlToPdfDocumentObject(htmlWithDigitalSignatureMarker, baseUrl);
// Make the HTML element with 'digital_signature_element' mapping ID a link to digital signature properties
HtmlElementMapping digitalSignatureMapping = htmlToPdfConverter.HtmlElementsMappingOptions.HtmlElementsMappingResult.GetElementByMappingId("digital_signature_element");
if (digitalSignatureMapping != null)
{
PdfPage digitalSignaturePage = digitalSignatureMapping.PdfRectangles[0].PdfPage;
RectangleF digitalSignatureRectangle = digitalSignatureMapping.PdfRectangles[0].Rectangle;
string certificateFilePath = Server.MapPath("~/DemoAppFiles/Input/Certificates/evopdf.pfx");
// Get the certificate from password protected PFX file
DigitalCertificatesCollection certificates = DigitalCertificatesStore.GetCertificates(certificateFilePath, "evopdf");
DigitalCertificate certificate = certificates[0];
// Create the digital signature
DigitalSignatureElement signature = new DigitalSignatureElement(digitalSignatureRectangle, certificate);
signature.Reason = "Protect the document from unwanted changes";
signature.ContactInfo = "The contact email is support@evopdf.com";
signature.Location = "Development server";
digitalSignaturePage.AddElement(signature);
}
// Save the PDF document in a memory buffer
byte[] outPdfBuffer = pdfDocument.Save();
// Send the PDF as response to browser
// Set response content type
Response.AddHeader("Content-Type", "application/pdf");
// Instruct the browser to open the PDF file as an attachment or inline
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Digital_Signatures.pdf; size={0}", outPdfBuffer.Length.ToString()));
// Write the PDF document buffer to HTTP response
Response.BinaryWrite(outPdfBuffer);
// End the HTTP response and stop the current page processing
Response.End();
}
finally
{
// Close the PDF document
if (pdfDocument != null)
pdfDocument.Close();
}
}
Protected Sub convertToPdfButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Create a HTML to PDF converter object with default settings
Dim htmlToPdfConverter As New HtmlToPdfConverter()
' Set license key received after purchase to use the converter in licensed mode
' Leave it not set to use the converter in demo mode
htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c="
Dim pdfDocument As Document = Nothing
Try
Dim htmlWithDigitalSignatureMarker As String = htmlStringTextBox.Text
Dim baseUrl As String = baseUrlTextBox.Text
' Convert a HTML string with a marker for digital signature to a PDF document object
pdfDocument = htmlToPdfConverter.ConvertHtmlToPdfDocumentObject(htmlWithDigitalSignatureMarker, baseUrl)
' Make the HTML element with 'digital_signature_element' mapping ID a link to digital signature properties
Dim digitalSignatureMapping As HtmlElementMapping = htmlToPdfConverter.HtmlElementsMappingOptions.HtmlElementsMappingResult.GetElementByMappingId("digital_signature_element")
If digitalSignatureMapping IsNot Nothing Then
Dim digitalSignaturePage As PdfPage = digitalSignatureMapping.PdfRectangles(0).PdfPage
Dim digitalSignatureRectangle As RectangleF = digitalSignatureMapping.PdfRectangles(0).Rectangle
Dim certificateFilePath As String = Server.MapPath("~/DemoAppFiles/Input/Certificates/evopdf.pfx")
' Get the certificate from password protected PFX file
Dim certificates As DigitalCertificatesCollection = DigitalCertificatesStore.GetCertificates(certificateFilePath, "evopdf")
Dim certificate As DigitalCertificate = certificates(0)
' Create the digital signature
Dim signature As New DigitalSignatureElement(digitalSignatureRectangle, certificate)
signature.Reason = "Protect the document from unwanted changes"
signature.ContactInfo = "The contact email is support@evopdf.com"
signature.Location = "Development server"
digitalSignaturePage.AddElement(signature)
End If
' Save the PDF document in a memory buffer
Dim outPdfBuffer() As Byte = pdfDocument.Save()
' Send the PDF as response to browser
' Set response content type
Response.AddHeader("Content-Type", "application/pdf")
' Instruct the browser to open the PDF file as an attachment or inline
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Digital_Signatures.pdf; size={0}", outPdfBuffer.Length.ToString()))
' Write the PDF document buffer to HTTP response
Response.BinaryWrite(outPdfBuffer)
' End the HTTP response and stop the current page processing
Response.End()
Finally
' Close the PDF document
If pdfDocument IsNot Nothing Then
pdfDocument.Close()
End If
End Try
End Sub
IronPDF ofrece una potente API para aplicar firmas digitales a tus archivos PDF, manteniendo el proceso simple y fácil de entender. EvoPdf ofrece un soporte básico para firmar pero carece de las extensas opciones que proporciona IronPDF, además de tomar un enfoque manual y más complejo.
IronPDF:
using IronPdf;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf/");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
using IronPdf;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf/");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
Imports IronPdf
' Stamps a Watermark onto a new or existing PDF
Private renderer = New ChromePdfRenderer()
Private pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf/")
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
pdf.SaveAs("C:\Path\To\Watermarked.pdf")
EvoPdf:
protected void convertToPdfButton_Click(object sender, EventArgs e)
{
// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=";
Document pdfDocument = null;
try
{
// Convert a HTML page to a PDF document object
pdfDocument = htmlToPdfConverter.ConvertUrlToPdfDocumentObject(urlTextBox.Text);
// Get the stamp width and height
float stampWidth = float.Parse(stampWidthTextBox.Text);
float stampHeight = float.Parse(stampHeightTextBox.Text);
// Center the stamp at the top of PDF page
float stampXLocation = (pdfDocument.Pages[0].ClientRectangle.Width - stampWidth) / 2;
float stampYLocation = 0;
RectangleF stampRectangle = new RectangleF(stampXLocation, stampYLocation, stampWidth, stampHeight);
// Create the stamp template to be repeated in each PDF page
Template stampTemplate = pdfDocument.AddTemplate(stampRectangle);
// Create the HTML element to add in stamp template
HtmlToPdfElement stampHtmlElement = new HtmlToPdfElement(htmlStringTextBox.Text, baseUrlTextBox.Text);
// Set the HTML viewer width for the HTML added in stamp
stampHtmlElement.HtmlViewerWidth = 600;
// Fit the HTML content in stamp template
stampHtmlElement.FitWidth = true;
stampHtmlElement.FitHeight = true;
// Add HTML to stamp template
stampTemplate.AddElement(stampHtmlElement);
// Save the PDF document in a memory buffer
byte[] outPdfBuffer = pdfDocument.Save();
// Send the PDF as response to browser
// Set response content type
Response.AddHeader("Content-Type", "application/pdf");
// Instruct the browser to open the PDF file as an attachment or inline
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Watermarks_and_Stamps.pdf; size={0}", outPdfBuffer.Length.ToString()));
// Write the PDF document buffer to HTTP response
Response.BinaryWrite(outPdfBuffer);
// End the HTTP response and stop the current page processing
Response.End();
}
finally
{
// Close the PDF document
if (pdfDocument != null)
pdfDocument.Close();
}
}
protected void convertToPdfButton_Click(object sender, EventArgs e)
{
// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=";
Document pdfDocument = null;
try
{
// Convert a HTML page to a PDF document object
pdfDocument = htmlToPdfConverter.ConvertUrlToPdfDocumentObject(urlTextBox.Text);
// Get the stamp width and height
float stampWidth = float.Parse(stampWidthTextBox.Text);
float stampHeight = float.Parse(stampHeightTextBox.Text);
// Center the stamp at the top of PDF page
float stampXLocation = (pdfDocument.Pages[0].ClientRectangle.Width - stampWidth) / 2;
float stampYLocation = 0;
RectangleF stampRectangle = new RectangleF(stampXLocation, stampYLocation, stampWidth, stampHeight);
// Create the stamp template to be repeated in each PDF page
Template stampTemplate = pdfDocument.AddTemplate(stampRectangle);
// Create the HTML element to add in stamp template
HtmlToPdfElement stampHtmlElement = new HtmlToPdfElement(htmlStringTextBox.Text, baseUrlTextBox.Text);
// Set the HTML viewer width for the HTML added in stamp
stampHtmlElement.HtmlViewerWidth = 600;
// Fit the HTML content in stamp template
stampHtmlElement.FitWidth = true;
stampHtmlElement.FitHeight = true;
// Add HTML to stamp template
stampTemplate.AddElement(stampHtmlElement);
// Save the PDF document in a memory buffer
byte[] outPdfBuffer = pdfDocument.Save();
// Send the PDF as response to browser
// Set response content type
Response.AddHeader("Content-Type", "application/pdf");
// Instruct the browser to open the PDF file as an attachment or inline
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Watermarks_and_Stamps.pdf; size={0}", outPdfBuffer.Length.ToString()));
// Write the PDF document buffer to HTTP response
Response.BinaryWrite(outPdfBuffer);
// End the HTTP response and stop the current page processing
Response.End();
}
finally
{
// Close the PDF document
if (pdfDocument != null)
pdfDocument.Close();
}
}
Protected Sub convertToPdfButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Create a HTML to PDF converter object with default settings
Dim htmlToPdfConverter As New HtmlToPdfConverter()
htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c="
Dim pdfDocument As Document = Nothing
Try
' Convert a HTML page to a PDF document object
pdfDocument = htmlToPdfConverter.ConvertUrlToPdfDocumentObject(urlTextBox.Text)
' Get the stamp width and height
Dim stampWidth As Single = Single.Parse(stampWidthTextBox.Text)
Dim stampHeight As Single = Single.Parse(stampHeightTextBox.Text)
' Center the stamp at the top of PDF page
Dim stampXLocation As Single = (pdfDocument.Pages(0).ClientRectangle.Width - stampWidth) / 2
Dim stampYLocation As Single = 0
Dim stampRectangle As New RectangleF(stampXLocation, stampYLocation, stampWidth, stampHeight)
' Create the stamp template to be repeated in each PDF page
Dim stampTemplate As Template = pdfDocument.AddTemplate(stampRectangle)
' Create the HTML element to add in stamp template
Dim stampHtmlElement As New HtmlToPdfElement(htmlStringTextBox.Text, baseUrlTextBox.Text)
' Set the HTML viewer width for the HTML added in stamp
stampHtmlElement.HtmlViewerWidth = 600
' Fit the HTML content in stamp template
stampHtmlElement.FitWidth = True
stampHtmlElement.FitHeight = True
' Add HTML to stamp template
stampTemplate.AddElement(stampHtmlElement)
' Save the PDF document in a memory buffer
Dim outPdfBuffer() As Byte = pdfDocument.Save()
' Send the PDF as response to browser
' Set response content type
Response.AddHeader("Content-Type", "application/pdf")
' Instruct the browser to open the PDF file as an attachment or inline
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Watermarks_and_Stamps.pdf; size={0}", outPdfBuffer.Length.ToString()))
' Write the PDF document buffer to HTTP response
Response.BinaryWrite(outPdfBuffer)
' End the HTTP response and stop the current page processing
Response.End()
Finally
' Close the PDF document
If pdfDocument IsNot Nothing Then
pdfDocument.Close()
End If
End Try
End Sub
IronPDF ofrece una herramienta de marcado de agua en PDF concisa pero robusta, lo que facilita la aplicación de marcas de agua personalizadas a tus archivos PDF sin necesidad de mucha configuración. EvoPdf, por otro lado, requiere un considerable esfuerzo para configurar la herramienta de marcas de agua, lo que la convierte en una opción menos eficiente.
IronPDF:
Sello de texto:
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create text stamper
Private textStamper As New TextStamper() With {
.Text = "Text Stamper!",
.FontFamily = "Bungee Spice",
.UseGoogleFont = True,
.FontSize = 30,
.IsBold = True,
.IsItalic = True,
.VerticalAlignment = VerticalAlignment.Top
}
' Stamp the text stamper
pdf.ApplyStamp(textStamper)
pdf.SaveAs("stampText.pdf")
Estampador de imágenes:
using IronPdf;
using IronPdf.Editing;
using System;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");
using IronPdf;
using IronPdf.Editing;
using System;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");
Imports IronPdf
Imports IronPdf.Editing
Imports System
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create image stamper
Private imageStamper As New ImageStamper(New Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg")) With {.VerticalAlignment = VerticalAlignment.Top}
' Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0)
pdf.SaveAs("stampImage.pdf")
EvoPdf: Soporte limitado para estampado de imágenes y texto, utiliza la misma herramienta que su función de marca de agua.
IronPDF proporciona métodos detallados y flexibles para añadir tanto texto como estampas de imágenes a los PDFs, sus herramientas de estampado son fáciles de usar y no requieren mucho código para implementar. EvoPdf necesita más configuración antes de poder estampar texto en sus páginas PDF.
DOCX a PDF C#
IronPDF:
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
Imports IronPdf
' Instantiate Renderer
Private renderer As New DocxToPdfRenderer()
' Render from DOCX file
Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
' Save the PDF
pdf.SaveAs("pdfFromDocx.pdf")
EvoPdf: Necesita utilizar la biblioteca de conversión Evo Work a PDF para convertir archivos DOCX al formato PDF.
IronPDF proporciona una API intuitiva para la conversión de DOCX a PDF, facilitando el manejo de diferentes tipos de documentos. Con EvoPdf, necesitarías asegurarte de tener la herramienta Evo Word to PDF instalada para realizar esta tarea.
Para obtener más información sobre el rico conjunto de características que ofrece IronPDF y verlas en acción, consulta las guías cómo hacerlo de IronPDF, que profundizan en cada característica, exploran cómo funcionan y te proporcionan las habilidades que necesitas para ser un experto en PDF.
IronPDF tiene diferentes niveles y características adicionales para la compra de una licencia. Los desarrolladores también pueden comprar Iron Suite, que les da acceso a todos los productos de Iron Software al precio de dos. Si no estás listo para comprar una licencia, IronPDF ofrece una prueba gratuita para que puedas explorar todas las funciones que tiene para ofrecer antes de comprometerte a una licencia.
Iron Suite: Por $1,498, obtienes acceso a todos los productos de Iron Software, incluyendo IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint, y IronWebScraper.
La licencia de EvoPdf se basa en dos modelos: Licencia de Despliegue y Licencia de Empresa. Ambas opciones vienen con una licencia perpetua e incluyen soporte técnico y actualizaciones de software durante el primer año.
IronPDF se enorgullece de su documentación extensa y detallada, así como de su soporte para desarrolladores.
Referencia de API de PDF: Ofrece referencias de API para que puedas aprovechar al máximo lo que nuestras herramientas tienen para ofrecer.
Para obtener más información, consulte la extensa documentación de IronPDF y visite el canal de YouTube de Iron Software.
IronPDF y EvoPdf son ambas bibliotecas PDF capaces para desarrolladores .NET. Sin embargo, el extenso conjunto de características de IronPDF, su sólida compatibilidad multiplataforma, las opciones de licencia flexibles y su excelente documentación y soporte lo convierten en una opción más atractiva para la mayoría de los proyectos de desarrollo. Con IronPDF, puedes realizar fácilmente cualquier tarea relacionada con PDF sabiendo que tienes un conjunto de características potente y rico a tu alcance.
EvoPdf es una sólida alternativa, especialmente para aquellos que buscan específicamente una herramienta enfocada en la conversión de HTML a PDF y no quieren todas las características adicionales de una biblioteca más avanzada, aunque aún tienen la opción de añadir y eliminar características al invertir en el paquete completo de herramientas.
Puedes probar la prueba gratuita de 30 días para ver las características disponibles.