Get Started with the Apryse Server SDK Python 3 PDF Library Integration

The Apryse Server SDK is cross-platform and supported on Windows, Linux, and macOS. The base package is robust, allowing you to programmatically do the following with PDFs:

Additional functionality

If you’re looking for additional capabilities, we offer add-on packages, such as Smart Data Extraction, and add-on modules, such as Office Conversion. For a complete list of add-ons, refer to the following:

Solutions and benefits

Using the Server SDK allows you to build server-side document processing solutions at scale without relying on client devices or cloud APIs. Since the Server runs entirely on-premises (or in your private cloud), you can ensure security and compliance with full control over access, storage, and encryption. You can also easily integrate with web apps, backend systems, document management systems, and content workflows.

Steps and samples

This guide walks you through steps to work through samples we give you, create a project, and integrate the Apryse Server SDK free trial into your project. We’ll use a Python project as our example project throughout this guide. By the end, you’ll have run through at least one sample, created a project, and built an "Apryse Hello World" within your application.

How to use Apryse with Python

There are two ways to use Apryse with Python:

  • Use pip3 which installs third party Python packages (for example, the Apryse SDK for Python 3). It’s the precompiled library for Python 3.x.
  • Use PDFNet bindings to build your own wrappers (less common).

This guide will get you started using the precompiled Python for 3.x through pip3.

Choose your preferred platform from the tabs below.

Precompiled Python3 and Linux PDF library integration 

You'll install or update pip3 and Python 3, then get started with our samples to see the output you can create when you integrate the Apryse Server SDK into your application. Last, you'll create a project and integrate the Server SDK into your Python 3 application, all while using the Linux platform.

Prerequisites

Before you start:

  • Install Visual Studio Code (or your preferred application) to write, edit, and debug source code.
  • Get your Apryse trial key.

License Key

Apryse collects some data regarding your usage of the SDK for product improvement.

If you wish to continue without data collection, contact us and we will email you a no-tracking trial key for you to get started.

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.

Keep your commercial license key confidential.

License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).

1. Install/Update Python 3 and pip3

You’ll need Python 3 on your system. You’ll need pip3 to eventually install the Apryse Server SDK.

We used Ubuntu, version 25.10, for creating this guide.

  1. Check to see if Python 3 and pip3 are installed on your system:

sh

1python3 --version
2python3 -m pip –version

2. Complete one of the following based on whether pip3 and Python3 are already installed:

  • OPTION 1: Install Python 3 and pip3 if they’re not installed.
    • To download Python 3, go to the Python home page, hover over Downloads at the top of the page, then select the file you need based on your operating system and device processor. You can use any Python 3 version that’s supported.
    • To install pip3 from the command line:
      • Install pip3 to your package lists:

sh

1sudo apt update
  • Enable the universe repository, if not already enabled:

sh

1sudo add-apt-repository universe
2sudo apt update
  • Install pip3:

sh

1sudo apt install python3-pip
  • OPTION 2: Update Python 3 and pip3 if there are versions already installed on your device:
    • Add the following to the command line:

sh

1sudo apt install python3 python3-pip

2. Run a sample

You’ll download and run the OfficeToPDFTest sample which allows you to explore and validate the conversion features offered by the SDK. By running the sample, you can quickly:

  •  Verify the capabilities.
  • Understand how to interact with the MS Office to Conversion PDF API.
  • Use it as a reference for integrating similar functionality into your own application.
  1. Download the tarball file for Linux file which includes all of the Apryse samples.
  2. Use your Linux file explorer to navigate to the Downloads folder, right-click on the tar.gz tarball file, then select Extract to...
  3. Select Home, New Folder, then enter ApryseSamples, and click Create to create a new folder to extract the tarball file into for running the samples. You can create a folder at a different location if you prefer, but for this guide’s instructions, we used the location and name above.
  4. Select the new folder you created, then click the Select button to cause the file to extract to your new folder.

The ApryseSamples folder is created and the tarball is extracted to the folder.

5. Navigate to the folder /Home/ApryseSamples/PDFNetPython3/Samples/OfficeToPDFTest/Python, right-click on the Python folder, then select Open in Terminal.

6. The Linux terminal opens to the directory you specified. On the command line, enter the following, then press Enter to install the apryse-sdk library from Apryse’s S3 private repository (You need this to run samples successfully):

The PDFNet Python 3 library from the default Python Package Index (PyPI) is not used in the code below because it’s no longer being updated. You’ll use the Apryse PyPI instead in the code.

sh

1python3 -m pip install apryse-sdk --extra-index-url=https://pypi.apryse.com

or

sh

1pip3 install install apryse-sdk --extra-index-url=https://pypi.apryse.com

If no errors occur, Successfully installed apryse-sdk ... will display in terminal.

7. Navigate via your Linux file explorer to /Home/ApryseSamples/PDFNetPython3/Samples/LicenseKey/Python/LicenseKey.py and double-click to open so you can add your license key to the LicenseKey.py file before running the sample.

8. Scroll down to the line containing ‘LicenseKey = “YOUR_PDFTRON_LICENSE_KEY” and replace the words in quotes with the copy of your trial license key. Leave the ‘if LicenseKey ==YOUR_PDFTRON_LICENSE_KEY’ as is with its default text.

9. Save your changes and close the file.

