Some test text!

Search
Hamburger Icon

Python / Guides / Python 2.x

Get started with Python2

Welcome to Apryse. Python2 for the Apryse SDK is supported on Windows, Linux and macOS and has precompiled wrappers available. To get started, choose your preferred platform from the tabs below.

Precompiled Python & 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.

There are two ways to use Apryse with Python:

  • Use the precompiled library for Python 2.7.
  • Use PDFNet bindings to build your own wrappers.

This guide will help you get started using the precompiled Python wrappers.

Prerequisites

  • Python 2.7.

    If you have multiple Python versions installed see the Troubleshooting.

  • Apryse's PDF library for Python on Windows:

Download the SDK

Download the SDK

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).

Initial setup

  1. Make sure that Python 2.7 has been added to your path environment variable and that the executable name is python.exe.

  2. Extract PDFNetWrappersWin64.zip or PDFNetWrappersWin32.zip.

  3. Get your Apryse trial 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 the samples

Find and enter the Samples folder. Here you can find sample code for a large number of features supported by the Apryse SDK.

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.

AddImageOutput

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.

AddImageTest output

Integrate into your application

This is called 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:

    # You can use the following two lines to use PDFNetPython
    # in your solution from anywhere on your system
    # so long as you have relative path
    import site
    site.addsitedir("../../Lib")
    import sys
    
    # This is the most important packages to import
    # for basic document manipulation.
    from PDFNetPython import *
    
    def main():
    
        # You need to initialize the PDFNet library 
        # Before calling any PDF related methods
        PDFNet.Initialize("YOUR_APRYSE_LICENSE_KEY")
    
        # This example creates a new document
        # and a new page, then adds the page
        # in the page sequence of the document
        doc = PDFDoc()
    
        page1 = doc.PageCreate()
        doc.PagePushBack(page1)
    
        # We save the document in a linearized
        # format which is the most popular and 
        # effective way to speed up viewing PDFs
        doc.Save(("linearized_output.pdf"), SDFDoc.e_linearized)
    
        doc.Close()
    
    if __name__ == "__main__":
        main()

    To test that your code works, run the code using a shell in the HelloWorld folder using:

    python.exe -u HelloWorld.py

    Once you have successfully run this, you should see an output file in the working directory of this program.

Next step

Guides Samples

Troubleshooting

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

Get the answers you need: Chat with us