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.

Windows 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 Windows 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 based on your device 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.
  • For 32-bit binary packages and slimmer binaries (including java libraries), visit the C++ docs for Server SDK.
  • 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 Windows PDFNetJava.zip file.
  2. Extract the PDFNetJava.zip file to the following location: C:\Users\YourName\PDFNetJava\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: C:\Users\YourName\PDFNetJava\PDFNetJava\Samples and click on Select folder.
  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. On the command line, enter the following and press Enter:

zsh/bash

1.\RunTest.bat

Note that if you encounter an error while trying to run the RunTest.bat file, you will need to unblock the RunTest.bat file. Select the RunTest.bat file, right-click and select Reveal in File Explorer. Right-click on the file and select Properties. Make sure the file is Unblocked.

10. When you run the RunTest.bat 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 command line.

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. From the Explorer pane, click on the Samples section, select the New Folder icon and enter HelloWorld.
  2. Right-click on the HelloWorld folder, select New File and name it HelloWorld.java.

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

  1. Copy the following code and paste it into the HelloWorld.java file to create a blank PDF page:

Java

1import java.io.File;
2import java.io.IOException;
3// These are the most important packages to import
4// for basic document manipulation.
5import com.pdftron.common.PDFNetException;
6import com.pdftron.pdf.*;
7import com.pdftron.sdf.SDFDoc;
8import java.io.*;
9public class HelloWorld
10{
11 // Just a simple setup for the application
12 public static void main(String[] args)
13 {
14 // PDFNet must always be initialized before any Apryse
15 // classes and methods can be used
16 PDFNet.initialize("YOUR_APRYSE_LICENSE_KEY");
17 System.out.println("Hello World!");
18 // Most Apryse operations are required to be wrapped in
19 // a try-catch block for PDFNetException, or in a method/class that
20 // throws PDFNetException
21 try {
22 // Creates a new PDFDoc object
23 PDFDoc doc = new PDFDoc();
24 // Creating a new page and adding it
25 // to document's sequence of pages
26 Page page1 = doc.pageCreate();
27 doc.pagePushBack(page1);
28 // Files can be saved with various options
29 // Linearized files are the most effective
30 // for opening and viewing quickly on various platforms
31 doc.save(("linearized_ouput.pdf"), SDFDoc.SaveMode.LINEARIZED, null);
32 doc.close();
33 } catch (PDFNetException e) {
34 System.out.println(e);
35 e.getStackTrace();
36 }
37 PDFNet.terminate();
38 }
39}

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

4. Run your project

  1. Open a Windows Command prompt and navigate to: C:\Users\YourName\PDFNetJava\PDFNetJava\Samples\HelloWorld.
  2. On the command line, enter the following and press Enter:

zsh/bash

1java.exe -Djava.library.path=../../Lib -classpath .;../../Lib/PDFNet.jar HelloWorld

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. Return to Visual Studio Code. In your Samples >HelloWorld folder, you will see the linearized_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.

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