10. To run the sample, navigate, through the Linux file explorer, to /Home/ApryseSamples/PDFNetPython3/Samples/OfficeToPDFTest/Python, right-click on the Python folder, then select Open in Terminal.

11. The Linux terminal opens the OfficeToPDFTest sample. From the project directory, on the command line, enter the following, then press Enter:

sh

1sh RunTest.sh

When you run the sh RunTest.sh command, the sample code loads an Office document, converts the Office document to PDF, saves the resulting PDF, and outputs status messages to the console. For more details, you can look at additional OfficeToPDF sample code and the Convert MS Office (Word, Excel, PowerPoint) to PDF overview.

Once the sample finishes running, you'll see the status Done in the terminal.

12. At the command prompt, type Exit, then press Enter.

13. Go to your Linux file explorer and navigate to: /Home/ApryseSamples/PDFNetPython3/Samples/TestFiles/Output. You will see three output PDF files (Fisherman.pdf, the_rime_of_the_ancient_mariner.pdf, and the factsheet_Arabic.pdf).

14. Open the PDF files to see the converted output. You have successfully run the OfficeToPDFTest conversion sample!

3. Create a new project

Next, you’ll create your own Python 3 project and add the Apryse Server SDK so you can later integrate the Apryse Server SDK into the project and run it.

  1. In your Linux file explorer, navigate to the Home folder, and select New Folder. Alternatively, press CTRL + Shift + n to display the New Folder modal.
  2. Enter the folder name, NewApryseProject, then click Create.
  3. Navigate to the folder /Home/NewApryseProject, right-click on the folder, then select Open in Terminal.
  4. The Linux terminal opens to the directory you specified. On the command line, enter the following, then press Enter to install the apryse-sdk library from Apryse’s S3 private repository (You need this to run your project successfully):

The PDFNet Python 3 library from the default Python Package Index (PyPI) is not used in the code below because it’s no longer being updated. You’ll use the Apryse PyPI instead in the code.

sh

1python3 -m pip install apryse-sdk --extra-index-url=https://pypi.apryse.com

or

sh

1pip3 install install apryse-sdk --extra-index-url=https://pypi.apryse.com

If no errors occur, Successfully installed apryse-sdk ... will display in terminal.

4. Integrate the Apryse Server SDK into your application

Next, you’ll open a blank PDF page within your application.

  1. Open Visual Studio Code (or your preferred application) and from the File menu, select Open Folder.
  2. Navigate to the Home folder from Linux file explorer, then, select the NewApryseProject folder and click Open.

The NewApryseProject opens in Visual Studio Code.

3. Create a file in the project named HelloWorld.py.

4. Copy the following Python code and paste it into Line 1 of the HelloWorld.py file, then Save your file.

Python

1# You can add the following line to integrate apryse-sdk
2# into your solution from anywhere on your system so long as
3# the library was installed successfully via pip
4from apryse_sdk import *
5def main():
6 # You need to initialize the PDFNet library
7 # Before calling any PDF related methods
8 PDFNet.Initialize("YOUR_LICENSE_KEY")
9 # This example creates a new document
10 # and a new page, then adds the page
11 # in the page sequence of the document
12 doc = PDFDoc()
13 page1 = doc.PageCreate()
14 doc.PagePushBack(page1)
15 # We save the document in a linearized
16 # format which is the most popular and
17 # effective way to speed up viewing PDFs
18 doc.Save(("linearized_output.pdf"), SDFDoc.e_linearized)
19 doc.Close()
20if __name__ == "__main__":
21 main()

Keep in mind the following about the code above:

  • You’re importing the Apryse SDK.
  • You’re initializing PDFNet using your Apryse license key. Scroll down to the line containing PDFNet.Initialize(“YOUR_LICENSE_KEY”); and replace the words in quotes with the copy of your trial license key. If you’re logged in to Apryse.com, your license key will automatically replace YOUR_LICENSE_KEY in the code above.
  • You’re doing various work with PDFNet. In this case, with a PDFDoc object.
  • You’re calling PDF.Terminate which releases any resources in use.

5. To test that your code works, run the script in the folder containing HelloWorld.py in the command prompt, then press Enter.

sh

1python3 -u HelloWorld.py

The code executes and you will see PDFNet is running in demo mode.

6. Exit out of the command line and navigate to the Home/NewApryseProject folder from Linux file explorer.

7. Open the linearized_output.pdf which you created by integrating the Apryse Server SDK!

8. Now that you have successfully run an OfficeToPDFTest sample and integrated the Apryse Server SDK Python PDF Library into your application, you can try out 50+ samples depending on your needs.

9. To try additional samples, go to section 2. Run a sample > Step 5 above and choose a different sample to run with a different URL path.

Additional modules are required for some samples functionality, for example, OCR, CAD and PDF to Office. You can get these from our additional module downloads page.

Related Blogs

How to Build Optical Character Recognition (OCR) in Python - 1/16/25

Splitting a PDF Using Python - 9/11/24

PDF to Office Document Conversion Using Apryse and Python - 4/4/24

Generating Documents and Reports from DOCX Templates and JSON using Apryse and Python - 10/9/23

A Guide to PDF Data Extraction Using Apryse SDK and Python - 7/20/23

Adding a Digital Signature to a PDF With the Python SDK - 7/13/23

How to Extract Text from a PDF Using Python - 12/9/22

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales