จัดการคำอธิบายประกอบใน PDF โดยใช้ Python

การจัดการคำอธิบายประกอบในเอกสาร PDFใช้ Aspose.PDF สำหรับ Python for .NET เพื่อแก้ไขไฟล์ PDF แบบโปรแกรม

Aspose.PDF for Python for .NET Logo

วิธีจัดการคำอธิบายประกอบโดยใช้ไลบรารี Python

ในการเพิ่มคำอธิบายประกอบข้อความในไฟล์ PDF เราจะใช้ Aspose.PDF for .NET API ซึ่งเป็น API การจัดการเอกสารที่อุดมไปด้วยคุณสมบัติ ทรงพลัง และใช้งานง่ายสำหรับแพลตฟอร์ม python-netเปิดตัวจัดการแพคเกจ NuGet ค้นหาAspose.PDF และติดตั้งคุณอาจใช้คำสั่งต่อไปนี้จากคอนโซลตัวจัดการแพคเกจ

Console

pip install aspose-pdf

สร้างคำอธิบายประกอบในเอกสาร PDF ผ่าน Python


คุณต้อง Aspose.PDF for Python ผ่าน.NET เพื่อลองใช้รหัสในสภาพแวดล้อมของคุณ

1.โหลด PDF ในอินสแตนซ์ของคลาสเอกสาร 1.สร้างคำอธิบายประกอบที่คุณต้องการเพิ่มใน PDF 1.เพิ่มคำอธิบายประกอบลงในคอลเลกชันคำอธิบายประกอบของวัตถุหน้า 1.บันทึกไฟล์ PDF

คำอธิบายประกอบข้อความ PDF - Python

Example: Python

import aspose.pdf as apdf

from os import path

path_infile = path.join(self.data_dir, infile)
path_outfile = path.join(self.data_dir, outfile)

document = apdf.Document(path_infile)

appearance = apdf.annotations.DefaultAppearance()
appearance.font_size = 12
appearance.font_name = "Arial"

freeTextAnnotation = apdf.annotations.FreeTextAnnotation(
    document.pages[1],
    apdf.Rectangle(299.988, 703.664, 508.708, 720.769, True),
    appearance
)
freeTextAnnotation.contents = "This is a free text annotation."
freeTextAnnotation.name = "FreeText1"
freeTextAnnotation.subject = "Revision 01"
freeTextAnnotation.title = "Free Text Annotation"
freeTextAnnotation.popup = apdf.annotations.PopupAnnotation(
    document.pages[1], apdf.Rectangle(299.988, 713.664, 308.708, 720.769, True)
)
freeTextAnnotation.popup.open = True
document.pages[1].annotations.add(freeTextAnnotation, consider_rotation=False)
document.save(path_outfile)