アノテーション
from ironpdf import *

# Load an existing PDF or create a new one
pdf = PdfDocument("existing.pdf")

pageIndex = 0

# Create a TextAnnotation object
annotation = TextAnnotation(pageIndex)
annotation.Title = "This is the major title"
annotation.Subject = "This is a subtitle"
annotation.Contents = "This is the long 'sticky note' comment content..."
annotation.Icon = TextAnnotation.AnnotationIcon.Help
annotation.X = 150
annotation.Y = 200
annotation.Width = 200
annotation.Height = 50
annotation.Opacity = 0.9
annotation.Printable = False
annotation.Hidden = False
annotation.OpenByDefault = True
annotation.ReadOnly = False
annotation.Rotatable = True

# Add the annotation to a specific page and location within the PDF
pdf.Annotations.Add(annotation)

# Save the PDF
pdf.SaveAs("existing.pdf")
pip install ironpdf
アノテーション

アノテーション

IronPDF for Pythonは、インタラクティブなテキストの注釈をPDFドキュメントに追加することができ、ページの特定の場所にコメント、レビューのメモ、またはメタデータを添付できます。

開始方法

??oading or creating aAnnotationsコレクションに追加して、保存します。

コードの理解

  • TextAnnotation(pageIndex):特定のゼロベースページインデックスをターゲットとする新しい注釈を作成します。
  • Title:注釈ポップアップの主ヘッダー本文テキスト。
  • Subject:注釈のサブタイトルまたは副見出し。
  • Contents:注釈の本体文 - メインコメントまたはノート内容。
  • Icon:ページ上に表示される視覚的アイコン。 オプションにはTextAnnotation.AnnotationIconからの他のオプションもあります。
  • X / Y:ページ上の注釈アンカーポイントの位置をポイント単位で指定。
  • Width / Height:注釈ポップアップボックスの寸法。
  • Opacity:注釈の透明度を0.0から1.0までの値で制御します。
  • False時に、注釈は印刷出力に含まれません。
  • False時に注釈はPDFビューアで表示されます。
  • True時に、PDFが最初に表示されたときに注釈ポップアップが開かれます。
  • False時に、ユーザーはPDFビューアで注釈を編集できます。
  • True時に、ユーザーは注釈を回転できます。
  • pdf.Annotations.Add(annotation):設定された注釈をドキュメントに追加します。

準備はできましたか?

バージョン:2026.11リリースされたばかり