产品比较

IronPDF和EvoPdf:比较

发布 2024年九月29日
分享:

IronPDF 和 EvoPdf 是用于创建、编辑和管理 PDF 文档的两个重要的 .NET 库。 每个产品都有独特的优势和功能,专为在 .NET 平台上工作的开发人员量身定制。 本文将深入比较这两个库,重点关注其功能、兼容性、许可、支持等方面。

希望在阅读完这篇文章后,您可以识别出哪些库最适合您的 PDF 需求,并能够进行比较分析,若您想要进一步研究更多的 PDF 库选项。

IronPDF和EvoPdf概述

IronPDF 是一个.NET PDF库,使开发人员能够以编程方式创建、编辑和操作PDF文档。 它以易于使用、广泛兼容.NET版本以及能够将HTML、ASPX和图像文件转换为PDF的功能而闻名,同时保持与原始内容的高度一致性。 IronPDF的详尽文档、强大的客户支持和丰富的功能集,使其成为开发人员在其.NET应用程序中集成PDF功能的首选。

EvoPdf 是另一个用于 HTML 到 PDF 转换及其他 PDF 操作任务的 .NET 库。 它为HTML标签、CSS、JavaScript以及其他现代网页技术提供高级支持,使得可以从网页内容生成高质量的PDF文档。 EvoPdf因其渲染能力和广泛支持Web标准而受到好评,使其成为专注于Web到PDF转换的开发人员的宝贵工具。

跨平台兼容性

IronPDF

IronPDF 提供广泛的跨平台兼容性,使其成为适用于各种环境的多功能工具:

  • .NET 版本:

    • 完全使用C#编写并支持C#, VB.NET,和 F#

    • .NET Core (8、7、6、5 和 3.1+)

    • .NET标准 (2.0+)
  • .NET 框架 (4.6.2+)
  • 应用环境: IronPDF 可以在各种应用环境中运行,如 Windows、Linux、Mac、Docker、Azure 和 AWS。
  • IDEs(集成开发环境): 适用于Microsoft Visual Studio和JetBrains Rider & ReSharper等IDEs。
  • 操作系统和处理器: 支持多种不同的操作系统和处理器,包括Windows、Mac、Linux、x64、x86、ARM。

    有关IronPDF兼容性的更多详细信息,请访问 IronPDF 兼容性.

EvoPdf

  • .NET 版本:

    • .NET Core (8, 7, 6, 和 5)

    • .NET Standard 2.0+
  • .NET 框架 (4.8.1、4.7.2、4.6.1 和 4.0+)
  • 应用环境:EvoPdf适用于Windows、Linux、Mac、Azure云服务和更多平台。

主要功能比较:IronPDF与EvoPdf中的PDF功能

IronPDF 和 EvoPdf 都提供强大的 PDF 操作功能,但开发人员应考虑以下明显的差异:

IronPDF

  • PDF转换:IronPDF可以从HTML内容生成PDF文档。 凭借对现代网络标准的全面支持,您可以放心,IronPDF 将始终从您的 HTML 内容中返回像素完美的 PDF。 IronPDF 还能将其他格式的文件转换为PDF,如DOCX、图片、RTF等。
  • PDF生成:使用IronPDF,您可以从URL、ASPX文件或HTML字符串生成PDF。
  • 安全功能: 使用IronPDF,您可以放心,任何敏感的PDF文件都得到了安全保护,多亏了它的安全功能。 使用 IronPDF 加密您的 PDF 文件,设置密码,并为您的 PDF 文件设置权限。
  • PDF编辑功能: 使用IronPDF,您可以处理现有的PDF文档,编辑它们,并轻松读取PDF文件。 IronPDF 提供的编辑功能包括添加页眉和页脚,将文本和图像盖章到PDF页面上,为PDF添加自定义水印,处理PDF表单,以及拆分或合并PDF文件。
  • 集成:无缝集成到 ASP.NET 和MVC应用程序。

    要获取 IronPDF 功能的完整列表,请访问 IronPDF 功能.

