Skip to main content

Product Page | Docs | Demos | API Reference | Examples | Blog | Search | Free Support | Temporary License

Aspose.PDF for Python is a robust on-premise library designed to handle a wide range of document processing tasks. This powerful tool empowers developers to enrich their applications by incorporating functionalities like document generation, modification, conversion, rendering, and printing, all without depending on external software.

PDF API Features

Aspose.PDF for Python offers a comprehensive set of features for working with PDF documents. Here are some popular features provided by the library:

  1. PDF Document Handling: Aspose.PDF for Python enables developers to create, open, modify, and save PDF documents using the associated PDF document handle. This includes tasks such as creating new PDF files, opening existing ones, and performing various operations on them.

  2. Document Page Manipulation: The library allows basic manipulation of document pages, such as adding or removing pages from the PDF document. This functionality provides flexibility in managing the structure and content of the PDF document.

  3. Advanced Page Manipulation: With Aspose.PDF for Python, developers can perform advanced manipulations on individual pages. This includes operations like rotating pages to different orientations, changing the content of pages, and adding elements like stamps or images to enhance the visual representation of the document.

  4. Export to Graphics Formats: The library provides the capability to export PDF document pages to various graphics formats. This allows developers to extract pages from PDF documents and save them as separate image files in formats like JPEG, PNG, or TIFF. This feature is particularly useful when integrating PDF content into other applications or systems that require graphics-based representations.

These features collectively empower developers to efficiently work with PDF documents in Python, offering extensive control over document creation, manipulation, and conversion to meet diverse application requirements.

Platform Independence

Aspose.PDF for Python is a versatile library that supports the development of applications across various operating systems, including Windows and Linux, as long as Python 3.5 or a later version is installed.

Get Started

Are you interested in trying out Aspose.PDF for Python?

To get started, simply run the following command in your console: pip install <insert alias here>. This will fetch the package for you. If you already have Aspose.PDF for Python and would like to upgrade to the latest version, you can use the command pip install --upgrade <insert alias here>.

To see Aspose.PDF in action, you can run the code snippets provided below in your own environment. Alternatively, you can explore the GitHub Repository or refer to the Aspose.PDF for Python Documentation for more information on common use cases.

Using Python to create blank PDF document

Aspose.PDF for Python allows you to create a new blank document:

from AsposePDFPythonWrappers import *

doc = Document()
doc.save("blank_pdf_document.pdf")

or direct with a module API:

from AsposePdfPython import *

doc = document_create()
document_save(doc, "blank_pdf_document.pdf")
close_handle(doc)

Using Python to Extract text from PDF file

Aspose.PDF for Python allows you to extract text from PDF files:

from AsposePDFPythonWrappers import *

def install_license(license_file):  
    lic = License()  
    lic.set_license(license_file)

def extract_text(pdf_file_name, save_file_name):  
    ext = PdfExtractor()  
    ext.bind_pdf(pdf_file_name)  
    ext.extract_text()  
    ext.get_text(save_file_name)

install_license("Aspose.PDF.PythonviaCPP.lic")
extract_text("pdf_file_name.pdf", "text_file_name.txt")

or direct with a module API:

from AsposePdfPython import *

def install_license(license_file):
    lic = license_create()
    license_set(lic, "Aspose.PDF.C++.lic")

def extract_text(pdf_file_name, save_file_name):
    ext = extractor_create()
    extractor_bind_pdf(ext, pdf_file_name)
    text = extractor_extract_text(ext)
    with open(save_file_name, 'w') as f:
    f.write(text)
    close_handle(ext)

install_license("Aspose.PDF.PythonviaCPP.lic")
extract_text("pdf_file_name.pdf", "text_file_name.txt")

Encrypt and Decrypt PDF document

Aspose.PDF for Python allows you to encrypt and decrypt PDF documents:

from AsposePDFPythonWrappers import *

def pdf_encrypt(pdf_file_source, user_password, owner_password, permissions:AsposePDFPython.Permissions, crypto_algorithm:AsposePDFPython.CryptoAlgorithm, pdf_file_result):  
    try:  
        doc = Document(pdf_file_source)  
        doc.encrypt(user_password, owner_password, permissions, crypto_algorithm)  
        doc.save(pdf_file_result)  
    except Exception as e:  
        print(e)  
  
def pdf_decrypt(pdf_file_source, password, pdf_file_result):  
    try:  
        doc = Document(pdf_file_source, password)  
        doc.decrypt()  
        doc.save(pdf_file_result)  
    except Exception as e:  
        print(e)

