註解允許使用者在文件的特定部分新增註解、提醒或其他資訊。 這些工具可在處理 PDF 時加強協作與溝通,讓使用者能夠註解、評論共用內容,並提供上下文。 Y
PDF 註解在業務工作流程中有各種用途:審閱人員可以在文件上標示反饋意見,團隊可以在不修改原始內容的情況下協同處理合約,品質保證團隊可以標示技術文件中的問題。 無論您是在建立文件管理系統或強化現有的 PDF 工作流程,IronPDF 的註解功能都能與您的 C# PDF 創作和 編輯功能無縫整合。 對於需要先進安全功能以及註解功能的組織,請探索我們全面的 IronPDF 安全性教學。
快速入門:使用IronPDF向PDF新增註釋
本快速指南演示了如何在 C# 中使用 IronPDF 在 PDF 文件中新增文字注释。 只需幾行程式碼,開發人員就能透過加入註解或備註來增強 PDF 的功能,增加文件的互動性與協作性。 首先載入您的 PDF 文件,並使用 AddTextAnnotation 方法快速插入註解。
PDF 註解允許在 PDF 頁面上新增類似"便條"的註解。 通過使用 Add 的方法,註解可以程式化地新增到 Annotations 屬性。
PDF 中的文字註解功能類似於實體文件中的便條貼。 它們會以小圖示的形式出現在頁面上,點擊後會顯示完整的註解文字。 這種非侵入式的方法可保持文件的可讀性,同時提供必要的回饋機制。 在處理 HTML 至 PDF 的轉換時,您可以在轉換後加入註解,以標示需要檢閱的區域或提供額外的上下文。 此功能與 JavaScript 渲染結合時,對於可能需要額外說明的動態內容尤其有用。
提示: 所有頁面索引都採用零為基準的索引。
using IronPdf;using IronPdf.Annotations;ChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>");// Create a PDF annotation object on a specified page indexTextAnnotation annotation = new TextAnnotation(0){Title = "This is the title",Contents = "This is the long 'sticky note' comment content...",X = 50,Y = 700,};// Add the annotationpdf.Annotations.Add(annotation);pdf.SaveAs("annotation.pdf");
using IronPdf;
using IronPdf.Annotations;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>");
// Create a PDF annotation object on a specified page index
TextAnnotation annotation = new TextAnnotation(0)
{
Title = "This is the title",
Contents = "This is the long 'sticky note' comment content...",
X = 50,
Y = 700,
};
// Add the annotation
pdf.Annotations.Add(annotation);
pdf.SaveAs("annotation.pdf");
ImportsIronPdfImportsIronPdf.AnnotationsDim renderer As New ChromePdfRenderer()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>")' Create a PDF annotation object on a specified page indexDim annotation As New TextAnnotation(0) With { .Title = "This is the title", .Contents = "This is the long 'sticky note' comment content...", .X = 50, .Y = 700}' Add the annotationpdf.Annotations.Add(annotation)pdf.SaveAs("annotation.pdf")
Imports IronPdf
Imports IronPdf.Annotations
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Annotation</h1>")
' Create a PDF annotation object on a specified page index
Dim annotation As New TextAnnotation(0) With {
.Title = "This is the title",
.Contents = "This is the long 'sticky note' comment content...",
.X = 50,
.Y = 700
}
' Add the annotation
pdf.Annotations.Add(annotation)
pdf.SaveAs("annotation.pdf")
TextAnnotation 類提供了多個自訂屬性:
Title:註解的標題文字,通常顯示於註解彈出視窗中
Contents:註解的主要正文文字
X, Y:指定註解圖示在頁面上出現位置的座標
PageIndex:註解應放置的頁面(以零為起始)的頁碼
對於更複雜的文件工作流程,可考慮將註解與其他 IronPDF 功能結合,例如用於核准流程的 數位簽名,或用於文件版本管理的 水印。 在處理敏感文件時,您也可以將註解與 PDF 權限和密碼整合,以控制誰可以檢視或修改註解。
using IronPdf;PdfDocument pdf = PdfDocument.FromFile("multipleAnnotation.pdf");// Remove a single annotation with specified indexpdf.Annotations.RemoveAt(1);pdf.SaveAs("removeSingleAnnotation.pdf");
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("multipleAnnotation.pdf");
// Remove a single annotation with specified index
pdf.Annotations.RemoveAt(1);
pdf.SaveAs("removeSingleAnnotation.pdf");
ImportsIronPdfPrivate pdf AsPdfDocument = PdfDocument.FromFile("multipleAnnotation.pdf")' Remove a single annotation with specified indexpdf.Annotations.RemoveAt(1)pdf.SaveAs("removeSingleAnnotation.pdf")
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("multipleAnnotation.pdf")
' Remove a single annotation with specified index
pdf.Annotations.RemoveAt(1)
pdf.SaveAs("removeSingleAnnotation.pdf")
using IronPdf;PdfDocument pdf = PdfDocument.FromFile("multipleAnnotation.pdf");// Remove all annotaions on a specified pagepdf.Annotations.RemoveAllAnnotationsForPage(0);// Remove all annotaions on the documentpdf.Annotations.Clear();pdf.SaveAs("removeAllAnnotation.pdf");
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("multipleAnnotation.pdf");
// Remove all annotaions on a specified page
pdf.Annotations.RemoveAllAnnotationsForPage(0);
// Remove all annotaions on the document
pdf.Annotations.Clear();
pdf.SaveAs("removeAllAnnotation.pdf");
ImportsIronPdfPrivate pdf AsPdfDocument = PdfDocument.FromFile("multipleAnnotation.pdf")' Remove all annotaions on a specified pagepdf.Annotations.RemoveAllAnnotationsForPage(0)' Remove all annotaions on the documentpdf.Annotations.Clear()pdf.SaveAs("removeAllAnnotation.pdf")
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("multipleAnnotation.pdf")
' Remove all annotaions on a specified page
pdf.Annotations.RemoveAllAnnotationsForPage(0)
' Remove all annotaions on the document
pdf.Annotations.Clear()
pdf.SaveAs("removeAllAnnotation.pdf")
using IronPdf;using IronPdf.Annotations;// Load an existing multi-page PDFPdfDocument pdf = PdfDocument.FromFile("multipage.pdf");// Create a clickable link on page 1 (index 0) that jumps to page 6 (index 5).// Page indexes are zero-based. The default DestinationType (Page) fits the// whole destination page in the viewer when the link is clicked.LinkAnnotation link = new LinkAnnotation(pageIndex: 0, destinationPageIndex: 5){X = 72, // points from the LEFT edge of the page (72 points = 1 inch)Y = 700, // BOTTOM edge of the clickable area (PDF origin is bottom-left)Width = 200,Height = 20,Contents = "Go to Chapter 6"};// LinkAnnotation lives in the same collection as TextAnnotationpdf.Annotations.Add(link);pdf.SaveAs("internal-link.pdf");
using IronPdf;
using IronPdf.Annotations;
// Load an existing multi-page PDF
PdfDocument pdf = PdfDocument.FromFile("multipage.pdf");
// Create a clickable link on page 1 (index 0) that jumps to page 6 (index 5).
// Page indexes are zero-based. The default DestinationType (Page) fits the
// whole destination page in the viewer when the link is clicked.
LinkAnnotation link = new LinkAnnotation(pageIndex: 0, destinationPageIndex: 5)
{
X = 72, // points from the LEFT edge of the page (72 points = 1 inch)
Y = 700, // BOTTOM edge of the clickable area (PDF origin is bottom-left)
Width = 200,
Height = 20,
Contents = "Go to Chapter 6"
};
// LinkAnnotation lives in the same collection as TextAnnotation
pdf.Annotations.Add(link);
pdf.SaveAs("internal-link.pdf");
ImportsIronPdfImportsIronPdf.Annotations' Load an existing multi-page PDFDim pdf AsPdfDocument = PdfDocument.FromFile("multipage.pdf")' Create a clickable link on page 1 (index 0) that jumps to page 6 (index 5).' Page indexes are zero-based. The default DestinationType (Page) fits the' whole destination page in the viewer when the link is clicked.Dim link As New LinkAnnotation(pageIndex:=0, destinationPageIndex:=5) With { .X = 72, ' points from the LEFT edge of the page (72 points = 1 inch) .Y = 700, ' BOTTOM edge of the clickable area (PDF origin is bottom-left) .Width = 200, .Height = 20, .Contents = "Go to Chapter 6"}' LinkAnnotation lives in the same collection as TextAnnotationpdf.Annotations.Add(link)pdf.SaveAs("internal-link.pdf")
Imports IronPdf
Imports IronPdf.Annotations
' Load an existing multi-page PDF
Dim pdf As PdfDocument = PdfDocument.FromFile("multipage.pdf")
' Create a clickable link on page 1 (index 0) that jumps to page 6 (index 5).
' Page indexes are zero-based. The default DestinationType (Page) fits the
' whole destination page in the viewer when the link is clicked.
Dim link As New LinkAnnotation(pageIndex:=0, destinationPageIndex:=5) With {
.X = 72, ' points from the LEFT edge of the page (72 points = 1 inch)
.Y = 700, ' BOTTOM edge of the clickable area (PDF origin is bottom-left)
.Width = 200,
.Height = 20,
.Contents = "Go to Chapter 6"
}
' LinkAnnotation lives in the same collection as TextAnnotation
pdf.Annotations.Add(link)
pdf.SaveAs("internal-link.pdf")
除了位置設置,還有一些屬性控制外觀和元資料:Color 設置連結的邊框顏色,Contents 提供描述性文字或工具提示,Title 命名註解。 對於現有內容的不顯示點擊覆蓋,將 Color 保持不設置並設置 Hidden = true(本指南稍後會展示)。
因為 LinkAnnotation 目標是同一文件中的頁面,所以它補充了 IronPDF 的大綱和書籤(建立查看器的側邊欄導航樹)以及自動生成的目錄功能,用於 HTML 到 PDF 的渲染。 當您需要在現有的 PDF 上新增可點擊的熱點時,請使用書籤功能用於側邊欄,用於渲染 HTML 的目錄功能,和 LinkAnnotation。
using IronPdf;using IronPdf.Annotations;using IronPdf.Bookmarks;PdfDocument pdf = PdfDocument.FromFile("multipage.pdf");// 1. Scroll to a specific vertical position on the destination page (full width shown)LinkAnnotation scrollLink = new LinkAnnotation(0, 2){X = 72, Y = 680, Width = 300, Height = 16,DestinationType = BookmarkDestinations.PageY,DestinationTop = 400 // scroll so y=400 sits at the top of the view};pdf.Annotations.Add(scrollLink);// 2. Jump to a position AND set the zoom levelLinkAnnotation zoomLink = new LinkAnnotation(0, 3, "Zoom to figure"){X = 72, Y = 650, Width = 200, Height = 16,DestinationType = BookmarkDestinations.PageZoom,DestinationLeft = 100,DestinationTop = 500,DestinationZoom = 150 // 150% zoom; use 0 to inherit the current zoom};pdf.Annotations.Add(zoomLink);// 3. Fit a specific rectangle on the destination pageLinkAnnotation rectLink = new LinkAnnotation(0, 4){X = 72, Y = 620, Width = 200, Height = 16,DestinationType = BookmarkDestinations.PageRect,DestinationLeft = 50,DestinationBottom = 100,DestinationRight = 550,DestinationTop = 700};pdf.Annotations.Add(rectLink);pdf.SaveAs("link-destinations.pdf");
using IronPdf;
using IronPdf.Annotations;
using IronPdf.Bookmarks;
PdfDocument pdf = PdfDocument.FromFile("multipage.pdf");
// 1. Scroll to a specific vertical position on the destination page (full width shown)
LinkAnnotation scrollLink = new LinkAnnotation(0, 2)
{
X = 72, Y = 680, Width = 300, Height = 16,
DestinationType = BookmarkDestinations.PageY,
DestinationTop = 400 // scroll so y=400 sits at the top of the view
};
pdf.Annotations.Add(scrollLink);
// 2. Jump to a position AND set the zoom level
LinkAnnotation zoomLink = new LinkAnnotation(0, 3, "Zoom to figure")
{
X = 72, Y = 650, Width = 200, Height = 16,
DestinationType = BookmarkDestinations.PageZoom,
DestinationLeft = 100,
DestinationTop = 500,
DestinationZoom = 150 // 150% zoom; use 0 to inherit the current zoom
};
pdf.Annotations.Add(zoomLink);
// 3. Fit a specific rectangle on the destination page
LinkAnnotation rectLink = new LinkAnnotation(0, 4)
{
X = 72, Y = 620, Width = 200, Height = 16,
DestinationType = BookmarkDestinations.PageRect,
DestinationLeft = 50,
DestinationBottom = 100,
DestinationRight = 550,
DestinationTop = 700
};
pdf.Annotations.Add(rectLink);
pdf.SaveAs("link-destinations.pdf");
ImportsIronPdfImportsIronPdf.AnnotationsImportsIronPdf.BookmarksDim pdf AsPdfDocument = PdfDocument.FromFile("multipage.pdf")' 1. Scroll to a specific vertical position on the destination page (full width shown)Dim scrollLink As New LinkAnnotation(0, 2) With { .X = 72, .Y = 680, .Width = 300, .Height = 16, .DestinationType = BookmarkDestinations.PageY, .DestinationTop = 400 ' scroll so y=400 sits at the top of the view}pdf.Annotations.Add(scrollLink)' 2. Jump to a position AND set the zoom levelDim zoomLink As New LinkAnnotation(0, 3, "Zoom to figure") With { .X = 72, .Y = 650, .Width = 200, .Height = 16, .DestinationType = BookmarkDestinations.PageZoom, .DestinationLeft = 100, .DestinationTop = 500, .DestinationZoom = 150 ' 150% zoom; use 0 to inherit the current zoom}pdf.Annotations.Add(zoomLink)' 3. Fit a specific rectangle on the destination pageDim rectLink As New LinkAnnotation(0, 4) With { .X = 72, .Y = 620, .Width = 200, .Height = 16, .DestinationType = BookmarkDestinations.PageRect, .DestinationLeft = 50, .DestinationBottom = 100, .DestinationRight = 550, .DestinationTop = 700}pdf.Annotations.Add(rectLink)pdf.SaveAs("link-destinations.pdf")
Imports IronPdf
Imports IronPdf.Annotations
Imports IronPdf.Bookmarks
Dim pdf As PdfDocument = PdfDocument.FromFile("multipage.pdf")
' 1. Scroll to a specific vertical position on the destination page (full width shown)
Dim scrollLink As New LinkAnnotation(0, 2) With {
.X = 72,
.Y = 680,
.Width = 300,
.Height = 16,
.DestinationType = BookmarkDestinations.PageY,
.DestinationTop = 400 ' scroll so y=400 sits at the top of the view
}
pdf.Annotations.Add(scrollLink)
' 2. Jump to a position AND set the zoom level
Dim zoomLink As New LinkAnnotation(0, 3, "Zoom to figure") With {
.X = 72,
.Y = 650,
.Width = 200,
.Height = 16,
.DestinationType = BookmarkDestinations.PageZoom,
.DestinationLeft = 100,
.DestinationTop = 500,
.DestinationZoom = 150 ' 150% zoom; use 0 to inherit the current zoom
}
pdf.Annotations.Add(zoomLink)
' 3. Fit a specific rectangle on the destination page
Dim rectLink As New LinkAnnotation(0, 4) With {
.X = 72,
.Y = 620,
.Width = 200,
.Height = 16,
.DestinationType = BookmarkDestinations.PageRect,
.DestinationLeft = 50,
.DestinationBottom = 100,
.DestinationRight = 550,
.DestinationTop = 700
}
pdf.Annotations.Add(rectLink)
pdf.SaveAs("link-destinations.pdf")
using IronPdf;using IronPdf.Annotations;using IronPdf.Bookmarks;using System;using System.Collections.Generic;PdfDocument pdf = PdfDocument.FromFile("report-with-toc.pdf");// Zero-based index of the page that holds the table-of-contents textint tocPageIndex = 1;// Map each TOC entry's leading text to the page index it should jump tovar tocEntries = new Dictionary<string, int>{ { "Introduction", 2 }, { "Methodology", 4 }, { "Results", 6 }, { "Conclusion", 9 },};// Walk the text chunks on the TOC page and overlay a clickable link on each matchforeach (var chunk in pdf.Pages[tocPageIndex].TextChunks){ string text = chunk.Contents.Trim(); foreach (var entry in tocEntries) { if (!text.StartsWith(entry.Key)) continue; var box = chunk.BoundingBox; pdf.Annotations.Add(new LinkAnnotation(tocPageIndex, entry.Value) {X = (int)box.Left,Y = (int)box.Bottom, // Bottom, NOT Top (PDF origin is bottom-left)Width = (int)Math.Max(box.Width, 400),Height = (int)Math.Abs(box.Top - box.Bottom),DestinationType = BookmarkDestinations.PageY,DestinationTop = 792, // top of a US Letter pageHidden = true // invisible overlay on the existing TOC text }); break; }}pdf.SaveAs("clickable-toc.pdf");
using IronPdf;
using IronPdf.Annotations;
using IronPdf.Bookmarks;
using System;
using System.Collections.Generic;
PdfDocument pdf = PdfDocument.FromFile("report-with-toc.pdf");
// Zero-based index of the page that holds the table-of-contents text
int tocPageIndex = 1;
// Map each TOC entry's leading text to the page index it should jump to
var tocEntries = new Dictionary<string, int>
{
{ "Introduction", 2 },
{ "Methodology", 4 },
{ "Results", 6 },
{ "Conclusion", 9 },
};
// Walk the text chunks on the TOC page and overlay a clickable link on each match
foreach (var chunk in pdf.Pages[tocPageIndex].TextChunks)
{
string text = chunk.Contents.Trim();
foreach (var entry in tocEntries)
{
if (!text.StartsWith(entry.Key)) continue;
var box = chunk.BoundingBox;
pdf.Annotations.Add(new LinkAnnotation(tocPageIndex, entry.Value)
{
X = (int)box.Left,
Y = (int)box.Bottom, // Bottom, NOT Top (PDF origin is bottom-left)
Width = (int)Math.Max(box.Width, 400),
Height = (int)Math.Abs(box.Top - box.Bottom),
DestinationType = BookmarkDestinations.PageY,
DestinationTop = 792, // top of a US Letter page
Hidden = true // invisible overlay on the existing TOC text
});
break;
}
}
pdf.SaveAs("clickable-toc.pdf");
ImportsIronPdfImportsIronPdf.AnnotationsImportsIronPdf.BookmarksImportsSystemImportsSystem.Collections.GenericDim pdf AsPdfDocument = PdfDocument.FromFile("report-with-toc.pdf")' Zero-based index of the page that holds the table-of-contents textDim tocPageIndex AsInteger = 1' Map each TOC entry's leading text to the page index it should jump toDim tocEntries As New Dictionary(OfString, Integer) From { {"Introduction", 2}, {"Methodology", 4}, {"Results", 6}, {"Conclusion", 9}}' Walk the text chunks on the TOC page and overlay a clickable link on each matchFor Each chunk In pdf.Pages(tocPageIndex).TextChunks Dim text AsString = chunk.Contents.Trim() For Each entry In tocEntries IfNot text.StartsWith(entry.Key) Then Continue For Dim box = chunk.BoundingBox pdf.Annotations.Add(New LinkAnnotation(tocPageIndex, entry.Value) With { .X = CInt(box.Left), .Y = CInt(box.Bottom), ' Bottom, NOT Top (PDF origin is bottom-left) .Width = CInt(Math.Max(box.Width, 400)), .Height = CInt(Math.Abs(box.Top - box.Bottom)), .DestinationType = BookmarkDestinations.PageY, .DestinationTop = 792, ' top of a US Letter page .Hidden = True ' invisible overlay on the existing TOC text }) Exit For NextNextpdf.SaveAs("clickable-toc.pdf")
Imports IronPdf
Imports IronPdf.Annotations
Imports IronPdf.Bookmarks
Imports System
Imports System.Collections.Generic
Dim pdf As PdfDocument = PdfDocument.FromFile("report-with-toc.pdf")
' Zero-based index of the page that holds the table-of-contents text
Dim tocPageIndex As Integer = 1
' Map each TOC entry's leading text to the page index it should jump to
Dim tocEntries As New Dictionary(Of String, Integer) From {
{"Introduction", 2},
{"Methodology", 4},
{"Results", 6},
{"Conclusion", 9}
}
' Walk the text chunks on the TOC page and overlay a clickable link on each match
For Each chunk In pdf.Pages(tocPageIndex).TextChunks
Dim text As String = chunk.Contents.Trim()
For Each entry In tocEntries
If Not text.StartsWith(entry.Key) Then Continue For
Dim box = chunk.BoundingBox
pdf.Annotations.Add(New LinkAnnotation(tocPageIndex, entry.Value) With {
.X = CInt(box.Left),
.Y = CInt(box.Bottom), ' Bottom, NOT Top (PDF origin is bottom-left)
.Width = CInt(Math.Max(box.Width, 400)),
.Height = CInt(Math.Abs(box.Top - box.Bottom)),
.DestinationType = BookmarkDestinations.PageY,
.DestinationTop = 792, ' top of a US Letter page
.Hidden = True ' invisible overlay on the existing TOC text
})
Exit For
Next
Next
pdf.SaveAs("clickable-toc.pdf")
源自左下角的 PDF 座標可能會讓習慣左上角原點系統的開發人員感到困惑。 不正確的座標計算可能會將註解放置在意想不到的位置,可能會遮蔽重要內容或出現在頁面外。 與 UI 框架或使用者輸入系統整合時,務必適當轉換座標。
在實施點擊註釋功能等功能或將使用者互動的螢幕坐標轉換為 PDF 坐標時,瞭解坐標系統變得更加重要。 對於複雜的定位需求,請考慮使用 IronPDF 的 viewport 和 zoom 功能,以確保無論在任何檢視條件下,註解都能正確顯示。
在新增多個註解時,我該如何優化效能?
新增多個註解時,請先將所有註解新增至集合,然後再儲存文件,以進行批次作業。 此方法可減少檔案 I/O 作業,並大幅提升效能,尤其是在處理大型 PDF 或連續處理多個文件時。 考慮實施進度指標,以便在大量作業期間提供更好的使用者體驗。
// Example of batch annotation processingvar annotations = new List<TextAnnotation>();for (int i = 0; i < 100; i++){ annotations.Add(new TextAnnotation(0) { Title = $"Note {i}", Contents = $"Content for note {i}",X = 50 + (i * 10),Y = 700 - (i * 20) });}// Add all annotations at onceforeach (var annotation in annotations){ pdf.Annotations.Add(annotation);}// Save once after all additionspdf.SaveAs("batch-annotated.pdf");
// Example of batch annotation processing
var annotations = new List<TextAnnotation>();
for (int i = 0; i < 100; i++)
{
annotations.Add(new TextAnnotation(0)
{
Title = $"Note {i}",
Contents = $"Content for note {i}",
X = 50 + (i * 10),
Y = 700 - (i * 20)
});
}
// Add all annotations at once
foreach (var annotation in annotations)
{
pdf.Annotations.Add(annotation);
}
// Save once after all additions
pdf.SaveAs("batch-annotated.pdf");
ImportsSystem.Collections.Generic' Example of batch annotation processingDim annotations As New List(OfTextAnnotation)()For i AsInteger = 0 To 99 annotations.Add(New TextAnnotation(0) With { .Title = $"Note {i}", .Contents = $"Content for note {i}", .X = 50 + (i * 10), .Y = 700 - (i * 20) })Next' Add all annotations at onceFor Each annotation In annotations pdf.Annotations.Add(annotation)Next' Save once after all additionspdf.SaveAs("batch-annotated.pdf")
Imports System.Collections.Generic
' Example of batch annotation processing
Dim annotations As New List(Of TextAnnotation)()
For i As Integer = 0 To 99
annotations.Add(New TextAnnotation(0) With {
.Title = $"Note {i}",
.Contents = $"Content for note {i}",
.X = 50 + (i * 10),
.Y = 700 - (i * 20)
})
Next
' Add all annotations at once
For Each annotation In annotations
pdf.Annotations.Add(annotation)
Next
' Save once after all additions
pdf.SaveAs("batch-annotated.pdf")
使用IronPDF的LinkAnnotation類,通過與文字註解相同的Annotations.Add方法來新增。建立具有從零開始的頁面索引和目的地頁面索引的LinkAnnotation,使用X, Y, Width和Height(以點為單位)設置可點擊區域,IronPDF生成一個可跳轉到目標頁面的可點擊區域。這對於自定義目錄、交叉引用和返回頂部按鈕非常理想。
Why is it important to test PDFs with annotations across different readers?
Different PDF readers render annotations differently, affecting icon styles and popup behaviors. Testing in popular viewers like Adobe Acrobat, Chrome, and mobile readers ensures consistent appearance and functionality across platforms.
What are best practices for working with PDF annotations using IronPDF?
Best practices include understanding the coordinate system starting from the bottom-left, optimizing performance by batching annotation additions, ensuring cross-viewer compatibility, and considering security measures for annotated content.