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

Custom Python wrapper for PDF library integration

There are two ways to use Apryse with Python:

  • Use pip - the precompiled library for Python 3.x.

  • (less common) Use PDFNet bindings to build your own wrappers.

This guide will help you get started by building your own wrapper. You can find more information about using the precompiled library

Custom Python wrapper & macOS PDF library integration

This guide will help you run Apryse samples and integrate a free trial of the Apryse SDK into Python applications on macOS. Your free trial includes unlimited trial usage and support from solution engineers.

Prerequisites

  • Python3 or Python2 with developer extensions

  • CMake version ≥ 2.8

  • SWIG 2.0.4 - 2.0.12 or SWIG 3.0.12 or SWIG 4.0.2 and above

  • Apryse's Python3 PDF library for macOS:

curl -L -O https://downloads.apryse.com/downloads/PDFNetCMac.zip
unzip PDFNetCMac.zip

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Please contact sales to purchase a commercial key or if you need any other license key assistance.

Initial setup

  1. Make a directory to store the wrappers and navigate into that directory.

  2. Clone the PDFNet Wrappers project, select the correct branch for your release afterwards. This is typically a numbered release such as 11.11, 11.12, 11.13 and 12.0.

  1. Navigate to PDFNetWrappers/PDFNetC and move the downloaded [PDFNet C/C++ SDK] for macOS(#prerequisites) into that directory and unzip it. Ensure you obtain the right architecture for your Python interpreter. This can be done with these two commands:

  1. Now to move the headers in place, make sure you are in the PDFNetWrappers/PDFNetC directory and executeandto move the PDFNet libraries in place.You can delete PDFNetCMac.zip to free up space.Your /PDFNetC folder should be laid out like this like this:

  1. Make a build directory inside /PDFNetWrappers and navigate to it. This guide will assume the build directory is called Build.

  2. ExecuteIf all goes well, you should get a message which reads:

  1. Execute make followed by sudo make install.

  2. Next we need to fix the rpaths issue on Mac. While still in the same Build directory, execute these lines:

  1. Get your Apryse trial key.

spinner

Also check out the source for the PDFNetC wrappers here.

Run the samples

Running a specific sample

  1. Navigate to the PYTHON folder in the sample, for example /Samples/AddImageTest/PYTHON and execute ./RunTest.sh.

Run all samples

  1. To run all tests, navigate to /Samples and executeThe tests will run one by one.

Output files will be in /Samples/TestFiles/Output

Integrate into your application

This section will show you how to use our SDK to create a simple Apryse "Hello World!" application. It will create a document with one blank page and save it as a linearized PDF in its running directory.

  1. Navigate to the /Samples directory and create a new directory called myApp (if it does not exist already). This guide will assume your application is named myApp. For organization, create a new directory inside myApp called PYTHON.

  2. Navigate inside that PYTHON directory and create a new Python file called myApp.py. Open it with your favorite text editor and paste this into it:

  1. Run your application via python myApp.py. If all goes well your output should read:

Check the output.pdf that the program output in the same directory. It should be a PDF with one blank page.

Next step

GuidesSamples

Also check out the source for the PDFNetC wrappers.

Troubleshooting

Check the troubleshooting page and our PDFNetWrappers github if you run into any issues going through this document.

Custom Python wrapper & Windows PDF library integration

This guide will help you run Apryse samples and integrate a free trial of the Apryse SDK into Python applications on Windows. Your free trial includes unlimited trial usage and support from solution engineers.

Prerequisites

  • Apryse's Python PDF library for Windows:

spinner
spinner

Make sure Python, cmake and SWIG are all added to your path environment variable.

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Please contact sales to purchase a commercial key or if you need any other license key assistance.

Initial setup

  1. Extract the PDFNetWrappersWinXX folder from the .zip file. This guide will assume it has been extracted to the current user's Desktop.

  2. From the extracted folder, copy the Lib and Headers folders and paste them into PDFNetWrappers-master/PDFNetC/

  3. Create a new folder called Build inside the PDFNetWrappers folder and enter it.This is what the current directory structure should look like:

  1. Open a Command Prompt here and run the following:

This will choose a default Visual Studio version to build the projects for. Wait for the bindings to finish. The output should end with something like this:

If you see error messages during this process, see the Troubleshooting section.You should have the following files in your Build directory:

  1. Open the generated PDFNetLanguageBindings.sln with Visual Studio.

  2. Change the build mode from Debug to Release, make sure the appropriate target version (x86 or x64) is selected and build the solution.

Release configuration only

There is no Debug version of the PDFNet library available.

  1. When using the PDFNetC64 (64-bit) library files then change the build configuration to x64 in the Build dropdown by choosing Configuration Manager....Under Active Solution Platform, Select <New...> and choose x64 if x64 is not displayed as a platform.Click ok then close the modal to exit.

  2. Right-click project PDFNetPython within Solution Explorer and choose Properties.Under Linker, select Command Line and change X86 to X64.Click ok to exit the modal.

  3. Right-click and build the PDFNetPython project.This will build the Python library files.

  4. Copy the _PDFNetPython.pyd dynamic link library file to the build\lib\Release folder using the command line below or manually from Windows explorer.This will ensure the Python module which communicates through the dynamic link library can be located for installation.

  1. When this is done, select and build the INSTALL project.This will install PDFNetPython lib files to the PDFNetWrappers\PDFNetC\lib folder where it can be located by the samples.

  2. Get your Apryse trial key.

spinner

The bindings should be successfully built. You can now run the samples to test out the Apryse SDK.

Run the samples

Find and enter the Samples folder (PDFNetWrappers-master/Samples). Here you can find sample code for a large number of features supported by the Apryse SDK.

The output files from all tests are stored in Samples/TestFiles/output/

Run a specific sample

  1. Find the sample you want to run and navigate into the PYTHON folder inside.

  2. Find RunTest.bat and run it. The results should appear on a cmd window.

Run all samples

  1. Find runall_python.bat in the samples folder and double click on it to run it. The results should appear on a cmd window.

Press any key when a sample ends to start the next one.

Integrate into your application

This is what we call the "Apryse Hello World" application. It is easy to integrate the rest of Apryse SDK if you are able to open, save and close a PDFDoc.

  1. Create a new folder in Samples by the name HelloWorld.

  2. In the HelloWorld folder, create a new file called HelloWorld.py, open and edit it using your favorite text editor.

  3. Insert the following to your file:To test that your code works, run the code using a shell in the HelloWorld folder using:Once you have successfully run this, you should see an output file in the working directory of this program.

Next step

GuidesSamples

Troubleshooting

Multiple versions of Python More information for conflict resolution between multiple Python installations.

CMake Process finding incorrect version Setting specific versions of Python to use for cmake.

Custom Python wrapper & Linux PDF library integration

This guide will help you run Apryse samples and integrate a free trial of the Apryse SDK into Python applications on Linux. Your free trial includes unlimited trial usage and support from solution engineers.

Prerequisites

  • Python3 or Python2 with developer extensions

  • CMake version ≥ 2.8

  • SWIG 2.0.4 - 2.0.12 or SWIG 3.0.12 or SWIG 4.0.2 and above

  • Apryse SDK for Linux:

spinner
spinner

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Please contact sales to purchase a commercial key or if you need any other license key assistance.

Initial setup

  1. Make a directory to store the wrappers and navigate into that directory.

  2. Clone the PDFNet Wrappers project, select the correct branch for your release afterwards. This is typically a numbered release such as 11.11, 11.12, 11.13 and 12.0.

  1. Navigate to PDFNetWrappers/PDFNetC and download the PDFNet C/C++ SDK into that directory. Ensure you obtain the right architecture for your Python interpreter. For example, if your interpreter is 64bit (which this guide will assume), execute

  1. Unpack PDFNetC64.tar.gz by tar xvzf PDFNetC64.tar.gz, then executeandto move the PDFNet libraries in place.You can delete PDFNetC64.tar.gz to free up space.Your /PDFNetC folder should be laid out like this like this:

  1. Make a build directory inside /PDFNetWrappers and navigate to it. This guide will assume the build directory is called Build.

  2. ExecuteIf all goes well, you should get a message which reads:

  1. Execute make followed by sudo make install. You are now ready to run the samples or integrate Apryse SDK into your own application.

Also check out the source for the PDFNetC wrappers here.

  1. Get your Apryse trial key.

spinner

Run the samples

Running a specific sample

  1. Navigate to the PYTHON folder in the sample, for example /Samples/AddImageTest/PYTHON and execute ./RunTest.sh.

Run all samples

  1. To run all tests, navigate to /Samples and executeThe tests will run one by one.

Output files will be in /Samples/TestFiles/Output

Integrate into your application

This section will show you how to use our SDK to create a simple Apryse "Hello World!" application. It will create a document with one blank page and save it as a linearized PDF in its running directory.

  1. Navigate to the /Samples directory and create a new directory called myApp (if it does not exist already). This guide will assume your application is named myApp. For organization, create a new directory inside myApp called PYTHON.

  2. Navigate inside that PYTHON directory and create a new Python file called myApp.py. Open it with your favorite text editor and paste this into it:

  1. Run your application via python myApp.py. If all goes well your output should read:

Check the output.pdf that the program output in the same directory. It should be a PDF with one blank page.

Next step

GuidesSamples

Also check out the source for the PDFNetC wrappers.

Troubleshooting

Check the troubleshooting page and our PDFNetWrappers github if you run into any issues going through this document.

Last updated

Was this helpful?