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:
Install Visual Studio Code or another code editor to develop and debug your code.
Install the Extension Pack for Java and the vscode-pdf extension from the Extensions Marketplace if using VS Code.
Install Java Development Kit (JDK) 25 (LTS) for your platform.
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.
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.
Download and unzip the PDFNetJava.zip file to a location of your choice.
Open the extracted
/PDFNetJava/Samplesfolder in Visual Studio Code.In the
Samplesdirectory, create aMyApp/javafolder structure.In the
javafolder, create aMyApp.javafile. 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.
Open the
MyApp.javafile in Visual Studio Code or your preferred code editor.Add the following code to the
MyApp.javafile, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
In Visual Studio Code, open your project’s
pom.xmlfile.Add the
PDFNet Mavenrepository and dependency in thepom.xmlfile and save your changes:
Add the following code to a Java file in
src/main/java/<your_package>/, such assrc/main/java/com/example/app/Main.java, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
In Visual Studio Code, open your top-level
build.gradlefile.Add the Apryse Maven repository, dependency, and application configuration to your
build.gradlefile and save your changes:
Add the following code to a Java file in
src/main/java/<your-package>/, such assrc/main/java/com/example/app/Main.java, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
Navigate to the
PDFNetJava/Samples/MyApp/javadirectory.In the terminal, run this command to compile
MyApp.javawith thePDFNet.jarfile added to the Java classpath:
Launch the application and load the Apryse Server SDK Java and native library dependencies:
A successful output looks similar to:
Verify a blank
output.pdffile was generated in the/PDFNetJava/Samples/MyApp/javadirectory. The folder structure looks similar to:
From the root of your Maven project, compile the application and download all required dependencies:
After the project compiles successfully, start the application and generate the PDF:
Check the terminal output to ensure a successful build. A successful output looks similar to:
Verify that the Server SDK generated a blank
output.pdffile in the root of your Java project.
From the root of your Gradle project, run this command to build and start the application:
Check the terminal output to ensure a successful build. A successful output looks similar to:
Verify that the Server SDK generated a blank
output.pdffile in the root of your Java project.
Prerequisites
Before you start:
Install Visual Studio Code or another code editor to develop and debug your code.
Install the Extension Pack for Java and the vscode-pdf extension from the Extensions Marketplace if using VS Code.
Install Java Development Kit (JDK) 25 (LTS) for your platform.
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.
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.
Download and unzip the PDFNetJava.zip file to a location of your choice.
Open the extracted
/PDFNetJava/Samplesfolder in Visual Studio Code.In the
Samplesdirectory, create aMyApp/javafolder structure.In the
javafolder, create aMyApp.javafile. 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.
Open the
MyApp.javafile in Visual Studio Code or your preferred code editor.Add the following code to the
MyApp.javafile, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
In Visual Studio Code, open your project’s
pom.xmlfile.Add the
PDFNet Mavenrepository and dependency in thepom.xmlfile and save:
Add the following code to a Java file in
src/main/java/<your_package>/, such assrc/main/java/com/example/app/Main.java, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
In Visual Studio Code, open your top-level
build.gradlefile.Add the
PDFNet Mavenrepository and dependency to yourbuild.gradlefile and save:
Add the following code to a Java file in
src/main/java/<your-package>/, such assrc/main/java/com/example/app/Main.java, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
Navigate to the
PDFNetJava/Samples/MyApp/javadirectory.In the terminal, run this command to compile
MyApp.javawith thePDFNet.jarfile added to the Java classpath:
Launch the application and load the Apryse Server SDK Java and native library dependencies:
A successful output looks similar to:
Verify a blank
output.pdffile was generated in the/PDFNetJava/Samples/MyApp/javadirectory. The folder structure looks similar to:
From the root of your Maven project, compile the application and download all required dependencies:
After the project compiles successfully, start the application and generate the PDF:
Check the terminal output to ensure a successful build. A successful output looks similar to:
Verify that the Server SDK generated a blank
output.pdffile in the root of your Java project.
From the root of your Gradle project, run this command to build and start the application:
Check the terminal output to ensure a successful build. A successful output looks similar to:
Verify that the Server SDK generated a blank
output.pdffile in the root of your Java project.
Prerequisites
Before you start:
Install Visual Studio Code or another code editor to develop and debug your code.
Install the Extension Pack for Java and the vscode-pdf extension from the Extensions Marketplace if using VS Code.
Install Java Development Kit (JDK) 25 (LTS) for your platform.
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.
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.
Download and unzip the PDFNetJava.zip file to a location of your choice.
Open the extracted
/PDFNetJava/Samplesfolder in Visual Studio Code.In the
Samplesdirectory, create aMyApp/javafolder structure.In the
javafolder, create aMyApp.javafile. 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.
Open the
MyApp.javafile in Visual Studio Code or your preferred code editor.Add the following code to the
MyApp.javafile, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
In Visual Studio Code, open your project’s
pom.xmlfile.Add the
PDFNet Mavenrepository and dependency in thepom.xmlfile and save:
Add the following code to a Java file in
src/main/java/<your_package>/, such assrc/main/java/com/example/app/Main.java, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
In Visual Studio Code, open your top-level
build.gradlefile.Add the
PDFNet Mavenrepository and dependency to yourbuild.gradlefile and save:
Add the following code to a Java file in
src/main/java/<your-package>/, such assrc/main/java/com/example/app/Main.java, update your license key, and save your changes:
With this code, you can:
Import the required Apryse
PDFNetnamespaces.Define a
mainmethod 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.
Navigate to the
PDFNetJava/Samples/MyApp/javadirectory.In the terminal, run this command to compile
MyApp.javawith thePDFNet.jarfile added to the Java classpath:
Launch the application and load the Apryse Server SDK Java and native library dependencies:
A successful output looks similar to:
Verify a blank
output.pdffile was generated in the/PDFNetJava/Samples/MyApp/javadirectory. The folder structure looks similar to:
From the root of your Maven project, compile the application and download all required dependencies:
After the project compiles successfully, start the application and generate the PDF:
Check the terminal output to ensure a successful build. A successful output looks similar to:
Verify that the Server SDK generated a blank
output.pdffile in the root of your Java project.
From the root of your Gradle project, run this command to build and start the application:
Check the terminal output to ensure a successful build. A successful output looks similar to:
Verify that the Server SDK generated a blank
output.pdffile in the root of your Java project.
Next steps
Last updated
Was this helpful?