สร้างแบบฟอร์ม PDF ผ่าน Python

สร้าง acroform ใน PDF โดยใช้โปรแกรมโดยใช้ Aspose.PDF สำหรับไลบรารี Python for .NET

วิธีสร้างแบบฟอร์ม PDF โดยใช้ Python

เพื่อที่จะสร้างรูปแบบ PDF (Acroforms) ในไฟล์ PDF เราจะใช้ Aspose.PDF for .NET API ซึ่งเป็นคุณลักษณะที่อุดมไปด้วยที่มีประสิทธิภาพและใช้งานง่ายต่อการใช้การจัดการเอกสาร API สำหรับ C# แพลตฟอร์มเปิดตัวจัดการแพคเกจ NuGet ค้นหาaspose.pdf และติดตั้งนอกจากนี้คุณยังอาจใช้คำสั่งต่อไปนี้จากคอนโซลการจัดการแพคเกจ

วิธีการสร้าง AcroForm ในรูปแบบ PDF โดยใช้ Python


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

  1. โหลด PDF ในอินสแตนซ์ของคลาสเอกสาร
  2. สร้างเขตข้อมูล
  3. สร้างการตกแต่ง (เช่น เส้นขอบ)
  4. เพิ่มฟิลด์ลงในเอกสารและบันทึก PDF ที่แก้ไขแล้ว

สร้างแบบฟอร์ม PDF ในรูปแบบ PDF - Python

ตัวอย่างโค้ดนี้จะแสดงวิธีการสร้างฟอร์ม PDF ในรูปแบบ PDF โดยใช้ 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)

# Create a new text box field
rectange = apdf.Rectangle(100, 100, 200, 120, True)
textBoxField = apdf.forms.TextBoxField(document.pages[1], rectange)
textBoxField.partial_name = "textbox1"
textBoxField.value = "Text Box"

# Customize the border of the text box field
border = apdf.annotations.Border(textBoxField)
border.width = 3
border.dash = apdf.annotations.Dash(1, 1)
textBoxField.border = border

# Set the color of the text box field
textBoxField.color = apdf.Color.dark_green

# Add the text box field to the form
document.form.add(textBoxField, 1)

# Save the modified PDF document
document.save(path_outfile)