Open PDF document programmatically
Contents
[
Hide
]
Open existing PDF document
There are several ways to open a document. The easiest is to specify a file name.
import aspose.pdf as ap
def open_document_from_file(infile):
# Open document
document = ap.Document(infile)
print("Pages: " + str(len(document.pages)))
Open existing PDF document from stream
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)))
Open encrypted PDF document
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)))