註解
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 文件中,允許您將評論、檢閱筆記或元資料附加到頁面上的特定位置。

入門指南

載入或建立一個Annotations集合中,然後保存。

理解程式碼

  • TextAnnotation(pageIndex):建立一個針對指定的以零為基礎頁面索引的新註釋。
  • Title:註釋彈出窗口的主要標題文字。
  • Subject:註釋的副標題或次要標題。
  • Contents:註釋的正文 - 主要的評論或筆記內容。
  • Icon:頁面上顯示的視覺圖示。 選項包括Help, Note, Comment, Key, 以及從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剛剛發布