pdf_encrypt("pdf_file_name.pdf", "user_password", "owner_password", Permissions(Permissions.ExtractContent|ModifyContent), CryptoAlgorithm.AESx256, "pdf_file_result.pdf")
pdf_decrypt("pdf_file_source.pdf", "password", "pdf_file_result.pdf")

or direct with a module API:

from AsposePdfPython import *

def pdf_encrypt(pdf_file_source, user_password, owner_password, permissions:AsposePDFPython.Permissions, crypto_algorithm:AsposePDFPython.CryptoAlgorithm, pdf_file_result): 
	try:
	    doc = document_open(pdf_file_source)
	    document_encrypt_1(doc, user_password, owner_password
	    , Permissions(Permissions.ExtractContent|ModifyContent), CryptoAlgorithm.AESx256)
	    document_save(doc, pdf_file_result)
	except Exception as e:
	    print(e)

def pdf_decrypt(pdf_file_source, password, pdf_file_result):  
	try:
	    doc = document_open_encrypted(pdf_file_source, password)
	    document_decrypt(doc)
	    document_save(doc, pdf_file_result)
	except Exception as e:
	    print(e)

pdf_encrypt("pdf_file_name.pdf", "user_password", "owner_password", Permissions(Permissions.ExtractContent|ModifyContent), CryptoAlgorithm.AESx256, "pdf_file_result.pdf")
pdf_decrypt("pdf_file_source.pdf", "password", "pdf_file_result.pdf")

Merge two PDF files

Aspose.PDF for Python allows you to merge or split PDF files:

from AsposePDFPythonWrappers import *

def merge_files(pdf_file_1, pdf_file_2, result_pdf_file):  
    doc1 = Document(pdf_file_1)  
    doc2 = Document(pdf_file_2)  
    pages1 = doc1.pages  
    pages2 = doc2.pages  
    pages1.add(pages2)  
    doc1.save(result_pdf_file)

merge_files("pdf_file_1.pdf", "pdf_file_2.pdf", "result_pdf_file.pdf")

or direct with a module API:

from AsposePdfPython import *

def merge_files(pdf_file_1, pdf_file_2, result_pdf_file):  
	doc1 = document_open(pdf_file_1)
	doc2 = document_open(pdf_file_2)
	pages1 = document_get_pages(doc1)
	pages2 = document_get_pages(doc2)
	page_collection_add_pages(pages1, pages2)
	document_save(doc1, result_pdf_file)
	close_handle(doc1)
	close_handle(doc2)

merge_files("pdf_file_1.pdf", "pdf_file_2.pdf", "result_pdf_file.pdf")

Product Page | Docs | Demos | API Reference | Examples | Blog | Search | Free Support | Temporary License

Metadata

Release files for aspose-pdf-cpp-for-python 25.9.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for aspose-pdf-cpp-for-python 25.9.4
File Interpreter ABI Platform
aspose_pdf_cpp_for_python-25.9.4-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
aspose_pdf_cpp_for_python-25.9.4-py3-none-macosx_10_14_x86_64.whl Python 3 none macOS 10.14+ x86-64 Details

Total release size: 348.5 MB

Release files / aspose_pdf_cpp_for_python-25.9.4-py3-none-macosx_11_0_arm64.whl

Download URL aspose_pdf_cpp_for_python-25.9.4-py3-none-macosx_11_0_arm64.whl
Size 164.5 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4daa6e472fe8fc2d6a216b0fd3b3ffcc3a61cd2771cdd108efb5c50949e04b1e
BLAKE2b-256 checksum
How to use checksums
f336f42095fc98859228ec1d3c450a850aa4344bd8158abff4b2f33e687ecbd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / aspose_pdf_cpp_for_python-25.9.4-py3-none-macosx_10_14_x86_64.whl

Download URL aspose_pdf_cpp_for_python-25.9.4-py3-none-macosx_10_14_x86_64.whl
Size 183.9 MB
Tags Python 3 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
d99f2ff6a78d3b9d4743436050772cc142e7bfc8c59ea0acd4ddb2a25b0b4e63
BLAKE2b-256 checksum
How to use checksums
b9c0cc58060147a4dbb47662c3b3f4c6c2f636d298c34a02870b68a4ca06e81c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

25.9.4 This release

2 release files

25.9.1

4 release files

25.9

3 release files

24.7

4 release files

2.0

4 release files

1.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page