Get Started with the Apryse Server SDK Java PDF Library Integration

Built for developers, the Apryse Server SDK is expansive, cross-platform, and fully supported on Windows, Linux, and macOS. Start programmatically handling core PDF functions server-side:

  • View
  • Annotate
  • Flatten
  • Extract
  • Search
  • Build forms
  • Support layers
  • Page manipulation
  • Semantic text comparison
  • PDF/A conversion and validation
  • Use digital signatures
  • Redact
  • PDF editing
  • Accessibility and auto-tagging
  • Generate templates
  • Smart Data Extraction
  • Add security
  • Use OCR
  • Document conversion, including Office and CAD conversion

Based on the add-ons you’ve purchased, you’ll need to download the associated modules to support the functionality.

Solutions & benefits

Achieve scalable document automation without dependency on client-side tools or third-party cloud services. The Apryse Server SDK runs seamlessly on-premises or in your private cloud, granting you full control over access, encryption, and storage for maximum security and compliance. This enterprise-grade tool is designed for easy integration with your web apps, backend systems, and existing document management and content workflows. Power your solutions at scale with a trusted, controlled server-side document engine. 

Steps & samples

This guide walks you through steps to integrate the Apryse Server SDK free trial into your project. We’ll use a Java project as our example project throughout this guide. By the end, you’ll have built an "Apryse Hello World" within your application and be able to open, save, and close a PDF Doc.

To get started, choose your preferred platform from the tabs below.

Linux Java PDF library integration

You'll get started with our samples to see the output you can create when you integrate the Apryse Server SDK into your Java projects. Next, you'll create a project and integrate the Server SDK into your Java project, using the Linux platform.

Prerequisites

Before you start:

  • Install Visual Studio Code (or your preferred application) to write, edit, and debug source code.
  • If you’re using VS Code, install the “Extension Pack for Java” and the “vscode-pdf” extensions that are available in the “Extensions: Marketplace” tab within VS Code. This will provide you with a full-featured Java development environment by bundling the essential tools.
  • Install the latest Java Development Kit (JDK) v25 (LTS) for your platform/processor.
  • Note: You must set the JAVA_HOME environment variable to the installation directory for your JDK to allow other tools to find it, otherwise, you will receive an error while running the samples.
  • 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. Contact sales by filling out our licensing form if you want to purchase a commercial license key.

Keep your commercial license key confidential.

License keys are uniquely generated and strictly confidential. Don't publish or store them in any public location, including public GitHub repositories.

1. Run a PDFNet sample project

In this section, you can download and run the OfficeToPDFTest PDFNet sample module, which demonstrates the SDK's document-conversion capabilities. Upon successful completion, you can convert a DOCX document to a PDF file while leveraging the MS Office-to-PDF conversion API. You can use this module as a reference implementation when integrating similar document-conversion functionality into your own applications. 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 Apryse Java PDF library for Linux PDFNetJava.zip file.
  2. Extract the PDFNetJava.zip file to the following location: /Home/YourName/PDFNetJava/Samples/
    Replace YourName with your user name. You can install the samples to another location if you prefer, but for this guide’s instructions, we used the location above.
  3. Before running the sample, you need to add your license key to the PDFTronLicense.java file. Open Visual Studio Code, select File > Open Folder, and navigate to: /Home/YourName/PDFNetJava/Samples and select Open.
  4. The Samples section opens in the Explorer pane. Scroll down and select the LicenseKey folder and click on the PDFTronLicense.java file to open.
  5. In the PDFTronLicense.java file, scroll down to the line containing private static String LicenseKey = ‘YOUR_PDFTRON_LICENSE_KEY’; and replace the words in quotes with the copy of your trial license key you generated when you completed the Prerequisites instructions above. Do not change any other information in this file.
  6. Save your changes and close the PDFTronLicense.java file.
  7. From the Explorer > Samples pane, scroll down and select the OfficeToPDFTest folder.
  8. Right-click on the RunTest.bat file and select Open in Integrated Terminal.
  9. In the terminal, enter the following and press Enter:

zsh/bash

1./RunTest.sh

10. When you run the 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 has finished running, you will see 100% Done conversion in the terminal.

11. Type exit to close the Integrated Terminal.

12. From the Explorer > Samples pane, scroll down and select the TestFiles > Output folder. You will see three output PDF files (Fishermen.pdf, the_rime_of_the_ancient_mariner.pdf, and the factsheet_Arabic.pdf).

13. Click on the PDF files to see the converted output. You have successfully run the OfficeToPDFTest conversion sample!

