产品比较

IronPDF与SelectPDF的对比

更新 2024年八月28日
分享:

介绍

当您处理PDF文档时,选择适合您需求的工具是重要的第一步。您是希望仅将HTML内容转换为PDF文档吗?还是您的PDF项目需要更复杂的工具,例如加密和应用数字签名?今天,我们将探讨两个PDF库,IronPDF和SelectPdf,并检查这些库如何提升您的PDF工作区。

IronPDF和SelectPdf概述

IronPDF 旨在成为 .NET 生态系统中所有与 PDF 相关任务的一站式解决方案。它支持 HTML、CSS、JavaScript 以及多种图像格式,因此对于基于 Web 的应用程序极具适应性。凭借生成 PDF、编辑 PDF 以及签署和加密等多种功能,IronPDF 是您工具库中的一个绝佳工具。

SelectPdf 提供一个灵活的 HTML 转 PDF 转换器,适用于 .NET 应用程序,并且可以在 .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的环境中运行
  • IDE: 适用于Microsoft Visual Studio和JetBrains Rider & ReSharper等IDE
  • 操作系统和处理器: 支持多种不同的操作系统和处理器,包括Windows、Mac、Linux、x64、x86、ARM

更多信息,请访问 IronPDF兼容性.

SelectPdf

  • .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 文件转换: 需要将其他文件格式转换为 PDF 吗?使用 IronPDF,将 DOCX 转换为 PDF,RTF 转换为 PDF,图像转换为 PDF,URL 转换为 PDF,甚至将 PDF 转换为 HTML,同时保持所需的文档结构。
  • 安全功能: 通过 IronPDF 您可以随时确保任何敏感的 PDF 文件是安全的,得益于它的安全功能。使用 IronPDF 为您的 PDF 设置安全设置,设置密码,并为您的 PDF 文件设置权限。
  • PDF 编辑功能: 使用 IronPDF,您可以轻松编辑现有文档。IronPDF 提供编辑功能,例如添加页眉和页脚,将文本和图像印章到 PDF 页面上,合并和拆分 PDF 文档,添加自定义水印到 PDF,以及处理 PDF 表单。

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

SelectPdf

  • PDF生成: 从头生成PDF文档,或从HTML内容(例如原始HTML字符串、网页等)生成PDF。
  • 操作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
VB   C#

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

无论您是想将多个网页转换为同一个PDF文档还是单个HTML字符串,IronPDF都能提供高保真PDF文件,这得益于其使用ChromePdfRenderer并支持现代web标准。使用IronPDF,您可以转换 HTML 转 PDF 使用仅几行代码。SelectPdf 的 HTML 转 PDF 转换工具简洁明了,且实现迅速,但可能不会产生同样高质量的输出。pdf。convert

如果您想了解更多关于 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
// 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");
<br>
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");
<br>
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")
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'<br>
VB   C#

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

当您在寻找 加密 对于你的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")
VB   C#

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

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

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

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

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");
<br>
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");
<br>
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")
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'<br>
VB   C#

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

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");
<br>
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");
<br>
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")
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'<br>
VB   C#

SelectPdf:

SelectPdf不支持直接将DOCX转换为PDF。

IronPDF支持直接转换 DOCX 文件转 PDF. 使用此功能,您只需几行代码即可将 DOCX 转换为 PDF,而不会丢失任何文件的质量。然而,SelectPdf 不提供内置的 DOCX 到 PDF 的支持。

有关 IronPDF 的 DOCX 到 PDF 转换功能的更多信息,请务必查看 如何 本主题指南。

功能比较摘要

IronPDF与SelectPDF的比较:图1

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

定价和许可:IronPDF vs. SelectPdf

IronPDF 定价和许可

IronPDF 有不同等级和额外功能的许可证供购买。开发者还可以购买 Iron Suite 这将让您以两个产品的价格获取所有IronSoftware的产品。如果您还没准备好购买许可证,IronPDF提供一个 免费试用 持续30天。

  • 永久许可证:根据您的团队规模、项目需求和地点数量提供各种永久许可证。每种许可证类型都配有电子邮件支持。
  • Lite许可证:此许可证费用为$749,支持一位开发者、一个地点和一个项目。
  • Plus许可证:此许可证比Lite许可证更进一步,支持三位开发者、三各地点和三个项目,费用为$1,499。Plus许可证除了基本的电子邮件支持外,还提供聊天支持和电话支持。
  • Professional许可证:此许可证适合较大的团队,支持十位开发者、十个地点和十个项目,费用为$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

SelectPdf

SelectPdf 提供多种永久许可级别,所有级别都包含为期一年的维护计划。

  • 单一开发者许可: $499,支持一个开发者和一台部署机器
  • 单一开发者 OEM 许可: $799,支持一个开发者和无限的部署机器
  • 5-开发者许可: $799,支持最多五个开发者和最多十台部署机器
  • 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更为复杂。

IronPDF作为.NET开发人员需要强大PDF功能的一个多用途且全面的解决方案脱颖而出。其广泛的功能、与现代.NET框架的兼容性以及优秀的支持使其成为开发者工具包中的一款强大工具。

< 前一页
IronPDF 和 Devexpress PDF Viewer 的比较
下一步 >
IronPDF与EVOPDF的比较

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

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