EvoPdf

  • HTML 到 PDF 转换器: 这是 EvoPdf 关注的主要功能,凭借对现代网络标准的高级支持,您可以将 HTML 内容转换为 PDF 格式。
  • PDF安全性: 通过利用EvoPdf的EvoPdf Chromium for .NET库,您可以创建具有安全功能和数字签名的PDF文档。
  • HTML 转换: 将网页、HTML 内容和 HTML 字符串转换为包括光栅图像和 SVG 矢量图像在内的多种文件类型,而不仅仅是 PDF。
  • PDF 操作: 使用 EvoPdf,您可以修改现有的 PDF 文档,合并它们,拆分它们,以及填写现有的 PDF 文档和其表单。

IronPDF与EvoPdf的顶级功能对比及代码示例

以下是IronPDF与EvoPdf之间主要功能的详细比较,并附有具体代码示例以展示其用法。

HTML 转换为 PDF

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")
VB   C#

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")
VB   C#

HTML 转换为 PDF 是一个常见的与PDF相关的任务,正如您在上述代码示例中所看到的,IronPDF和EvoPdf都可以轻松处理此工作。 IronPDF 通过其现代化的网络支持提供了像素完美的HTML内容渲染,因此您只需几行代码即可创建PDF文档,同时保持原始渲染质量。

加密PDF文档

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")
VB   C#

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
VB   C#

IronPDF 提供了一个全面的 API 用于管理 加密 设置,同时让您对流程和各种安全设置进行全面控制。 EvoPdf 的加密工具在过程控制方面提供了类似的水平,使其成为 PDF 加密的另一个有力竞争者。

编辑 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")
VB   C#

EvoPdf:缺乏内置文本编辑支持。

IronPDF为您提供强大的PDF功能。 编辑工具 能够在短短几行代码中从您的PDF文件中编辑指定内容。 另一方面,EvoPdf 不提供任何内置的 PDF 涂黑工具。

数字签名PDF文件

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")
VB   C#

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
VB   C#

IronPDF 提供了一个强大的 API 用于应用 数字签名 到您的PDF文件,同时保持过程简单易懂。 EvoPdf 提供基本的签名支持,但缺乏 IronPDF 提供的广泛选项,同时采用手动和更复杂的方法。

将自定义水印应用于PDF文档

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")
VB   C#

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
VB   C#

IronPDF提供简洁而强大的PDF 水印工具,使您可以轻松地将自定义水印应用于PDF文件,几乎无需设置。另一方面,EvoPdf需要投入相当多的精力来设置水印工具,使其成为一个较不简化的选项。

在 PDF 页面上盖图章和文本

IronPDF:

文本印章:

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")
VB   C#

图像戳记器:

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")
VB   C#

EvoPdf:对图像和文本标记的支持有限,使用与其水印功能相同的工具。

IronPDF提供详细且灵活的方法,用于将文本和图像印章添加到PDF中,其 冲压工具 易于使用,且实现所需代码不多。 在将文本添加到PDF页面之前,EvoPdf需要更多的设置。

DOCX转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")
VB   C#

EvoPdf:你需要使用Evo Work to PDF转换库来将DOCX文件转换为PDF格式。

IronPDF提供直观的API用于 DOCX 转换为 PDF,使处理不同的文档类型更容易。使用EvoPdf时,您需要确保安装了Evo Word to PDF工具才能执行此任务。

代码示例比较摘要

要了解 IronPDF 提供的丰富功能集并查看其实际应用,请查看 IronPDF。 如何操作 指南深入探讨每个功能,探索其工作原理,并为您提供成为PDF专家所需的技能。

定价和授权:IronPDF vs. EvoPdf Library

IronPDF

