在實際環境中測試
在生產環境中測試無浮水印。
在任何需要的地方都能運作。
在處理 PDF 文件時,選擇符合您需求的合適工具是重要的第一步。您是否僅僅是想將 HTML 內容轉換為 PDF 文件? 或者您的 PDF 專案是否需要更複雜的工具,例如加密和套用數位簽章? 今天,我們將探討兩個 PDF 庫,IronPDF 和 SelectPdf,並研究如何使用這些庫來提升您的 PDF 工作環境。
了解更多關於 IronPDF被設計為 .NET 生態系統中所有 PDF 相關任務的一站式解決方案。 它支持 HTML、CSS、JavaScript 以及多种图像格式,因此对于基于网络的应用程序极为适应。 IronPDF 提供多種功能,如生成 PDF、編輯、簽名和加密,是添加到您的工具庫中的一個極佳工具。
SelectPdf 為 .NET 應用程式提供一個靈活的 HTML 到 PDF 轉換器,可在 .NET Framework 和 .NET Core 平台上運行。 它提供了豐富的功能來創建 PDF 文件和操作現有的 PDF 文檔,使其適用於各種商業和個人情境。
IronPDF 支援多種平台,確保您可以在您偏好的環境中工作。 以下是其兼容性分析:
(C#, VB.NET, F#)
作業系統和處理器: 支援多種不同的作業系統和處理器,包括 Windows、Mac、Linux、x64、x86、ARM
欲了解更多資訊,請造訪IronPDF 相容性詳細資訊.
.NET 版本:
.NET Core 2.1+
PDF 編輯功能: 使用 IronPDF,您可以輕鬆編輯現有文件。 IronPDF 提供編輯功能,例如能夠添加頁眉和頁腳、將文字和圖像蓋印到 PDF 頁面、合併和拆分 PDF 文件、為 PDF 添加自定義浮水印,以及處理 PDF 表單。
若需了解 IronPDF 提供的功能的詳細資訊,請造訪進階 IronPDF 功能.
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");
// 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("<img src='icons/iron.png'>", @"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("<h1>Hello World</h1>");
// 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("<img src='icons/iron.png'>", @"c:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
IRON VB CONVERTER ERROR developers@ironsoftware.com
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
無論您是想將多個網頁轉換成同一個 PDF 文件,還是單個 HTML 字串,IronPDF 透過使用 ChromePdfRenderer 和支援現代網頁標準來提供高保真度的 PDF 文件。 使用IronPDF,您可以轉換高保真 HTML 轉 PDF只需幾行程式碼即可完成。 SelectPdf 的 HTML 轉 PDF 轉換工具實施簡潔迅速,但可能無法產生同樣高品質的輸出。
如果您想了解更多關於IronPDF的HTML到PDF轉換工具,請查看我們的便捷指南HTML 轉 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 & 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 & 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 & 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")
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
當您在尋找高效加密您的 PDF 文件,IronPDF 和 SelectPdf 都提供內建的加密工具。 IronPDF 的加密功能非常廣泛,讓您在維持易於使用的同時,擁有對各種安全設置的充足控制。 SelectPdf 的加密功能簡潔易用,易於整合到您的專案中。
如需有關向 PDF 檔案添加密碼和權限的更多信息,請訪問 IronPDF 的幫助頁面。添加密碼和權限指南.
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")
SelectPdf:
SelectPdf 不直接支援修訂。
IronPDF 提供了一個簡潔而強大的 PDF編輯工具能夠僅用幾行代碼遮掩指定內容的功能。 另一方面,SelectPdf 缺乏內建的編修功能。
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")
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()
使用 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("<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")
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()
IronPDF 的內建水印工具利用 HTML 和 CSS 提供一種簡便的方法在您的 PDF 頁面上應用浮水印,同時讓您完全掌控整個過程,並只需使用幾行代碼即可完成。 SelectPdf 也有一個 PDF 浮水印工具,您可以使用它將自訂浮水印添加到您的 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");
// 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("<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");
// 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("<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")
' 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")
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()
IronPDF 提供了一個強大的工具給將文字和圖片加蓋到PDF文件上您的 PDF 文件。 應用文字或圖片標記的方法類似於 HTML 和 CSS,這意味著您將完全掌控標記過程。 SelectPdf 的方法需要較長的時間,並且在過程中涉及更多的手動工作。
如果您想了解有關 IronPDF 蓋章工具的更多資訊,請務必查看其方便的工具。文本和圖片蓋章指南.
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")
SelectPdf:
SelectPdf 不支持直接將 DOCX 轉換為 PDF。
IronPDF 支援直接轉換DOCX 檔案轉 PDF. 有了這項功能,您可以用幾行程式碼將 DOCX 轉換為 PDF,且不會損失檔案的品質。 然而,SelectPdf 不提供內建的 DOCX 轉 PDF 支援。
若要了解有關IronPDF的DOCX轉PDF功能的更多資訊,請務必查看DOCX 轉 PDF 轉換指南.
如需詳細的程式碼範例,請訪問IronPDF 範例頁面.
IronPDF 授權和定價擁有不同的等級和額外功能可供購買許可證。 開發人員還可以購買IronSuite這使您以兩個產品的價格獲得IronSoftware所有產品的使用權。 如果您還沒有準備好購買許可證,IronPDF 提供一個免費試用選項持續30天。
IronSuite:只需 1,498 美元,即可使用包括 IronPDF、IronOCR、IronWord、IronXL、IronBarcode、IronQR、IronZIP、IronPrint 和 IronWebScraper 在內的所有 Iron Software 產品。
SelectPdf 提供一系列永久授權等級,全部包含一年維護計劃。
IronPDF 在提供廣泛的文檔和支援方面表現出色:
定期更新:每月產品更新,以確保提供最新功能和安全補丁。
如需更多資訊,請查看 IronPDF 的廣泛內容文件庫, 並造訪IronSoftware YouTube 頻道.
在處理 PDF 時,擁有適合您 PDF 專案需求的 PDF 函式庫是至關重要的。 今天我們親眼看到 IronPDF 和 SelectPdf 的運作情況,並深入了解這兩個庫。 SelectPdf 提供了一系列強大的功能來處理 PDF,但是與 IronPDF 相比,其中許多功能可能需要更多的工作來實現。
IronPDF 在需要強大的 PDF 功能的 .NET 開發者中脫穎而出,是一個多功能且全面的解決方案。 其廣泛的功能、與現代 .NET 框架的兼容性以及優秀的支援使其成為一個您開發者工具包中強大的工具。
您可以嘗試使用 0 天免費試用 查看他們的可用功能。