14. Close the output PDF files.

2. Create a new PDFNet Java project

This section provides steps to create a simple Java project that uses the Apryse SDK and the PDFNet library to programmatically generate a blank PDF document. With these steps, you can learn how to set up your environment, import the required libraries, and run a script that produces a valid PDF file—all without manual intervention. This example provides a practical foundation for more advanced document‑generation workflows.

  1. In Visual Studio Code, from the Explorer pane, click on the Samples section, select the New Folder icon and enter myApp.
  2. Right-click on the myApp folder, select New File and name it JAVA.

3. Initialize and integrate the Apryse Server SDK into your application

  1. From the myApp folder, in the new file you just created, copy the following code and paste it into the myApp.java file to create a blank PDF page:

Java

1import java.io.File;
2import java.io.IOException;
3import com.pdftron.common.PDFNetException;
4import com.pdftron.pdf.*;
5import com.pdftron.sdf.SDFDoc;
6import com.pdftron.sdf.ObjSet;
7import com.pdftron.sdf.Obj;
8public class myApp
9{
10 public static void main(String[] args)
11 {
12 PDFNet.initialize("YOUR_APRYSE_LICENSE_KEY"); // PDFNet must be initialized before accessing any Apryse API
13 try
14 {
15 PDFDoc doc = new PDFDoc();
16 Page page = doc.pageCreate(); // Start a new page
17 doc.pagePushBack(page); // Add the page to the document
18 doc.save("output.pdf", SDFDoc.SaveMode.LINEARIZED, null); // Save the document as a linearized PDF
19 }
20 catch(PDFNetException e)
21 {
22 e.printStackTrace();
23 System.out.println(e);
24 }
25 System.out.println("Hello World!");
26 }
27}

2. Scroll down to the line containing PDFNet.initialize(“YOUR_PDFTRON_LICENSE_KEY”); and replace the words in quotes with the copy of your trial license key. Save your changes.

4. Run your project

  1. Right-click on the myApp.java file and select Open in Integrated Terminal.
  2. In the terminal, enter the following and press Enter to compile your application using the PDFNet library:

zsh/bash

1javac -cp .:../../../Lib/PDFNet.jar myApp.java

Then enter the following and press Enter to run the project:

zsh/bash

1java -Djava.library.path=../../../Lib -classpath .:../../../Lib/PDFNet.jar myApp

Keep in mind the following about the code above:

  • The system logs a startup message.
  • The program imports the Java SDK.
  • The script defines an async main function that builds the PDF.
  • The PDFNet engine runs with cleanup and license initialization.
  • The program logs any errors.
  • The script releases PDFNet resources and shuts down the engine.

3. In the terminal, type exit and press Enter.

4. In your Samples > myApp folder, you will see the output.pdf file you created by integrating the Apryse Server SDK!

5. You have successfully added the Apryse Server SDK to your Java project!

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

6. To try additional samples, go to section 1. Run a sample > step 7 above and choose another sample to run.

Additional ways to integrate.

If you prefer to use Maven or Gradle, choose from the following tabs:

1. Add the PDFNet Maven repository in your top-level pom.xml.

XML

1<repositories>
2 <repository>
3 <id>pdftron</id>
4 <name>PDFNet Maven</name>
5 <url>https://pdftron.com/maven/release</url>
6 </repository>
7</repositories>

2. Add the PDFNet Maven dependency in your pom.xml.

XML

1<dependencies>
2 <dependency>
3 <groupId>com.pdftron</groupId>
4 <artifactId>PDFNet</artifactId>
5 <version>11.1.0</version>
6 </dependency>
7</dependencies>

Integrate into your application

  1. Add PDFNet Maven repository and dependency in your pom.xml.
  2. In your src\main\java\your\java\folder\, add the following code to your java files. We use src\main\java\com\mycompany\app\App.java as an example:

Java

1package com.mycompany.app;
2import com.pdftron.pdf.*;
3public class App
4{
5 public static void main(String[] args)
6 {
7 PDFNet.initialize("YOUR_APRYSE_LICENSE_KEY");
8 try {
9 // YOUR CODE GOES HERE
10 } catch (Exception e) {
11 }
12 PDFNet.terminate();
13 }
14}

To test your code, you can navigate to the root of your project and run the following commands:

Bash

1mvn compile
2mvn exec:java -Dexec.mainClass=com.mycompany.app.App

If the program runs successfully, you should see no error in the terminal.

We have demonstrated how to integrate Apryse's Java SDK into your Maven project. If your have any questions, please don't hesitate to contact us!

Next Steps

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales