Python 를 통해 PDF 문서의 테이블을 관리합니다.

Python 라이브러리를 사용하여 PDF에서 테이블을 다루는 방법

Python 를 통해 테이블에서 가장 많이 사용되는 작업

Python for .NET 라이브러리를 사용하여 PDF 문서의 테이블을 관리하는 방법

테이블 작업을 위해 python-net 플랫폼을 위한 기능이 풍부하고 강력하며 사용하기 쉬운 문서 조작 API인 Aspose.PDF for .NET API를 사용할 것입니다.NuGet 패키지 관리자를 열고 Aspose.pdf를 검색하여 설치합니다.패키지 관리자 콘솔에서 다음 명령을 사용할 수도 있습니다.

Python Package Manager Console

pip install aspose-pdf

Python 를 통해 PDF에 표 추가


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

1.문서 인스턴스와 함께 PDF를 로드합니다. 1.페이지의 색인을 통해 페이지에 액세스합니다. 1.테이블 객체를 생성합니다. 1.테이블 설정을 설정합니다 (예: 테두리 설정). 1.테이블을 채웁니다. 1.테이블을 페이지에 추가합니다. 1.파일을 저장합니다.

PDF에 표 추가 - Python

    import aspose.pdf as ap

    input_file = DIR_INPUT_TABLE + "AddTable.pdf"
    output_file = DIR_OUTPUT + "document_with_table_out.pdf"
    # Load source PDF document
    doc = ap.Document(input_file)
    # Initializes a new instance of the Table
    table = ap.Table()
    # Set the table border color as LightGray
    table.border = ap.BorderInfo(ap.BorderSide.ALL, 5, ap.Color.from_rgb(apd.Color.light_gray))
    # Set the border for table cells
    table.default_cell_border = ap.BorderInfo(ap.BorderSide.ALL, 5, ap.Color.from_rgb(apd.Color.light_gray))
    # Create a loop to add 10 rows
    for row_count in range(0, 10):
        # Add row to table
        row = table.rows.add()
        # Add table cells
        row.cells.add("Column (" + str(row_count) + ", 1)")
        row.cells.add("Column (" + str(row_count) + ", 2)")
        row.cells.add("Column (" + str(row_count) + ", 3)")
    # Add table object to first page of input document
    doc.pages[1].paragraphs.add(table)
    # Save updated document containing table object
    doc.save(output_file)