Platforms
Frameworks
Languages
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.
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.
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.
A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.
License keys are uniquely generated and strictly confidential. Don't publish or store them in any public location, including public GitHub repositories.Â
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.
/PDFNetJava/Samples folder in Visual Studio Code.Samples directory, create a MyApp/java folder structure.java folder, create a MyApp.java file. Your project should now include a similar structure: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.
MyApp.java file in Visual Studio Code or your preferred code editor.MyApp.java file, update your license key, and save your changes:MyApp/java/MyApp.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.pom.xml file.PDFNet Maven repository and dependency in the pom.xml file, and save your changes:pom.xml
3. 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:
Main.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.build.gradle file.build.gradle file, and save your changes:build.gradle
If the plugins, repositories, or dependencies blocks already exist, add the new entries to them instead of creating duplicate sections.
3. 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:
Main.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.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.
PDFNetJava/Samples/MyApp/java directory.MyApp.java with the PDFNet.jar file added to the Java classpath:3. Launch the application and load the Apryse Server SDK Java and native library dependencies:
A successful output looks similar to:
4. Verify a blank output.pdf file was generated in the /PDFNetJava/Samples/MyApp/java directory. The folder structure looks similar to:
2. After the project compiles successfully, start the application and generate the PDF:
3. Check the terminal output to ensure a successful build. A successful output looks similar to:
4. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.
2. Check the terminal output to ensure a successful build. A successful output looks similar to:
3. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.
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.
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.
A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.
License keys are uniquely generated and strictly confidential. Don't publish or store them in any public location, including public GitHub repositories.
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.
/PDFNetJava/Samples folder in Visual Studio Code.Samples directory, create a MyApp/java folder structure.java folder, create a MyApp.java file. Your project should now include a similar structure: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.
MyApp.java file in Visual Studio Code or your preferred code editor.MyApp.java file, update your license key, and save your changes:MyApp/java/MyApp.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.pom.xml file.PDFNet Maven repository and dependency in the pom.xml file:pom.xml
3. 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:
Main.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.build.gradle file.PDFNet Maven repository and dependency to your build.gradle file:build.gradle
3. 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:
Main.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.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.
PDFNetJava/Samples/MyApp/java directory.MyApp.java with the PDFNet.jar file added to the Java classpath:3. Launch the application and load the Apryse Server SDK Java and native library dependencies:
A successful output looks similar to:
4. Verify a blank output.pdf file was generated in the /PDFNetJava/Samples/MyApp/java directory. The folder structure looks similar to:
2. After the project compiles successfully, start the application and generate the PDF:
3. Check the terminal output to ensure a successful build. A successful output looks similar to:
4. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.
2. Check the terminal output to ensure a successful build. A successful output looks similar to:
3. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.
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.
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.
A commercial license key is required for use in a production environment. Contact sales to purchase a commercial license key.
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.
/PDFNetJava/Samples folder in Visual Studio Code.Samples directory, create a MyApp/java folder structure.java folder, create a MyApp.java file. Your project should now include a similar structure: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.
MyApp.java file in Visual Studio Code or your preferred code editor.MyApp.java file, update your license key, and save your changes:MyApp/java/MyApp.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.pom.xml file.PDFNet Maven repository and dependency in the pom.xml file:pom.xml
3. 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:
Main.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.build.gradle file.PDFNet Maven repository and dependency to your build.gradle file:build.gradle
3. 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:
Main.java
If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.
With this code, you can:
PDFNet namespaces.main method to serve as the starting point for execution.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.
PDFNetJava/Samples/MyApp/java directory.MyApp.java with the PDFNet.jar file added to the Java classpath:3. Launch the application and load the Apryse Server SDK Java and native library dependencies:
A successful output looks similar to:
4. Verify a blank output.pdf file was generated in the /PDFNetJava/Samples/MyApp/java directory. The folder structure looks similar to:
2. After the project compiles successfully, start the application and generate the PDF:
3. Check the terminal output to ensure a successful build. A successful output looks similar to:
4. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.
2. Check the terminal output to ensure a successful build. A successful output looks similar to:
3. Verify that the Server SDK generated a blank output.pdf file in the root of your Java project.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales