프로그래밍 방식으로 PDF 문서 열기

기존 PDF 문서 열기

문서를 여는 방법에는 여러 가지가 있습니다.가장 쉬운 방법은 파일 이름을 지정하는 것입니다.

import aspose.pdf as ap

def open_document_from_file(infile):

    # Open document
    document = ap.Document(infile)
    print("Pages: " + str(len(document.pages)))

스트림에서 기존 PDF 문서 열기

import aspose.pdf as ap
import io

def open_document_from_stream(infile):
    with io.FileIO(infile, "r") as stream:
        # Open document
        document = ap.Document(stream)
        print("Pages: " + str(len(document.pages)))

암호화된 PDF 문서 열기

import aspose.pdf as ap

def open_document_encrypted(infile):
    password = "P@ssw0rd"
    # Open document
    document = ap.Document(infile, password)
    print("Pages: " + str(len(document.pages)))