For the complete documentation index, see llms.txt. This page is also available as Markdown.

Build a Python PDF library app with Apryse Server SDK

This get-started guide explains how to set up your Python environment and install and use the Apryse Server SDK in a Python application. We'll demonstrate how to build a simple app for programmatic PDF generation.

There are two ways to use Apryse with Python:

  • Use pip to install third‑party Python packages, such as the Apryse SDK. The SDK is distributed as a precompiled Python library.

  • Use PDFNet bindings to build your own custom Python wrapper (less common).

This guide walks you through getting started with the precompiled Python SDK using pip.

Choose your preferred platform from these tabs.

Prerequisites

Before you start:

  • Install Visual Studio Code or another code editor to develop and debug code.

  • Install Python 3 and pip. In this guide, we use Homebrew to manage the Python installation.

  • Get your Apryse trial key.

spinner

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.

1. Set up Python and pip

Before getting started, ensure that Python and pip are installed. You’ll use pip to install the Apryse Server SDK.

Info

macOS includes a system‑managed Python used by the operating system. For development, install Python via Homebrew and use it inside a virtual environment.

  1. Check whether Python and pip are installed:

The python3 path should point to Homebrew (for example, /opt/homebrew/bin/python3 or /usr/local/bin/python3). If it points to /usr/bin/python3, you're using the system Python.

  1. If Python and pip aren't installed, install them with Homebrew. This command installs the latest Python version with pip:

  1. If Python and pip are installed with Homebrew, update Homebrew and Python. This also updates pip:

2. Set up your project

Set up your project by creating a folder and preparing your workspace for the application.

  1. In your file manager, create a Documents > NewApryseProject folder.

  2. Open the new NewApryseProject folder in Visual Studio Code or in another code editor.

  3. Create a HelloWorld.py file at the root of your project.

3. Add the Apryse SDK

Next, integrate the Apryse Server SDK into your Python application and add the code needed to generate a PDF.

  1. Navigate to the ~/Documents/NewApryseProject directory in your terminal, then install the Apryse SDK using pip to fetch the package from Apryse's package index:

Info

Install the Apryse SDK in a virtual environment to ensure it's isolated and installed in a predictable location. When running Python scripts that import apryse-sdk, make sure you activate the same virtual environment first.

A successful output looks like:

Info

The legacy PDFNetPython3 package on the default Python Package Index (PyPI) is no longer maintained.

  1. Open the HelloWorld.py file in Visual Studio Code or your preferred code editor:

  1. Add this code to the HelloWorld.py file, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import and initialize the Apryse Python SDK using your license key.

  • Create a new PDF document and add a blank page.

  • Save the document as a linearized PDF for optimized viewing.

  • Perform document operations using the PDFNet API—in this case, creating and modifying a PDFDoc object.

  • Close the document after saving.

4. Verify your output

Finally, build and run your application to confirm that the Apryse Server SDK is working correctly. After the application runs successfully, it will generate a blank PDF file locally.

  1. Go to the Documents > NewApryseProject folder, and right-click to select New Terminal at Folder.

  2. In the terminal, run the HelloWorld.py script:

A successful output looks similar to:

  1. Go to the Documents > NewApryseProject folder using the file manager.

  2. Verify the blank output.pdf file was generated programmatically using the Apryse Server SDK. The folder structure looks similar to:

Prerequisites

Before you start:

spinner

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.

1. Set up Python and pip

Before getting started, ensure that Python and pip are installed. You’ll use pip to install the Apryse Server SDK.

  1. Check whether Python and pip are installed:

  1. If Python and pip aren't installed, download any supported Python 3 version and run the installer from your Downloads folder. During installation:

  • Use admin privileges.

  • Select Add Python to PATH.

  • Enable pip and venv.

  1. If Python and pip are installed, run the following command to update:

2. Set up your project

Set up your project by creating a folder and preparing your workspace for the application.

  1. In your file manager, create a Documents > NewApryseProject folder.

  2. Open the new NewApryseProject folder in Visual Studio Code or in another code editor.

  3. Create a HelloWorld.py file at the root of your project.

3. Add the Apryse SDK

Next, integrate the Apryse Server SDK into your Python application and add the code needed to generate a PDF.

  1. Navigate to the \Documents\NewApryseProject directory in your terminal, then install the Apryse SDK using pip to fetch the package from Apryse's package index:

Info

Install the Apryse SDK in a virtual environment to ensure it's isolated and installed in a predictable location. When running Python scripts that import apryse-sdk, make sure you activate the same virtual environment first.

A successful output looks like:

Info

The legacy PDFNetPython3 package on the default Python Package Index (PyPI) is no longer maintained.

  1. Open the HelloWorld.py file in Visual Studio Code or your preferred code editor:

  1. Add this code to the HelloWorld.py file, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import and initialize the Apryse Python SDK using your license key.

  • Create a new PDF document and add a blank page.

  • Save the document as a linearized PDF for optimized viewing.

  • Perform document operations using the PDFNet API—in this case, creating and modifying a PDFDoc object.

  • Close the document after saving.

4. Verify your output

Finally, build and run your application to confirm that the Apryse Server SDK is working correctly. After the application runs successfully, it will generate a blank PDF file locally.

  1. Go to the Documents > NewApryseProject folder, and right-click to select Open in Terminal.

  2. In the terminal, run the HelloWorld.py script:

