PDF 양식.Python 를 통해 관리

Python via .NET 라이브러리용 Aspose.PDF 라이브러리를 사용하여 PDF 문서의 아크로폼 관리

Python via .NET 라이브러리를 사용하여 PDF 양식을 관리하는 방법

PDF 파일에 PDF 양식 (아크로폼) 을 추가하려면 python-net 플랫폼을 위한 기능이 풍부하고 강력하며 사용하기 쉬운 문서 조작 API인 Aspose.PDF for .NET API를 사용하겠습니다.NuGet 패키지 관리자에서 직접 최신 버전을 다운로드하고ASpose.pdf를 검색하여 설치할 수 있습니다.패키지 관리자 콘솔에서 다음 명령을 사용할 수도 있습니다.

Console

pip install aspose-pdf

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

사용자 환경에서 코드를 시험해 보려면 Aspose.PDF via .NET을 통한 파이썬용 이 필요합니다.

  1. 문서 클래스의 인스턴스에서 PDF를 로드합니다.
  2. 페이지의 색인을 통해 페이지에 액세스합니다.
  3. Form 컬렉션의 Add 메서드를 호출합니다.
  4. 추가하려는 양식 필드를 생성합니다.
  5. 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)