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
pipto install third‑party Python packages, such as the Apryse SDK. The SDK is distributed as a precompiled Python library.Use
PDFNetbindings 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.
Get your Apryse trial 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.
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.
If Python and pip aren't installed, install them with Homebrew. This command installs the latest Python version with pip:
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.
In your file manager, create a Documents > NewApryseProject folder.
Open the new NewApryseProject folder in Visual Studio Code or in another code editor.
Create a
HelloWorld.pyfile 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.
Navigate to the
~/Documents/NewApryseProjectdirectory in your terminal, then install the Apryse SDK using pip to fetch the package from Apryse's package index:
A successful output looks like:
Open the
HelloWorld.pyfile in Visual Studio Code or your preferred code editor:
Add this code to the
HelloWorld.pyfile, update your license key, and save your changes:
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
PDFDocobject.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.
Go to the Documents > NewApryseProject folder, and right-click to select New Terminal at Folder.
In the terminal, run the
HelloWorld.pyscript:
A successful output looks similar to:
Go to the Documents > NewApryseProject folder using the file manager.
Verify the blank
output.pdffile was generated programmatically using the Apryse Server SDK. The folder structure looks similar to:
Prerequisites
Before you start:
Install Visual Studio Code or another code editor to develop and debug code.
Install Python 3 and pip.
Get your Apryse trial 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.
Check whether Python and pip are installed:
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.
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.
In your file manager, create a Documents > NewApryseProject folder.
Open the new NewApryseProject folder in Visual Studio Code or in another code editor.
Create a
HelloWorld.pyfile 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.
Navigate to the
\Documents\NewApryseProjectdirectory in your terminal, then install the Apryse SDK using pip to fetch the package from Apryse's package index:
A successful output looks like:
Open the
HelloWorld.pyfile in Visual Studio Code or your preferred code editor:
Add this code to the
HelloWorld.pyfile, update your license key, and save your changes:
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
PDFDocobject.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.
Go to the Documents > NewApryseProject folder, and right-click to select Open in Terminal.
In the terminal, run the
HelloWorld.pyscript:
A successful output looks similar to:
Go to the Documents > NewApryseProject folder using the file manager.
Verify the blank
output.pdffile was generated programmatically using the Apryse Server SDK. The folder structure looks similar to:
Prerequisites
Before you start:
Install Visual Studio Code or another code editor to develop and debug code.
Install Python 3 and pip.
Get your Apryse trial 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.
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.
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.
2. Set up your project
Set up your project by creating a folder and preparing your workspace for the application.
In your file manager, create a Documents > NewApryseProject folder.
Open the new NewApryseProject folder in Visual Studio Code or in another code editor.
Create a
HelloWorld.pyfile 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.
Navigate to the
~/Documents/NewApryseProjectdirectory in your terminal, then install the Apryse SDK using pip to fetch the package from Apryse's package index
A successful output looks like:
Open the
HelloWorld.pyfile in Visual Studio Code or your preferred code editor:
Add this code to the
HelloWorld.pyfile, update your license key, and save your changes:
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
PDFDocobject.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.
Go to the Documents > NewApryseProject folder, and right-click to select Open in Terminal.
In the terminal, run the
HelloWorld.pyscript:
A successful output looks similar to:
Go to the Documents > NewApryseProject folder using the file manager.
Verify the blank
output.pdffile 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
An active AWS account
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 FunctionUpload 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!
Related Blogs
Splitting a PDF Using Python - 9/11/24
Last updated
Was this helpful?