使用 C# 和 IronPDF 在 PDF 上加蓋文字與影像印章
IronPDF在現有的PDF文件上使用TextStamper、ImageStamper、HTMLStamper和BarcodeStamper類別以精確定位方式加蓋文字、大圖片、HTML內容和條碼。
Stamping 將額外的內容覆蓋在現有的 PDF 文件上。 圖章可在 PDF 上加入資訊、標籤、水印或註解。 使用IronPDF的全面加蓋功能添加頁眉和頁腳或創建自訂水印。
IronPDF提供四種加蓋器:TextStamper、ImageStamper、HTMLStamper和BarcodeStamper。 HTMLStamper利用所有HTML功能和CSS樣式,類似於將HTML字串轉換為PDF。
使用IronPDF的TextStamper類別向PDF文件添加文字註解、水印或標籤。 下面的示例演示了使用ApplyStamp方法將文字加蓋到PDF上的過程。
-
1使用 IronPDF 安裝 NuGet Package Manager
-
2複製並運行這段程式碼。
var pdf = new IronPdf.PdfDocument("input.pdf"); var stamper = new IronPdf.Editing.TextStamper() { Text = "Confidential", FontSize = 50, Opacity = 50, VerticalAlignment = IronPdf.Editing.VerticalAlignment.Middle, HorizontalAlignment = IronPdf.Editing.HorizontalAlignment.Center }; pdf.ApplyStamp(stamper); pdf.SaveAs("stamped.pdf");Dim pdf = New IronPdf.PdfDocument("input.pdf") Dim stamper = New IronPdf.Editing.TextStamper() With { .Text = "Confidential", .FontSize = 50, .Opacity = 50, .VerticalAlignment = IronPdf.Editing.VerticalAlignment.Middle, .HorizontalAlignment = IronPdf.Editing.HorizontalAlignment.Center } pdf.ApplyStamp(stamper) pdf.SaveAs("stamped.pdf")Dim pdf = New IronPdf.PdfDocument("input.pdf") Dim stamper = New IronPdf.Editing.TextStamper() With { .Text = "Confidential", .FontSize = 50, .Opacity = 50, .VerticalAlignment = IronPdf.Editing.VerticalAlignment.Middle, .HorizontalAlignment = IronPdf.Editing.HorizontalAlignment.Center } pdf.ApplyStamp(stamper) pdf.SaveAs("stamped.pdf") -
3部署到您的生產環境進行測試
立即在您的項目中開始使用 IronPDF,並使用 免費試用
最小工作流程(5 個步驟)
- 下載C#程式庫以便加蓋文字和圖像
- 創建並配置所需的 stamper 類
- 使用
ApplyStamp方法將圖章套用到 PDF 檔案。 - 使用
ApplyMultipleStamps方法應用多個圖章 - 指定要應用印章的特定頁面
如何在PDF上加蓋文字?
創建一個包含所有顯示配置的TextStamper物件。 將TextStamper對象傳遞給ApplyStamp方法。 Text屬性設定顯示的文字。 設定字型族、字型樣式和圖章位置。
TextStamper提供類似於管理PDF文件中的字體的廣泛自訂選項。 通過將UseGoogleFont設置為true使用系統字體或Google字體。
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")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")輸出PDF看起來如何?
如何創建多行文字加蓋?
在TextStamper中使用<br>標籤處理多行文字。 例如,“line 1
line 2”會在第一行產生“line 1”,在第二行產生“line 2”。這樣可以創建地址加蓋或多行水印。
如何在PDF上加蓋圖像?
創建ImageStamper對象並使用ApplyStamp方法將圖片應用於文件。 方法的第二個參數接受頁面索引,用於單頁或多頁加蓋。 以下範例為 PDF 第 1 頁上的圖片蓋章。
針對複雜的圖像操作,探索向PDF添加圖像或處理base64編碼的圖像。
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")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")圖像加蓋輸出看起來如何?
支持哪些圖像格式?
ImageStamper支持PNG、JPEG、GIF和SVG,通過URI引用或文件路徑。 確保遠端影像的正常網路連線。 對於Azure環境,考慮使用從Azure Blob儲存體中取得的圖像。
如何應用多個加蓋?
通過傳遞加蓋器數組來使用ApplyMultipleStamps應用多個加蓋。 此方法可在單一作業中有效率地處理數個圖章。
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create two text stampers
TextStamper stamper1 = new TextStamper()
{
Text = "Text stamp 1",
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
};
TextStamper stamper2 = new TextStamper()
{
Text = "Text stamp 2",
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Right,
};
Stamper[] stampersToApply = { stamper1, stamper2 };
// Apply multiple stamps
pdf.ApplyMultipleStamps(stampersToApply);
pdf.SaveAs("multipleStamps.pdf");using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create two text stampers
TextStamper stamper1 = new TextStamper()
{
Text = "Text stamp 1",
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
};
TextStamper stamper2 = new TextStamper()
{
Text = "Text stamp 2",
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Right,
};
Stamper[] stampersToApply = { stamper1, stamper2 };
// Apply multiple stamps
pdf.ApplyMultipleStamps(stampersToApply);
pdf.SaveAs("multipleStamps.pdf");Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create two text stampers
Private stamper1 As New TextStamper() With {
.Text = "Text stamp 1",
.VerticalAlignment = VerticalAlignment.Top,
.HorizontalAlignment = HorizontalAlignment.Left
}
Private stamper2 As New TextStamper() With {
.Text = "Text stamp 2",
.VerticalAlignment = VerticalAlignment.Top,
.HorizontalAlignment = HorizontalAlignment.Right
}
Private stampersToApply() As Stamper = { stamper1, stamper2 }
' Apply multiple stamps
pdf.ApplyMultipleStamps(stampersToApply)
pdf.SaveAs("multipleStamps.pdf")Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create two text stampers
Private stamper1 As New TextStamper() With {
.Text = "Text stamp 1",
.VerticalAlignment = VerticalAlignment.Top,
.HorizontalAlignment = HorizontalAlignment.Left
}
Private stamper2 As New TextStamper() With {
.Text = "Text stamp 2",
.VerticalAlignment = VerticalAlignment.Top,
.HorizontalAlignment = HorizontalAlignment.Right
}
Private stampersToApply() As Stamper = { stamper1, stamper2 }
' Apply multiple stamps
pdf.ApplyMultipleStamps(stampersToApply)
pdf.SaveAs("multipleStamps.pdf")當加蓋重疊時會發生什麼?
我可以混合使用不同的加蓋類型嗎?
ApplyMultipleStamps接受包含任何加蓋器類型的陣列。合併TextStamper、ImageStamper、HTMLStamper和BarcodeStamper於一次操作中。 同時建立具有頁眉、頁腳、水印和識別碼的複雜文件版面。
如何控制加蓋位置?
使用 3x3 網格定義圖章位置,其中有三個水平列和三個垂直行。 選擇水平對齊方式:左、中、右。 選擇垂直對齊方式:上、中、下。 調整水平與垂直偏移,以達到精確定位。 請參閱下面的圖片,以獲得視覺上的呈現。