IronPDF 拥有不同级别和购买许可证的附加功能。 开发者还可以购买 IronSuite 此许可使您可以以两个产品的价格访问所有Iron Software的产品。 如果您还没有准备好购买许可证,IronPDF提供一个 免费试用 这样您就可以在购买许可证之前探索其提供的所有功能。

  • 永久许可证: 根据您团队的规模、项目需求和地点数量提供一系列永久许可证。 每种许可类型都包括电子邮件支持。
  • Lite License:此许可证价格为749美元,支持一个开发者、一个地点和一个项目。
  • Plus License(加强许可): 支持三名开发者、三个地点和三个项目,这是从轻量版许可升级的下一步,费用为$1,499。Plus许可还提供聊天支持和电话支持,除了基本的电子邮件支持。
  • 专业许可证: 此许可证适用于较大的团队,支持10名开发者、10个位置和10个项目,价格为2999美元。它提供与之前等级相同的联系支持渠道,但也提供屏幕共享支持。
  • 免版税重新分发: IronPDF 的许可还提供额外 $1,999 的免版税重新分发覆盖。
  • 持续不断的产品支持: IronPDF为用户提供持续的产品更新、安全功能升级以及他们工程团队的支持,费用为每年999美元或一次性支付1999美元,享受5年的服务。
  • IronSuite:您可以通过支付1,498美元获得所有Iron Software产品的访问权限,包括 IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrintIronWebScraper.

EvoPdf

EvoPdf 的许可基于两种模式:部署许可和公司许可。 两种选项均为永久许可,并在第一年提供技术支持和软件更新。

  • EVO PDF 工具包: 这款产品包含所有相关工具,例如:HTML 转 PDF 转换器、EvoPdf Chromium、Word 转 PDF 转换器、Excel 转 PDF 转换器等。 此许可证的部署版本费用为650美元,公司版本费用为1400美元。
  • EVO HTML到PDF转换器适用于所有平台: 这只是单个产品,如果你只需要HTML到PDF工具,可以单独购买,而无需购买EVO PDF Toolkit捆绑包。 部署版本费用为450美元,公司版本费用为1200美元。

文档和支持:IronPDF与EvoPdf比较

IronPDF

IronPDF以其全面、详细的文档和开发者支持而自豪。

  • 全面的文档:涵盖所有功能的广泛且用户友好的文档。
  • 24/5 支持:提供活跃的工程师支持。
  • 视频教程:详细的视频指南可在YouTube上找到。
  • 社区论坛:为了提供额外支持而设立的活跃社区。
  • 定期更新:每月产品更新,确保具备最新功能和安全补丁。
  • PDF API 参考: 提供 API 参考,让您充分利用我们的工具所提供的功能。

    documentation on our website. 文献资料,并访问 IronSoftware YouTube频道.

EvoPdf

  • 文档: EvoPdf 提供其功能的文档,不过如果您不熟悉该网站,可能会觉得难以导航。
  • 在线演示: 在 EVO PDF 软件网站上,您可以通过其在线演示部分测试该库提供的所有功能。
  • 技术支持: 您可以通过网站上提供的电子邮件和电话详细信息与团队联系以获得技术和非技术支持。

结论

IronPDF 和EvoPdf都是为.NET开发人员提供的强大PDF库。 然而,IronPDF 广泛的功能集、强大的跨平台兼容性、灵活的许可选项以及出色的文档和支持,使其成为大多数开发项目更具吸引力的选择。 使用 IronPDF,您可以轻松执行任何与 PDF 相关的任务,并且拥有强大且丰富的功能集在手边。

EvoPdf 是一个不错的替代方案,特别适合那些专注于寻找 HTML 到 PDF 转换工具的人,并且不需要更高级库的多余功能,同时仍然可以通过投资完整的工具包来添加和删除功能。

< 前一页
IronPDF与SelectPDF的对比
下一步 >
iTextSharp C# HTML 转换为 PDF 的 .NET Core 替代方案

准备开始了吗? 版本: 2024.9 刚刚发布

免费NuGet下载 总下载量: 10,840,061 查看许可证 >