Platforms
Frameworks
Languages
This article 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.
To get started, choose your preferred platform from the tabs below.
Before you start:
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.
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 by filling out our licensing form if you want 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 provides steps to create a simple Java project.
PDFNetJava.zip file to the following location: C:\Users\YourName\ YourName with your user name. HelloWorld.java.HelloWorld.java file to create a blank PDF page: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.
C:\Users\YourName\PDFNetJava\Samples\HelloWorld.HelloWorld.java with the PDFNet.jar file added to the Java classpath:3. Type the following command to launch the application and load the Apryse Server SDK Java and native library dependencies:
Keep in mind the following about the code above:
4. In the terminal, type exit and press Enter.
5. 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!
6. You have successfully added the Apryse Server SDK to your Java project.
Before you start:
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.
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 by filling out our licensing form if you want 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 provides steps to create a simple Java project.
PDFNetJava.zip file to the following location: /Home/YourName/PDFNetJava/Samples/ YourName with your user name. JAVA.myApp.java file to create a blank PDF page: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.
myApp.java file and select Open in Integrated Terminal.Then enter the following and press Enter to run the project:
Keep in mind the following about the code above:
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.
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.
2. Add the PDFNet Maven dependency in your pom.xml.
pom.xml.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:To test your code, you can navigate to the root of your project and run the following commands:
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!
1. Add the PDFNet Maven repository in your top-level build.gradle.
2. Add the PDFNet dependency in your build.gradle.
Here we use a demo Gradle app as an example:
1. Add PDFNet Maven repository and dependency in your build.gradle.
2. In your app\src\main\java\your\java\folder\, add the following code to your java files. In this example, it's app\src\main\java\demo\App.java.
To test your code, you can navigate to the root of your project and run the following commands:
If the program builds successfully, you should see Apryse is running ... and BUILD SUCCESSFUL in the terminal.
We have demonstrated how to integrate Apryse's Java SDK into your Gradle project. You can find more information about building with Java on Gradle. If your have any questions, please don't hesitate to contact us!
Before you start:
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.
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 by filling out our licensing form if you want to purchase a commercial license key.
This section provides steps to create a simple Java project.
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. In Visual Studio Code, from the Explorer pane, click on the Samples section, select the New Folder icon and enter myApp for the name.
4. Right-click on the myApp folder, select New Folder and enter JAVA for the name.
5. In the JAVA folder, select New File and name it myApp.java.
myApp.java file to create a blank PDF page.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.
myApp.java file and select Open in Integrated Terminal.Then enter the following and press Enter to run the project:
Keep in mind the following about the code above:
3. Once the project has finished running, you will see: PDFNet is running in demo mode. Package V2. Hello World! in the terminal.
4. Type exit and press Enter to close the Integrated Terminal.
5. In your Samples > myApp folder, you will see the output.pdf file you created by integrating the Apryse Server SDK!
6. You have successfully added the Apryse Server SDK to your Java project.
If you prefer to use Maven or Gradle, choose from the following tabs:
This section will show you how to use our SDK to create a simple Apryse "Hello World!" application. It will create a document with one blank page and save it as a linearized PDF in its running directory.
/Samples directory of the Apryse SDK and create a directory called myApp if it does not exist already. This guide will assume your project is named myApp.myApp directory and create a JAVA directory for organization. Then create a myApp.java file in the JAVA directory. Open this file in your favorite text editor and paste:3. In that same JAVA directory inside your myApp project folder and compile your application using our PDFNet library:
4. Run the project by executing:
If all goes well, your terminal should output:
Check the output.pdf that the program output in the same directory. It should be a PDF with one blank page.
Check the troubleshooting page if you run into any issues going through this document.
1. Add the PDFNet Maven repository in your top-level pom.xml.
2. Add the PDFNet Maven dependency in your pom.xml.
pom.xml.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:To test your code, you can navigate to the root of your project and run the following commands:
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!
1. Add the PDFNet Maven repository in your top-level build.gradle.
2. Add the PDFNet dependency in your build.gradle.
Here we use a demo Gradle app as an example:
1. Add PDFNet Maven repository and dependency in your build.gradle.
2. In your app\src\main\java\your\java\folder\, add the following code to your java files. In this example, it's app\src\main\java\demo\App.java.
To test your code, you can navigate to the root of your project and run the following commands:
If the program builds successfully, you should see Apryse is running ... and BUILD SUCCESSFUL in the terminal.
We have demonstrated how to integrate Apryse's Java SDK into your Gradle project. Read more on building with Java on Gradle. If your have any questions, please don't hesitate to contact us!
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales