PDF注釈を追加および編集する方法
注釈により、ユーザーはドキュメントの特定のセクションにコメント、リマインダー、または追加情報を追加することができます。 それらは、PDFの共同作業やコミュニケーションを強化し、ユーザーが共有コンテンツに注釈を付け、コメントし、文脈を提供することを可能にします。
IronPDFの使用を開始!**
今日から無料トライアルでIronPDFをあなたのプロジェクトで使い始めましょう。
PDF注釈を追加および編集する方法
- PDF注釈用C#ライブラリのダウンロード
- 既存のPDFドキュメントを読み込むか、新しいPDFドキュメントをレンダリングします。
- 以下を使用
追加
注釈の追加方法 - PDF注釈の取得と編集
- PDFドキュメントから注釈を削除
注釈の追加例
PDF注釈は、PDFページに「付箋メモ」のようなコメントを追加することを可能にします。 Annotations プロパティの Add
メソッドを使用することにより、注釈をプログラムで追加できます。
ヒント
:path=/static-assets/pdf/content-code-examples/how-to/annotation-add-annotation.cs
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");
IRON VB CONVERTER ERROR developers@ironsoftware.com
注釈付きPDF
上記のPDFドキュメント内の注釈は、Chromeブラウザーで表示できます。
注釈の取得と編集の例
PDF注釈の取得および編集は、明確さ、正確性、使用性を向上させることでコラボレーションを改善します。 Annotationsプロパティを通じて注釈コレクションにアクセスし、タイトル、内容、X、Yなどのプロパティを新しい情報で更新します。
:path=/static-assets/pdf/content-code-examples/how-to/annotation-edit-annotation.cs
using IronPdf;
using IronPdf.Annotations;
using System.Linq;
PdfDocument pdf = PdfDocument.FromFile("annotation.pdf");
// Retrieve annotation collection
PdfAnnotationCollection annotationCollection = pdf.Annotations;
// Select the first annotation
TextAnnotation annotation = (TextAnnotation)annotationCollection.First();
// Edit annotation
annotation.Title = "New title";
annotation.Contents = "New content...";
annotation.X = 150;
annotation.Y = 800;
pdf.SaveAs("editedAnnotation.pdf");
Imports IronPdf
Imports IronPdf.Annotations
Imports System.Linq
Private pdf As PdfDocument = PdfDocument.FromFile("annotation.pdf")
' Retrieve annotation collection
Private annotationCollection As PdfAnnotationCollection = pdf.Annotations
' Select the first annotation
Private annotation As TextAnnotation = CType(annotationCollection.First(), TextAnnotation)
' Edit annotation
annotation.Title = "New title"
annotation.Contents = "New content..."
annotation.X = 150
annotation.Y = 800
pdf.SaveAs("editedAnnotation.pdf")
編集された注釈付きPDF
上記のPDFドキュメント内の注釈は、Chromeブラウザーで表示できます。
注釈を削除する例
以下のメソッドを使用して、不要または古くなった注釈を簡単に削除できます:RemoveAt
、RemoveAllAnnotationsForPage
、および Clear
。
- RemoveAt: 指定されたインデックスのアノテーションを1つ削除します。
- RemoveAllAnnotationsForPage:指定されたページのすべての注釈を削除します。
- クリア: ドキュメントのすべての注釈を削除します。
単一注釈を削除
単一の注釈を削除するには、注釈コレクションのインデックスに基づいた対応するインデックスを使用して RemoveAt
メソッドを使用します。
:path=/static-assets/pdf/content-code-examples/how-to/annotation-remove-single-annotation.cs
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("multipleAnnotation.pdf");
// Remove a single annotation with specified index
pdf.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")
単一の注釈をPDFから削除しました
前
以下を日本語に翻訳してください: After
上記のPDFドキュメント内の注釈は、Chromeブラウザーで表示できます。
すべての注釈を削除
特定のページ上のすべての注釈を削除するには、RemoveAllAnnotationsForPage
メソッドを使用し、ページインデックスを指定します。 ドキュメント全体の注釈をすべて削除したい場合は、AnnotationsプロパティのClear
メソッドを呼び出すだけです。
:path=/static-assets/pdf/content-code-examples/how-to/annotation-remove-all-annotation.cs
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");
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")