A successful output looks similar to:

  1. Go to the Documents > NewApryseProject folder using the file manager.

  2. Verify the blank output.pdf file was generated programmatically using the Apryse Server SDK. The folder structure looks similar to:

Prerequisites

Before you start:

spinner

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.

1. Set up Python and pip

Before getting started, ensure that Python and pip are installed. You’ll use pip to install the Apryse Server SDK. We used Ubuntu 25.10 to create this guide.

  1. Check whether Python and pip are installed:

On Ubuntu, /usr/bin/python3 is the system Python installed via the Advanced Package Tool (apt) package manager. This is expected and safe to use on Ubuntu systems.

  1. If Python and pip aren't installed, or you want to ensure they're up-to-date, run:

The commands install Python 3, pip, and the venv module if they aren't already installed, and update them to the latest versions provided by Ubuntu.

Info

On most Ubuntu systems, the universe repository is already enabled. If a package cannot be found, you may need to enable it.

2. Set up your project

Set up your project by creating a folder and preparing your workspace for the application.

  1. In your file manager, create a Documents > NewApryseProject folder.

  2. Open the new NewApryseProject folder in Visual Studio Code or in another code editor.

  3. Create a HelloWorld.py file at the root of your project.

3. Add the Apryse SDK

Next, integrate the Apryse Server SDK into your Python application and add the code needed to generate a PDF.

  1. Navigate to the ~/Documents/NewApryseProject directory in your terminal, then install the Apryse SDK using pip to fetch the package from Apryse's package index

Info

Install the Apryse SDK in a virtual environment to ensure it's isolated and installed in a predictable location. When running Python scripts that import apryse-sdk, make sure you activate the same virtual environment first.

A successful output looks like:

Info

The legacy PDFNetPython3 package on the default Python Package Index (PyPI) is no longer maintained.

  1. Open the HelloWorld.py file in Visual Studio Code or your preferred code editor:

  1. Add this code to the HelloWorld.py file, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import and initialize the Apryse Python SDK using your license key.

  • Create a new PDF document and add a blank page.

  • Save the document as a linearized PDF for optimized viewing.

  • Perform document operations using the PDFNet API—in this case, creating and modifying a PDFDoc object.

  • Close the document after saving.

4. Verify your output

Finally, build and run your application to confirm that the Apryse Server SDK is working correctly. After the application runs successfully, it will generate a blank PDF file locally.

  1. Go to the Documents > NewApryseProject folder, and right-click to select Open in Terminal.

  2. In the terminal, run the HelloWorld.py script:

A successful output looks similar to:

  1. Go to the Documents > NewApryseProject folder using the file manager.

  2. Verify the blank output.pdf file was generated programmatically using the Apryse Server SDK. The folder structure looks similar to:

This guide will help you set up Apryse SDK serverless AWS Lambda functions. Your free trial includes unlimited trial usage and support from solution engineers.

Prerequisites

Initial setup

In this particular guide, we will demonstrate how to set up an AWS Lambda function to use Apryse SDK.

First, prepare a zip package with apryse-sdk embedded and your lambda_function.py.

From the command line, check your Python3 version. This information will be needed when you create your function later.

From the command line:

Copy your lambda source (i.e. lambda_function.py) to YOUR_FUNCTION_FOLDER. Then zip your package before uploading it to your AWS Lambda account.

You can now upload YOUR_FUNCTION_FOLDER.zip to your AWS Lambda.

Second, create a lambda function in your AWS account and upload the zip package:

  • Lambda > Functions > Create function > Author from scratch > Function name [YOUR_FUNCTION_NAME] > Runtime [Python3.x] (Choose the version that matches your Python3 version from the checking above.) > choose Create Function

  • Upload from .zip file > Upload [your zip package] > Save

  • Add triger > API Gateway > Create an API > REST > Security [Open]

  • Configuration > General configuration > Edit > memory [Choose 10240MB]

Integrate into your application

Once you have followed the initial setup instructions, you can begin calling Apryse SDK APIs in your lambda function source. For example:

Run Sample Code

You can update python script of your AWS Lambda function with the following code or download the source code from our github respository. This snippet shows how to process a request sent from a client to convert an office document to PDF and send the output to client.

Testing

After you have uploaded your zip package to your AWS Lambda function and get its API endpoint in Configuration > Triggers, you can now do a simple test using REST API.

In order to use this function to convert an office document to PDF, the client needs to post a REST API request to the server. The request must include json data structured as in the code below.

Upon receiving a client's request, a response will be sent back to the client including the base64 encoded pdf output using the same json structure. All the client needs to do now is decode the encoded data into pdf. That's it! Access the sample python code. After cloning the repository and installing necessary packages, please refer to /client/README.txt for detailed instructions. Navigate to the client folder, run the following command, and see the reponse to client's request in the console and check the output in the output folder:

The client will send a REST API request to convert /input/simple-word_2007.docx to pdf and the server will send back the encoded data, which will then be saved as pdf in the output folder.

You can experiment with your own office document by putting it inside input folder:

We have shown how to set an AWS Lambda function using Apryse SDK. You can now experiment making your own functions, URLs, and can fully utilize Apryse SDK. If your have any questions, please don't hesitate to contact us!


Last updated

Was this helpful?