Python aracılığıyla PDF Formları oluşturun

Python for .NET Kütüphanesi için Aspose.PDF kullanarak programlı olarak PDF’de akroformlar oluşturun

Python kullanarak PDF formları nasıl oluşturulur

PDF dosyasında PDF Formları (Acroforms) oluşturmak için, C# platformu için zengin özelliklere sahip, güçlü ve kullanımı kolay bir belge işleme API’si olan .NET için Aspose.PDF API’sini kullanacağız. NuGet paket yöneticisini açın, Aspose.PDF öğesini arayın ve yükleyin. Paket Yöneticisi Konsolu’ndan aşağıdaki komutu da kullanabilirsiniz.

Python kullanarak PDF’de AcroForm Nasıl Oluşturulur


Kodu ortamınızda denemek için Aspose.PDF for .NET gerekir.

  1. PDF’yi Document sınıfının bir örneğinde yükleyin.
  2. Bir alan oluşturun.
  3. Süslemeler oluşturun (Sınır gibi).
  4. Belgeye alan ekleyin ve değiştirilmiş PDF’yi kaydedin

PDF'de PDF Formları Oluşturun - Python

Bu örnek kod, Python kullanarak PDF'de PDF Formlarının nasıl oluşturulacağını gösterir

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)