I tried to optimize my test2.jar application using JProfiler. I noticed, that the most of time is spent in exceptions. However I can't locate the root cause for these exceptions. Both "load" and "save" are under my inspections.
Invitation.pdf is created using PDF-XChange Editor 9.0.352. PDF version is 1.7. It is empty document containing one form field, but the same problem exists with other more complicated pdf documents.
Do I have something wrong in my code or is there a bug in PDFBox 2.0.26 or JProfiler 13.0.3 trial version?
package com.home.tests.test2;
import java.io.IOException;
import java.io.File;
import org.apache.pdfbox.pdmodel.PDDocument;
public class Test2
{
public static void main(String args[]) throws IOException
{
try {
File template = new File("C:\\apps\\PDFBox-2.0.26\\test", "Template.pdf");
PDDocument document = PDDocument.load(template);
// TODO: Fill in form fields
document.save("Invitation.pdf");
document.close();
} catch (IOException e) {
System.err.println("Exception caught:");
e.printStackTrace();
System.exit(1);
}
System.out.println("Completed writing Invitation.pdf with success.");
}
}
When I run the jar there seems to be nothing wrong with it:
C:\apps\PDFBox-2.0.26\test>"C:\Program Files\Java\jre1.8.0_341\bin\java" -jar Test2.jar Completed writing Invitation.pdf with success.
However JProfiler found a lot of exceptions