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

Build a Java PDF library app with Apryse Server SDK

This guide shows how to build a simple Java PDF application that uses the Apryse Server SDK and PDFNet library to generate a PDF programmatically. You’ll set up a minimal project, install the SDK, and add the required code to create a blank PDF document. This example provides a practical foundation for building more advanced document‑generation workflows.

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

Prerequisites

Before you start:

Set the JAVA_HOME environment variable to your JDK installation directory so your system can locate Java. If it's not set correctly, you may encounter errors when running your project.

  • For 32-bit binary packages and slimmer binaries (including Java libraries), visit the C++ docs for Server SDK.

  • Install Apache Maven or Gradle if you plan to use a build tool to manage dependencies and run your project.

  • Get your Apryse trial key.

spinner

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.

1. Set up your project

This section uses a manual setup, where you create a simple Java project and add the Apryse Server SDK using the JAR files from the downloaded package. This approach is useful for quick testing and understanding how the SDK works. If you’re using a build tool such as Maven or Gradle in an existing Java project, skip to the next section.

  1. Download and unzip the PDFNetJava.zip file to a location of your choice.

  2. Open the extracted /PDFNetJava/Samples folder in Visual Studio Code.

  3. In the Samples directory, create a MyApp/java folder structure.

  4. In the java folder, create a MyApp.java file. Your project should now include a similar structure:

2. Add the Apryse SDK

Next, you'll integrate the Apryse Server SDK into your Java application and add the code needed to generate a PDF. You can use a manual setup by adding the SDK JAR files directly, or use Maven or Gradle to include the SDK as a dependency.

  1. Open the MyApp.java file in Visual Studio Code or your preferred code editor.

  2. Add the following code to the MyApp.java file, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

  1. In Visual Studio Code, open your project’s pom.xml file.

  2. Add the PDFNet Maven repository and dependency in the pom.xml file and save your changes:

Info

The maven-metadata.xml endpoint lists all published versions of the com.pdftron:PDFNet artifact, along with the latest and release versions. This is useful for determining which version to specify in your pom.xml dependency.

  1. Add the following code to a Java file in src/main/java/<your_package>/, such as src/main/java/com/example/app/Main.java, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

  1. In Visual Studio Code, open your top-level build.gradle file.

  2. Add the Apryse Maven repository, dependency, and application configuration to your build.gradle file and save your changes:

Info

If the plugins, repositories, or dependencies blocks already exist, add the new entries to them instead of creating duplicate sections.

Info

The maven-metadata.xml endpoint lists all published versions of the com.pdftron:PDFNet artifact, along with the latest and release versions. This is useful for determining which version to specify in your pom.xml dependency.

  1. Add the following code to a Java file in src/main/java/<your-package>/, such as src/main/java/com/example/app/Main.java, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

3. Verify your output

Finally, build and run your Java application to confirm that the Apryse Server SDK is working correctly. After the application runs successfully, it will generate a blank PDF file locally. Instructions are provided for manual, Maven, and Gradle-based integrations.

  1. Navigate to the PDFNetJava/Samples/MyApp/java directory.

  2. In the terminal, run this command to compile MyApp.java with the PDFNet.jar file added to the Java classpath:

  1. Launch the application and load the Apryse Server SDK Java and native library dependencies:

A successful output looks similar to:

  1. Verify a blank output.pdf file was generated in the /PDFNetJava/Samples/MyApp/java directory. The folder structure looks similar to:

  1. From the root of your Maven project, compile the application and download all required dependencies:

  1. After the project compiles successfully, start the application and generate the PDF:

  1. Check the terminal output to ensure a successful build. A successful output looks similar to:

  1. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.

  1. From the root of your Gradle project, run this command to build and start the application:

  1. Check the terminal output to ensure a successful build. A successful output looks similar to:

  1. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.

Prerequisites

Before you start:

Set the JAVA_HOME environment variable to your JDK installation directory so your system can locate Java. If it's not set correctly, you may encounter errors when running your project.

  • Install Apache Maven or Gradle if you plan to use a build tool to manage dependencies and run your project.

  • Get your Apryse trial key.

spinner

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.

1. Set up your project

This section uses a manual setup, where you create a simple Java project and add the Apryse Server SDK using the JAR files from the downloaded package. This approach is useful for quick testing and understanding how the SDK works. If you’re using a build tool such as Maven or Gradle in an existing Java project, skip to the next section.

  1. Download and unzip the PDFNetJava.zip file to a location of your choice.

  2. Open the extracted /PDFNetJava/Samples folder in Visual Studio Code.

  3. In the Samples directory, create a MyApp/java folder structure.

  4. In the java folder, create a MyApp.java file. Your project should now include a similar structure:

2. Add the Apryse SDK

Next, you'll integrate the Apryse Server SDK into your Java application and add the code needed to generate a PDF. You can use a manual setup by adding the SDK JAR files directly, or use Maven or Gradle to include the SDK as a dependency.

  1. Open the MyApp.java file in Visual Studio Code or your preferred code editor.

  2. Add the following code to the MyApp.java file, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

  1. In Visual Studio Code, open your project’s pom.xml file.

  2. Add the PDFNet Maven repository and dependency in the pom.xml file and save:

Info

The maven-metadata.xml endpoint lists all published versions of the com.pdftron:PDFNet artifact, along with the latest and release versions. This is useful for determining which version to specify in your pom.xml dependency.

  1. Add the following code to a Java file in src/main/java/<your_package>/, such as src/main/java/com/example/app/Main.java, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

  1. In Visual Studio Code, open your top-level build.gradle file.

  2. Add the PDFNet Maven repository and dependency to your build.gradle file and save:

