Python 를 통해 PDF 양식 작성

Python for .NET 라이브러리용 Aspose.PDF 라이브러리를 사용하여 프로그래밍 방식으로 PDF로 아크로폼 생성

Python 를 사용하여 PDF 양식을 만드는 방법

PDF 파일로 PDF 양식 (아크로폼) 을 만들려면 기능이 풍부하고 강력하며 사용하기 쉬운 C# 플랫폼용 문서 조작 API인 Aspose.PDF for .NET API를 사용하겠습니다.NuGet 패키지 관리자를 열고 ASpose.pdf를 검색하여 설치합니다.패키지 관리자 콘솔에서 다음 명령을 사용할 수도 있습니다.

Python 를 사용하여 PDF로 아크로폼을 만드는 방법


사용자 환경에서 코드를 테스트하려면 Aspose.PDF for .NET 이 필요합니다.

  1. 문서 클래스의 인스턴스에서 PDF를 로드합니다.
  2. 필드 만들기.
  3. 장식 만들기 (예: 테두리)
  4. 문서에 필드 추가 및 수정된 PDF 저장

PDF로 PDF 양식 만들기 - Python

이 샘플 코드는 Python 를 사용하여 PDF로 PDF 양식을 만드는 방법을 보여줍니다.

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)