产品比较

IronPDF与SelectPDF的对比

介绍

在处理 PDF 文档时,选择适合自己需要的工具是重要的第一步。您是否只是想将 HTML 内容转换为 PDF 文档? 或者您的 PDF 项目需要更复杂的工具,如加密和应用数字签名? 今天,我们将介绍 IronPDF 和 SelectPdf 这两个 PDF 库,并研究如何使用这些库来提升您的 PDF 工作空间。

IronPDF 和 SelectPdf 概述

了解更多关于IronPDF的信息 旨在成为.NET生态系统中所有PDF相关任务的一站式解决方案。 它支持 HTML、CSS、JavaScript 以及多种图像格式,因此对基于网络的应用程序具有极强的适应性。 IronPDF 具有生成 PDF、编辑 PDF 或签名和加密等多种功能,是一款值得添加到您的工具库中的好工具。

SelectPdf 为 .NET 应用程序提供了灵活的 HTML 到 PDF 转换器,可在 .NET Framework 和 .NET Core 平台上运行。 它提供了创建 PDF 文件和处理现有 PDF 文档的丰富功能,因此适用于各种业务和个人场景。

跨平台兼容性

IronPDF:

IronPDF支持多种平台,确保您可以在首选环境中工作。 以下是其兼容性的分解:

  • .NET 版本:

    • (C#, VB.NET, F#)

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

    • .NET Standard (2.0+)
  • .NET Framework (4.6.2+)
  • 应用环境:IronPDF 可在包括 Windows、Linux、Mac、Docker、Azure 和 AWS 在内的环境中运行。
  • IDEs:兼容的IDE包括Microsoft Visual Studio和JetBrains Rider & ReSharper
  • 操作系统和处理器:支持多种不同的操作系统和处理器,包括 Windows、Mac、Linux、x64、x86、ARM

    欲了解更多信息,请访问IronPDF兼容性详情

选择 PDF

  • .NET 版本:

    • .NET Framework 4.0+

    • .NET Core 2.1+
  • .NET Standard 2.0
  • 应用环境:SelectPdf 仅适用于 Windows 操作系统,不适用于 Azure 等基于云的环境。

关键功能比较:IronPDF 与 SelectPdf 的 PDF 功能

IronPDF

  • HTML 转换为 PDF: IronPDF 可以处理 HTML 转换为 PDF,借助其对现代 Web 标准的全面支持,您可以放心地期待 IronPDF 能够始终如一地从您的 HTML 内容中返回像素完美的 PDF。
  • PDF文件转换:需要将HTML以外的文件格式转换为PDF吗? 使用 IronPDF 将 DOCX 转换为 PDF、将 RTF 转换为 PDF、将图片转换为 PDF、将 URL 转换为 PDF,甚至将 PDF 转换为 HTML,同时保持所需的文档结构。
  • 安全功能:使用IronPDF,您可以始终放心,任何敏感的PDF文件都将因为其安全功能而得到保护。 使用 IronPdf 为您的 PDF 文件设置 PDF 安全设置、设置密码和设置权限。
  • PDF编辑功能:使用IronPDF,您可以轻松编辑现有文档。 IronPDF 提供的编辑功能包括添加页眉和页脚、在 PDF 页面上印制文本和图像、合并和拆分 PDF 文档、在 PDF 上添加自定义水印以及处理 PDF 表单。

    有关IronPDF提供的功能的详细信息,请访问Advanced IronPDF Features

选择 PDF

  • PDF生成: 从头开始生成PDF文档,或从HTML内容生成PDF,例如原始HTML字符串、网页等。
  • 操作PDF文件:添加、合并和拆分PDF页面,从现有PDF文件中提取页面。
  • PDF 设置: 设置 PDF 页面设置,例如设置页面方向、大小和边距。 设置 PDF 查看器首选项和 PDF 文档属性。
  • PDF安全性:设置您的PDF文档安全设置,使用密码加密您的PDF文件,并编辑您的PDF文件的权限。

    IronPDF 与 SelectPdf 的顶级亮点功能比较及代码示例

<table>
  <thead>
    <tr>
      <th>功能</th>
      <th>IronPDF 代码示例</th>
      <th>SelectPdf 代码示例</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Pdf 转换</td>
      <td>
        <pre><code class="language-csharp">
            var Renderer = new IronPdf.ChromePdfRenderer();
            var PDFDocument = Renderer.RenderHtmlAsPdf("&lt;h1&gt;Hello, World!&lt;/h1&gt;");
            PDFDocument.SaveAs("HtmlToPdf.pdf");
        </code></pre>
      </td>
      <td>
        <pre><code class="language-csharp">
            var converter = new HtmlToPdf();
            var doc = converter.ConvertHtmlString("&lt;h1&gt;Hello, World!&lt;/h1&gt;");
            doc.Save("HtmlToPdf.pdf");
        </code></pre>
      </td>
    </tr>
    <tr>
      <td>添加水印</td>
      <td>
        <pre><code class="language-csharp">
            var PDFDocument = PdfDocument.FromFile("example.pdf");
            var StampedPdf = PDFDocument.StampPDF("Confidential", PageNumbering.Normal, FontSize: 50, opacity: 50);
            StampedPdf.SaveAs("Watermarked.pdf");
        </code></pre>
      </td>
      <td>
        <pre><code class="language-csharp">
            var doc = new PdfDocument();
            var watermark = new PdfTextSection(10, 10, "Confidential", new Font("Arial", 50));
            watermark.Opacity = 0.5;
            doc.Add(watermark);
            doc.Save("Watermarked.pdf");
        </code></pre>
      </td>
    </tr>
  </tbody>
</table>
<table>
  <thead>
    <tr>
      <th>功能</th>
      <th>IronPDF 代码示例</th>
      <th>SelectPdf 代码示例</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Pdf 转换</td>
      <td>
        <pre><code class="language-csharp">
            var Renderer = new IronPdf.ChromePdfRenderer();
            var PDFDocument = Renderer.RenderHtmlAsPdf("&lt;h1&gt;Hello, World!&lt;/h1&gt;");
            PDFDocument.SaveAs("HtmlToPdf.pdf");
        </code></pre>
      </td>
      <td>
        <pre><code class="language-csharp">
            var converter = new HtmlToPdf();
            var doc = converter.ConvertHtmlString("&lt;h1&gt;Hello, World!&lt;/h1&gt;");
            doc.Save("HtmlToPdf.pdf");
        </code></pre>
      </td>
    </tr>
    <tr>
      <td>添加水印</td>
      <td>
        <pre><code class="language-csharp">
            var PDFDocument = PdfDocument.FromFile("example.pdf");
            var StampedPdf = PDFDocument.StampPDF("Confidential", PageNumbering.Normal, FontSize: 50, opacity: 50);
            StampedPdf.SaveAs("Watermarked.pdf");
        </code></pre>
      </td>
      <td>
        <pre><code class="language-csharp">
            var doc = new PdfDocument();
            var watermark = new PdfTextSection(10, 10, "Confidential", new Font("Arial", 50));
            watermark.Opacity = 0.5;
            doc.Add(watermark);
            doc.Save("Watermarked.pdf");
        </code></pre>
      </td>
    </tr>
  </tbody>
</table>
HTML

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("&lt;h1&gt;Hello World&lt;/h1&gt;");

// Export to a file or Stream
pdf.SaveAs("output.pdf");

// Advanced Example with HTML Assets
// Load external html assets: images, CSS and JavaScript.
// An optional BasePath 'c:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("&lt;img src='icons/iron.png'&gt;", @"c:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.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("&lt;h1&gt;Hello World&lt;/h1&gt;");

// Export to a file or Stream
pdf.SaveAs("output.pdf");

// Advanced Example with HTML Assets
// Load external html assets: images, CSS and JavaScript.
// An optional BasePath 'c:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("&lt;img src='icons/iron.png'&gt;", @"c:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

SelectPdf:

// instantiate an HTML to PDF converter object
HtmlToPdf converter = new HtmlToPdf();

// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl(url);

// save pdf document
doc.Save(file);

// close pdf document
doc.Close();
// instantiate an HTML to PDF converter object
HtmlToPdf converter = new HtmlToPdf();

// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl(url);

// save pdf document
doc.Save(file);

// close pdf document
doc.Close();
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

无论您是想将多个网页转换为同一个PDF文档,还是转换单个HTML字符串,IronPDF都可以通过使用ChromePdfRenderer以及对现代 web 标准的支持,提供高保真度的PDF文件。 使用IronPDF,您只需几行代码即可将HTML转化为高保真PDF。 SelectPdf 的 HTML 到 PDF 转换工具简洁明了、实施快捷,但可能无法产生同样高质量的输出。

如果您想了解更多关于IronPDF的HTML转PDF转换工具,请查看我们方便的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
// The following code makes a PDF read only and will disallow copy &amp; paste and printing
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
// The following code makes a PDF read only and will disallow copy &amp; paste and printing
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
' The following code makes a PDF read only and will disallow copy &amp; paste and printing
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")
$vbLabelText   $csharpLabel

SelectPdf:

// set document passwords
doc.Security.OwnerPassword = "test1";
doc.Security.UserPassword = "test2";

//set document permissions
doc.Security.CanAssembleDocument = false;
doc.Security.CanCopyContent = true;
doc.Security.CanEditAnnotations = true;
doc.Security.CanEditContent = true;
doc.Security.CanFillFormFields = true;
doc.Security.CanPrint = true;
// set document passwords
doc.Security.OwnerPassword = "test1";
doc.Security.UserPassword = "test2";

//set document permissions
doc.Security.CanAssembleDocument = false;
doc.Security.CanCopyContent = true;
doc.Security.CanEditAnnotations = true;
doc.Security.CanEditContent = true;
doc.Security.CanFillFormFields = true;
doc.Security.CanPrint = true;
' set document passwords
doc.Security.OwnerPassword = "test1"
doc.Security.UserPassword = "test2"

'set document permissions
doc.Security.CanAssembleDocument = False
doc.Security.CanCopyContent = True
doc.Security.CanEditAnnotations = True
doc.Security.CanEditContent = True
doc.Security.CanFillFormFields = True
doc.Security.CanPrint = True
$vbLabelText   $csharpLabel

当您希望高效加密您的PDF时,IronPDF和SelectPdf都提供内置加密工具。 IronPDF 的加密功能非常广泛,可以让您对各种安全设置进行大量控制,同时使用起来仍然简单明了。 SelectPdf 的加密功能简洁明了,易于在您的项目中实施。

有关向您的 PDF 文件添加密码和权限的更多信息,请访问 IronPDF 的有用添加密码和权限指南

编辑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")
$vbLabelText   $csharpLabel

SelectPdf:

SelectPdf 不支持直接编辑。

IronPDF 提供了一个简洁而强大的 PDF 净化工具,只需几行代码即可净化指定内容。 另一方面,SelectPdf 缺乏任何内置的编辑功能。

数字签名PDF文件

IronPDF:

using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("&lt;h1&gt;foo&lt;/h1&gt;");

// 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("&lt;h1&gt;foo&lt;/h1&gt;");

// 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("&lt;h1&gt;foo&lt;/h1&gt;")

' 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")
$vbLabelText   $csharpLabel

SelectPdf:

// create a new pdf document
PdfDocument doc = new PdfDocument();

// add a new page to the document
PdfPage page = doc.AddPage();

// get image path 
// the image will be used to display the digital signature over it
string imgFile = Server.MapPath("~/files/logo.png");

// get certificate path
string certFile = Server.MapPath("~/files/selectpdf.pfx");

// define a rendering result object
PdfRenderingResult result;

// create image element from file path 
PdfImageElement img = new PdfImageElement(0, 0, imgFile);
result = page.Add(img);

// get the #PKCS12 certificate from file
PdfDigitalCertificatesCollection certificates =
    PdfDigitalCertificatesStore.GetCertificates(certFile, "selectpdf");
PdfDigitalCertificate certificate = certificates[0];

// create the digital signature object
PdfDigitalSignatureElement signature =
    new PdfDigitalSignatureElement(result.PdfPageLastRectangle, certificate);
signature.Reason = "SelectPdf";
signature.ContactInfo = "SelectPdf";
signature.Location = "SelectPdf";
page.Add(signature);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
// create a new pdf document
PdfDocument doc = new PdfDocument();

// add a new page to the document
PdfPage page = doc.AddPage();

// get image path 
// the image will be used to display the digital signature over it
string imgFile = Server.MapPath("~/files/logo.png");

// get certificate path
string certFile = Server.MapPath("~/files/selectpdf.pfx");

// define a rendering result object
PdfRenderingResult result;

// create image element from file path 
PdfImageElement img = new PdfImageElement(0, 0, imgFile);
result = page.Add(img);

// get the #PKCS12 certificate from file
PdfDigitalCertificatesCollection certificates =
    PdfDigitalCertificatesStore.GetCertificates(certFile, "selectpdf");
PdfDigitalCertificate certificate = certificates[0];

// create the digital signature object
PdfDigitalSignatureElement signature =
    new PdfDigitalSignatureElement(result.PdfPageLastRectangle, certificate);
signature.Reason = "SelectPdf";
signature.ContactInfo = "SelectPdf";
signature.Location = "SelectPdf";
page.Add(signature);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
' create a new pdf document
Dim doc As New PdfDocument()

' add a new page to the document
Dim page As PdfPage = doc.AddPage()

' get image path 
' the image will be used to display the digital signature over it
Dim imgFile As String = Server.MapPath("~/files/logo.png")

' get certificate path
Dim certFile As String = Server.MapPath("~/files/selectpdf.pfx")

' define a rendering result object
Dim result As PdfRenderingResult

' create image element from file path 
Dim img As New PdfImageElement(0, 0, imgFile)
result = page.Add(img)

' get the #PKCS12 certificate from file
Dim certificates As PdfDigitalCertificatesCollection = PdfDigitalCertificatesStore.GetCertificates(certFile, "selectpdf")
Dim certificate As PdfDigitalCertificate = certificates(0)

' create the digital signature object
Dim signature As New PdfDigitalSignatureElement(result.PdfPageLastRectangle, certificate)
signature.Reason = "SelectPdf"
signature.ContactInfo = "SelectPdf"
signature.Location = "SelectPdf"
page.Add(signature)

' save pdf document
doc.Save(Response, False, "Sample.pdf")

' close pdf document
doc.Close()
$vbLabelText   $csharpLabel

使用IronPDF,轻松应用数字签名到PDF文件中,这款简单而强大的PDF签名工具让这一过程变得轻而易举。 SelectPdf 还可以对 PDF 应用数字签名,不过这需要更多的设置和更多的手动操作。

如果您想查看更多关于IronPDF数字签名工具的实际应用,请访问其数字签名工具指南

应用自定义水印

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("&lt;h2 style='color:red'&gt;SAMPLE&lt;/h2&gt;", 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("&lt;h2 style='color:red'&gt;SAMPLE&lt;/h2&gt;", 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("&lt;h2 style='color:red'&gt;SAMPLE&lt;/h2&gt;", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)

pdf.SaveAs("C:\Path\To\Watermarked.pdf")
$vbLabelText   $csharpLabel

SelectPdf:

// create a new pdf document
PdfDocument doc = new PdfDocument();

// create a new pdf font
PdfFont font = doc.AddFont(PdfStandardFont.Helvetica);
font.Size = 24;

// add a new page to the document
PdfPage page = doc.AddPage();

// create a new text element and add it to the page
PdfTextElement text = new PdfTextElement(0, 0, Helper.SomeLongText(), font);
page.Add(text);

// get image path
string imgFile = Server.MapPath("~/files/logo.png");

// watermark all pages - add a template containing an image 
// to the bottom right of the page
// the image should repeat on all pdf pages automatically
// the template should be rendered behind the rest of the page elements
PdfTemplate template = doc.AddTemplate(doc.Pages[0].ClientRectangle);
PdfImageElement img = new PdfImageElement(
    doc.Pages[0].ClientRectangle.Width - 300,
    doc.Pages[0].ClientRectangle.Height - 150, imgFile);
img.Transparency = 50;
template.Background = true;
template.Add(img);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
// create a new pdf document
PdfDocument doc = new PdfDocument();

// create a new pdf font
PdfFont font = doc.AddFont(PdfStandardFont.Helvetica);
font.Size = 24;

// add a new page to the document
PdfPage page = doc.AddPage();

// create a new text element and add it to the page
PdfTextElement text = new PdfTextElement(0, 0, Helper.SomeLongText(), font);
page.Add(text);

// get image path
string imgFile = Server.MapPath("~/files/logo.png");

// watermark all pages - add a template containing an image 
// to the bottom right of the page
// the image should repeat on all pdf pages automatically
// the template should be rendered behind the rest of the page elements
PdfTemplate template = doc.AddTemplate(doc.Pages[0].ClientRectangle);
PdfImageElement img = new PdfImageElement(
    doc.Pages[0].ClientRectangle.Width - 300,
    doc.Pages[0].ClientRectangle.Height - 150, imgFile);
img.Transparency = 50;
template.Background = true;
template.Add(img);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
' create a new pdf document
Dim doc As New PdfDocument()

' create a new pdf font
Dim font As PdfFont = doc.AddFont(PdfStandardFont.Helvetica)
font.Size = 24

' add a new page to the document
Dim page As PdfPage = doc.AddPage()

' create a new text element and add it to the page
Dim text As New PdfTextElement(0, 0, Helper.SomeLongText(), font)
page.Add(text)

' get image path
Dim imgFile As String = Server.MapPath("~/files/logo.png")

' watermark all pages - add a template containing an image 
' to the bottom right of the page
' the image should repeat on all pdf pages automatically
' the template should be rendered behind the rest of the page elements
Dim template As PdfTemplate = doc.AddTemplate(doc.Pages(0).ClientRectangle)
Dim img As New PdfImageElement(doc.Pages(0).ClientRectangle.Width - 300, doc.Pages(0).ClientRectangle.Height - 150, imgFile)
img.Transparency = 50
template.Background = True
template.Add(img)

' save pdf document
doc.Save(Response, False, "Sample.pdf")

' close pdf document
doc.Close()
$vbLabelText   $csharpLabel

IronPDF 内置的水印工具利用 HTML 和 CSS 提供了一种易于将水印应用于 PDF 页面的方式,同时让您完全控制整个过程,而只需使用几行代码。 SelectPdf 也有一个 PDF 水印工具,您可以用它为 PDF 添加自定义水印,但是这个过程比较长,而且可能不那么容易实现。

在PDF上加盖图像和文字

IronPDF:

using IronPdf;
using IronPdf.Editing;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("&lt;h1&gt;Example HTML Document!&lt;/h1&gt;");

// 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");

// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("/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;

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("&lt;h1&gt;Example HTML Document!&lt;/h1&gt;");

// 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");

// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("/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

Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("&lt;h1&gt;Example HTML Document!&lt;/h1&gt;")

' 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")

' Create image stamper
Dim imageStamper As New ImageStamper(New Uri("/img/svgs/iron-pdf-logo.svg")) With {.VerticalAlignment = VerticalAlignment.Top}

' Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0)
pdf.SaveAs("stampImage.pdf")
$vbLabelText   $csharpLabel

SelectPdf:

// create a new pdf document
PdfDocument doc = new PdfDocument();

// create a new pdf font
PdfFont font = doc.AddFont(PdfStandardFont.Helvetica);
font.Size = 24;

// add a new page to the document
PdfPage page = doc.AddPage();

// create a new text element and add it to the page
PdfTextElement text = new PdfTextElement(0, 0, Helper.SomeLongText(), font);
page.Add(text);

// get image path
string imgFile = Server.MapPath("~/files/logo.png");

// stamp all pages - add a template containing an image to the bottom right of 
// the page the image should repeat on all pdf pages automatically
PdfTemplate template = doc.AddTemplate(doc.Pages[0].ClientRectangle);
PdfImageElement img = new PdfImageElement(
    doc.Pages[0].ClientRectangle.Width - 300,
    doc.Pages[0].ClientRectangle.Height - 150, imgFile);
template.Add(img);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
// create a new pdf document
PdfDocument doc = new PdfDocument();

// create a new pdf font
PdfFont font = doc.AddFont(PdfStandardFont.Helvetica);
font.Size = 24;

// add a new page to the document
PdfPage page = doc.AddPage();

// create a new text element and add it to the page
PdfTextElement text = new PdfTextElement(0, 0, Helper.SomeLongText(), font);
page.Add(text);

// get image path
string imgFile = Server.MapPath("~/files/logo.png");

// stamp all pages - add a template containing an image to the bottom right of 
// the page the image should repeat on all pdf pages automatically
PdfTemplate template = doc.AddTemplate(doc.Pages[0].ClientRectangle);
PdfImageElement img = new PdfImageElement(
    doc.Pages[0].ClientRectangle.Width - 300,
    doc.Pages[0].ClientRectangle.Height - 150, imgFile);
template.Add(img);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
doc.Close();
' create a new pdf document
Dim doc As New PdfDocument()

' create a new pdf font
Dim font As PdfFont = doc.AddFont(PdfStandardFont.Helvetica)
font.Size = 24

' add a new page to the document
Dim page As PdfPage = doc.AddPage()

' create a new text element and add it to the page
Dim text As New PdfTextElement(0, 0, Helper.SomeLongText(), font)
page.Add(text)

' get image path
Dim imgFile As String = Server.MapPath("~/files/logo.png")

' stamp all pages - add a template containing an image to the bottom right of 
' the page the image should repeat on all pdf pages automatically
Dim template As PdfTemplate = doc.AddTemplate(doc.Pages(0).ClientRectangle)
Dim img As New PdfImageElement(doc.Pages(0).ClientRectangle.Width - 300, doc.Pages(0).ClientRectangle.Height - 150, imgFile)
template.Add(img)

' save pdf document
doc.Save(Response, False, "Sample.pdf")

' close pdf document
doc.Close()
$vbLabelText   $csharpLabel

IronPDF 提供强大的工具,用于将文本和图像加盖到 PDF 文档上。 应用文本或图像标记的方法类似 HTML 和 CSS,这意味着您可以完全控制标记过程。 SelectPdf 的方法时间较长,过程中涉及较多的手工工作。

如果您想了解有关IronPDF标记工具的更多信息,请务必查看其实用的标记文本和图像指南

DOCX 转 PDF 转换

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")
$vbLabelText   $csharpLabel

SelectPdf:

SelectPdf 不支持 DOCX 到 PDF 的直接转换。

IronPDF支持将DOCX文件直接转换为PDF。 有了这项功能,您只需几行字就能将 DOCX 转换为 PDF,而且不会损失文件的任何质量。 然而,SelectPdf 并不提供 DOCX 到 PDF 的内置支持。

有关IronPDF的DOCX转PDF转换功能的更多信息,请务必查看DOCX转PDF转换指南

功能对比摘要

IronPDF与SelectPDF的比较:图1

有关详细的代码示例,请访问IronPDF 示例页面

定价和许可:IronPDF vs. SelectPdf

IronPDF 定价和许可

IronPDF 许可和定价具有不同的级别和附加功能以购买许可证。 开发人员也可以购买Iron Suite,它以两个产品的价格为您提供使用所有 Iron Software 产品的权限。 如果您尚未准备好购买许可证,IronPDF 提供了一个 为期30天的免费试用选项

  • 永久许可证:提供多种永久许可证,具体取决于您的团队规模、项目需求和地点数量。 每种许可类型都包括电子邮件支持。
  • Lite license:此许可证费用为$749,支持一位开发者、一个地点和一个项目。
  • Plus license:支持三名开发人员、三个地点和三个项目,这是比Lite License更高的步伐,费用为$1,499。Plus License除了基本的电子邮件支持外,还提供聊天支持和电话支持。
  • 专业许可:此许可适用于较大的团队,支持十名开发人员、十个地点和十个项目,价格为$2,999。它提供与之前等级相同的联系支持渠道,但还提供屏幕共享支持。
  • 免版税重新分发:IronPDF 的许可还提供免版税重新分发保障,额外费用为 $1,999
  • 不中断的产品支持:IronPDF 提供持续产品更新、安全功能升级及其工程团队的支持,费用为 $999/年或一次性购买 $1,999,涵盖5年的支持。
  • Iron Suite:价格为 $1,498,您可以访问所有 Iron Software 产品,包括 IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint 和 IronWebScraper。

    IronPDF与SelectPDF的比较:图2

选择 PDF

SelectPdf 提供一系列永久许可级别,均包含一年维护计划。

  • 单个开发人员许可: $499,支持一个开发人员和一台部署机器
  • 单个开发人员OEM许可证: $799,支持一名开发人员和无限制部署机器
  • 5-开发者许可: $799,支持最多5位开发者和最多10台部署机器
  • 5-开发者 OEM 许可证: $1,099,支持多达五名开发人员和无限部署机器
  • 企业许可证: $1,199,支持无限开发者和最多一百台部署机器
  • 企业OEM许可证: $1,599,支持无限开发人员和无限部署机器

文档与支持:IronPDF vs. SelectPdf

IronPDF

IronPDF在提供广泛文档和支持方面表现出色:

  • 全面文档:广泛且用户友好的文档涵盖所有功能。
  • 24/5 支持:提供活跃的工程师支持。
  • 视频教程:YouTube上提供了逐步视频指南。
  • 社区论坛:活跃社区以提供额外支持。
  • 定期更新:每月产品更新,以确保最新功能和安全补丁。

    欲了解更多信息,请查看IronPDF的详细文档库,并访问IronSoftware YouTube频道

SelectPdf 文档和支持

  • 详细文档:涵盖SelectPdf提供的所有功能方面,并附有代码示例。
  • 电子邮件支持:可用于技术和许可查询。
  • 专业服务:针对复杂实施的付费支持,例如他们的一年维护计划

结论

在处理 PDF 时,拥有满足 PDF 项目需求的合适 PDF 库至关重要。 今天,我们看到了 IronPdf 和 SelectPdf 的实际应用,并对这两个库进行了仔细了解。 SelectPdf 为处理 PDF 提供了一系列可靠的功能,但其中很多功能的实现可能要比 IronPDF 的对应功能花费更多的精力。

对于需要强大 PDF 功能的 .NET 开发人员来说,IronPDF 是一个多功能的综合解决方案。 其丰富的功能、与现代 .NET Framework 的兼容性以及出色的支持使其成为开发人员工具包中的强大工具。

您可以尝试30天免费试用以查看他们提供的功能。

Chipego
软件工程师
Chipego 拥有出色的倾听技巧,这帮助他理解客户问题并提供智能解决方案。他在 2023 年加入 Iron Software 团队,此前他获得了信息技术学士学位。IronPDF 和 IronOCR 是 Chipego 主要专注的两个产品,但他对所有产品的了解每天都在增长,因为他不断找到支持客户的新方法。他喜欢 Iron Software 的合作氛围,公司各地的团队成员贡献他们丰富的经验,以提供有效的创新解决方案。当 Chipego 离开办公桌时,你经常可以发现他在看书或踢足球。
< 前一页
IronPDF 和 Devexpress PDF Viewer 的比较
下一步 >
IronPDF和EvoPdf:比较