Info

If the plugins, repositories, or dependencies blocks already exist, add the new entries to them instead of creating duplicate sections.

Info

The maven-metadata.xml endpoint lists all published versions of the com.pdftron:PDFNet artifact, along with the latest and release versions. This is useful for determining which version to specify in your pom.xml dependency.

  1. Add the following code to a Java file in src/main/java/<your-package>/, such as src/main/java/com/example/app/Main.java, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

3. Verify your output

Finally, build and run your Java application to confirm that the Apryse Server SDK is working correctly. After the application runs successfully, it will generate a blank PDF file locally. Instructions are provided for manual, Maven, and Gradle-based integrations.

  1. Navigate to the PDFNetJava/Samples/MyApp/java directory.

  2. In the terminal, run this command to compile MyApp.java with the PDFNet.jar file added to the Java classpath:

  1. Launch the application and load the Apryse Server SDK Java and native library dependencies:

A successful output looks similar to:

  1. Verify a blank output.pdf file was generated in the /PDFNetJava/Samples/MyApp/java directory. The folder structure looks similar to:

  1. From the root of your Maven project, compile the application and download all required dependencies:

  1. After the project compiles successfully, start the application and generate the PDF:

  1. Check the terminal output to ensure a successful build. A successful output looks similar to:

  1. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.

  1. From the root of your Gradle project, run this command to build and start the application:

  1. Check the terminal output to ensure a successful build. A successful output looks similar to:

  1. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.

Prerequisites

Before you start:

Set the JAVA_HOME environment variable to your JDK installation directory so your system can locate Java. If it's not set correctly, you may encounter errors when running your project.

  • Install Apache Maven or Gradle if you plan to use a build tool to manage dependencies and run your project.

  • Get your Apryse trial key.

spinner

Run Apryse SDK in production

A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.

1. Set up your project

This section uses a manual setup, where you create a simple Java project and add the Apryse Server SDK using the JAR files from the downloaded package. This approach is useful for quick testing and understanding how the SDK works. If you’re using a build tool such as Maven or Gradle in an existing Java project, skip to the next section.

  1. Download and unzip the PDFNetJava.zip file to a location of your choice.

  2. Open the extracted /PDFNetJava/Samples folder in Visual Studio Code.

  3. In the Samples directory, create a MyApp/java folder structure.

  4. In the java folder, create a MyApp.java file. Your project should now include a similar structure:

2. Add the Apryse SDK

Next, you'll integrate the Apryse Server SDK into your Java application and add the code needed to generate a PDF. You can use a manual setup by adding the SDK JAR files directly, or use Maven or Gradle to include the SDK as a dependency.

  1. Open the MyApp.java file in Visual Studio Code or your preferred code editor.

  2. Add the following code to the MyApp.java file, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

  1. In Visual Studio Code, open your project’s pom.xml file.

  2. Add the PDFNet Maven repository and dependency in the pom.xml file and save:

Info

The maven-metadata.xml endpoint lists all published versions of the com.pdftron:PDFNet artifact, along with the latest and release versions. This is useful for determining which version to specify in your pom.xml dependency.

  1. Add the following code to a Java file in src/main/java/<your_package>/, such as src/main/java/com/example/app/Main.java, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

  1. In Visual Studio Code, open your top-level build.gradle file.

  2. Add the PDFNet Maven repository and dependency to your build.gradle file and save:

Info

If the plugins, repositories, or dependencies blocks already exist, add the new entries to them instead of creating duplicate sections.

Info

The maven-metadata.xml endpoint lists all published versions of the com.pdftron:PDFNet artifact, along with the latest and release versions. This is useful for determining which version to specify in your pom.xml dependency.

  1. Add the following code to a Java file in src/main/java/<your-package>/, such as src/main/java/com/example/app/Main.java, update your license key, and save your changes:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

With this code, you can:

  • Import the required Apryse PDFNet namespaces.

  • Define a main method to serve as the starting point for execution.

  • Initialize the Apryse SDK with a license key.

  • Create a new PDF document, add a blank page, and save it as a linearized PDF.

  • Log errors to the console.

  • Output a simple message to confirm the program ran successfully.

3. Verify your output

Finally, build and run your Java application to confirm that the Apryse Server SDK is working correctly. After the application runs successfully, it will generate a blank PDF file locally. Instructions are provided for manual, Maven, and Gradle-based integrations.

  1. Navigate to the PDFNetJava/Samples/MyApp/java directory.

  2. In the terminal, run this command to compile MyApp.java with the PDFNet.jar file added to the Java classpath:

  1. Launch the application and load the Apryse Server SDK Java and native library dependencies:

A successful output looks similar to:

  1. Verify a blank output.pdf file was generated in the /PDFNetJava/Samples/MyApp/java directory. The folder structure looks similar to:

  1. From the root of your Maven project, compile the application and download all required dependencies:

  1. After the project compiles successfully, start the application and generate the PDF:

  1. Check the terminal output to ensure a successful build. A successful output looks similar to:

  1. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.

  1. From the root of your Gradle project, run this command to build and start the application:

  1. Check the terminal output to ensure a successful build. A successful output looks similar to:

  1. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.

Next steps

UsageGuidesSamplesAPI docs

Last updated

Was this helpful?