關鍵定位屬性是什麼?
HorizontalAlignment:相對於頁面的水平對齊。 預設:HorizontalAlignment.Center。VerticalAlignment:相對於頁面的垂直對齊。 預設:VerticalAlignment.Middle。HorizontalOffset:水平偏移。 預設:0,單位:MeasurementUnit.Percentage。 正值向右偏移,負值向左偏移。VerticalOffset:垂直偏移。 預設:0,單位:MeasurementUnit.Percentage。 正值向下偏移,負值向上偏移。
如何設定精確的偏移量?
使用Length類別指定HorizontalOffset和VerticalOffset。 預設測量單位為百分比。 可用的單位包括英吋、毫米、公分、像素和點。 這使得精確定位變得可能,類似於在PDF文件中設定自訂邊距。
代碼
using IronPdf.Editing;
using System;
// Create text stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Top,
// Specify offsets
HorizontalOffset = new Length(10),
VerticalOffset = new Length(10),
};using IronPdf.Editing;
using System;
// Create text stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Top,
// Specify offsets
HorizontalOffset = new Length(10),
VerticalOffset = new Length(10),
};Imports IronPdf.Editing
Imports System
' Create text stamper
Private imageStamper As New ImageStamper(New Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg")) With {
.HorizontalAlignment = HorizontalAlignment.Center,
.VerticalAlignment = VerticalAlignment.Top,
.HorizontalOffset = New Length(10),
.VerticalOffset = New Length(10)
}Imports IronPdf.Editing
Imports System
' Create text stamper
Private imageStamper As New ImageStamper(New Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg")) With {
.HorizontalAlignment = HorizontalAlignment.Center,
.VerticalAlignment = VerticalAlignment.Top,
.HorizontalOffset = New Length(10),
.VerticalOffset = New Length(10)
}如何加蓋HTML內容?
使用HtmlStamper類別加蓋文字和圖像。 HtmlStamper使用CSS樣式渲染HTML設計,然後將其加蓋到PDF文件上。 HtmlBaseUrl屬性指定HTML字串資產的基本URL,例如CSS和圖像文件。 這使用相同的渲染引擎來將HTML轉換為PDF。
代碼
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create HTML stamper
HtmlStamper htmlStamper = new HtmlStamper()
{
Html = @"<img src='https://ironpdf.com/img/svgs/iron-pdf-logo.svg'>
<h1>Iron Software</h1>",
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the HTML stamper
pdf.ApplyStamp(htmlStamper);
pdf.SaveAs("stampHtml.pdf");using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create HTML stamper
HtmlStamper htmlStamper = new HtmlStamper()
{
Html = @"<img src='https://ironpdf.com/img/svgs/iron-pdf-logo.svg'>
<h1>Iron Software</h1>",
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the HTML stamper
pdf.ApplyStamp(htmlStamper);
pdf.SaveAs("stampHtml.pdf");Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create HTML stamper
Private htmlStamper As New HtmlStamper() With {
.Html = "<img src='https://ironpdf.com/img/svgs/iron-pdf-logo.svg'>
<h1>Iron Software</h1>",
.VerticalAlignment = VerticalAlignment.Top
}
' Stamp the HTML stamper
pdf.ApplyStamp(htmlStamper)
pdf.SaveAs("stampHtml.pdf")Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create HTML stamper
Private htmlStamper As New HtmlStamper() With {
.Html = "<img src='https://ironpdf.com/img/svgs/iron-pdf-logo.svg'>
<h1>Iron Software</h1>",
.VerticalAlignment = VerticalAlignment.Top
}
' Stamp the HTML stamper
pdf.ApplyStamp(htmlStamper)
pdf.SaveAs("stampHtml.pdf")HTML加蓋器的基本屬性是什麼?
Html:要加蓋到您的PDF上的HTML片段。 對JavaScript、CSS和圖像的外部引用是相對於HtmlBaseUrl的。HtmlBaseUrl:外部CSS、JavaScript和圖像文件引用的基本URL。CssMediaType:啟用Media="screen" CSS樣式。 設定AllowScreenCss=false使用CSS media="print"渲染加蓋。 預設:PdfCssMediaType.Screen。
為什麼使用HTML加蓋器而不是文字加蓋器?
HTMLStamper提供全集成的HTML和CSS支援,用於複雜佈局、多字體、顏色和嵌入圖像在一個加蓋中。適合豐富的內容水印或頁眉。 維持一致的品牌形象並可以使用響應式CSS設計。
如何加蓋條碼?
BarcodeStamper類別直接在現有PDF文件上加蓋條碼。 支援 QRCode、Code128 及 Code39 條碼類型。
代碼
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create barcode stamper
BarcodeStamper barcodeStamper = new BarcodeStamper("IronPdf!!", BarcodeEncoding.Code39)
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the barcode stamper
pdf.ApplyStamp(barcodeStamper);
pdf.SaveAs("stampBarcode.pdf");using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create barcode stamper
BarcodeStamper barcodeStamper = new BarcodeStamper("IronPdf!!", BarcodeEncoding.Code39)
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the barcode stamper
pdf.ApplyStamp(barcodeStamper);
pdf.SaveAs("stampBarcode.pdf");Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create barcode stamper
Private barcodeStamper As New BarcodeStamper("IronPdf!!", BarcodeEncoding.Code39) With {.VerticalAlignment = VerticalAlignment.Top}
' Stamp the barcode stamper
pdf.ApplyStamp(barcodeStamper)
pdf.SaveAs("stampBarcode.pdf")Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create barcode stamper
Private barcodeStamper As New BarcodeStamper("IronPdf!!", BarcodeEncoding.Code39) With {.VerticalAlignment = VerticalAlignment.Top}
' Stamp the barcode stamper
pdf.ApplyStamp(barcodeStamper)
pdf.SaveAs("stampBarcode.pdf")條碼有哪些配置選項?
Value:條碼的字串值。BarcodeType:支持QRCode、Code128和Code39的編碼類型。預設:QRCode。Width:渲染條碼的寬度(像素)。 預設:250px。Height:渲染條碼的高度(像素)。 預設:250px。
何時應使用每種類型的條碼?
QRCode 可處理 URL 和大型資料集(最多可達 4,296 個字母數字字符)。 Code128適用於具有高密度要求的字母數字數據。 Code39適用於簡單的數字或大寫字母組合。 選擇 BarCode 類型時,請考慮掃描設備的相容性。
有哪些其他加蓋選項?
這些屬性提供對加蓋外觀和行為的精細控制,類似於創建自訂水印。
如何控制加蓋外觀?
Opacity:控制透明度。 0 代表隱形,100 代表不透明。Rotation:將加蓋從0到360度順時針旋轉。MaxWidth:輸出加蓋的最大寬度。MaxHeight:輸出加蓋的最大高度。MinWidth:輸出加蓋的最小寬度。MinHeight:輸出加蓋的最小高度。Hyperlink:為加蓋元素添加點擊超連結。 注意:加蓋不會保留HTML連結(a標籤)。Scale:對加蓋應用百分比縮放。 預設值:100 (無效)。IsStampBehindContent:將加蓋放置在內容後面。 如果內容不透明,可能看不到圖章。WaitFor:等待事件或時間。請參閱使用WaitFor延遲PDF渲染。Timeout:渲染超時(秒)。 預設值:60。
哪些屬性最常使用?
Opacity和IsStampBehindContent創建浮水印。 Scale和Rotation調整視覺定位和大小。 範例:
// Create a semi-transparent watermark behind content
TextStamper watermark = new TextStamper()
{
Text = "CONFIDENTIAL",
FontSize = 60,
FontColorCode = "#CCCCCC",
Opacity = 25,
Rotation = -45,
IsStampBehindContent = true,
VerticalAlignment = VerticalAlignment.Middle,
HorizontalAlignment = HorizontalAlignment.Center
};// Create a semi-transparent watermark behind content
TextStamper watermark = new TextStamper()
{
Text = "CONFIDENTIAL",
FontSize = 60,
FontColorCode = "#CCCCCC",
Opacity = 25,
Rotation = -45,
IsStampBehindContent = true,
VerticalAlignment = VerticalAlignment.Middle,
HorizontalAlignment = HorizontalAlignment.Center
};' Create a semi-transparent watermark behind content
Dim watermark As New TextStamper() With {
.Text = "CONFIDENTIAL",
.FontSize = 60,
.FontColorCode = "#CCCCCC",
.Opacity = 25,
.Rotation = -45,
.IsStampBehindContent = True,
.VerticalAlignment = VerticalAlignment.Middle,
.HorizontalAlignment = HorizontalAlignment.Center
}' Create a semi-transparent watermark behind content
Dim watermark As New TextStamper() With {
.Text = "CONFIDENTIAL",
.FontSize = 60,
.FontColorCode = "#CCCCCC",
.Opacity = 25,
.Rotation = -45,
.IsStampBehindContent = True,
.VerticalAlignment = VerticalAlignment.Middle,
.HorizontalAlignment = HorizontalAlignment.Center
}總結
IronPDF的加蓋功能可以將文字、圖像、HTML內容和條碼添加到現有的PDF文件中。 四種具有廣泛客製化選項的專業 stamper 類別可建立具有水印、頁首、頁尾和註解的專業文件。 具有各種測量單位和對齊方式選項的定位系統可確保像素完美的位置。 使用簡單的文字戳記或複雜的 HTML 佈局與 CSS 定型。 IronPDF的加蓋API提供靈活性和控制,適合企業級PDF操作。
常見問題
在 PDF 上加蓋文字和圖片的目的是什麼?
在現有PDF文件上加蓋覆蓋物,可添加資訊、標籤、浮水印或註解。IronPDF允許在加蓋文字、圖像、HTML內容和條形碼時進行精確定位控制。
如何使用IronPDF在PDF上加蓋文字?
您可以使用IronPDF的TextStamper類別來新增文字註解、水印或標籤。設定TextStamper物件,包含所需的文字、字體大小及對齊方式,然後使用ApplyStamp方法來應用。
IronPDF支持哪些圖像格式進行PDF加蓋?
IronPDF中的ImageStamper類別支援PNG、JPEG、GIF和SVG圖像格式。您可以透過URI參考或檔案路徑提供這些圖像。
我可以在PDF上同時加蓋多個印章嗎?
是的,IronPDF允許您使用ApplyMultipleStamps方法應用多個圖章。您可以在一次操作中結合不同的圖章類別,例如TextStamper、ImageStamper、HTMLStamper和BarcodeStamper。
我如何控制PDF文件上的印章位置?
IronPDF使用3x3網格系統來定位印章。您可以指定水平和垂直對齊,並使用偏移來微調放置,以實現像素級精確位置。
使用`HTMLStamper`和`TextStamper`有何主要區別?
HTMLStamper類別支援完整的HTML和CSS功能,允許複雜的版面設計和嵌入圖像,而TextStamper適合更簡單的文字註解。HTML圖章對於創建豐富內容的水印或標題非常有用。
如何使用IronPDF創建半透明的浮水印?
您可以使用IronPDF的圖章類別中的Opacity屬性來創建半透明的水印。例如,將Opacity設為25,以在PDF文件上應用輕透明的水印。
IronPDF支持哪些類型的條形碼在PDF上加蓋?
IronPDF的BarcodeStamper類別支援QRCode、Code128和Code39條碼類型。每種類型適合不同的編碼需求,並可在大小及位置上進行客製化。
是否可以在IronPDF中為加蓋元素添加超連結?
是的,IronPDF允許您透過Hyperlink屬性將超連結添加到圖章元素中。但是請注意,HTML連結(a標籤)不會在圖章中保留。
加蓋PDF文字時,我可以使用Google字型嗎?
是的,IronPDF允許您在TextStamper中使用Google Fonts。將UseGoogleFont屬性設為true,並指定所需字體系列,即可在您的文字圖章中使用Google Fonts。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。