0
votes

Hi I found this example of pdfbox using annotation:

https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddAnnotations.java

When I try to run it in netbeans, nothing happens except to print in output:

Usage: add_annotation_exp1.Add_annotation_exp1$AddAnnotations

Not sure what I am doing wrong

1
Add program argument "test.pdf" as a program argument. If not sure how to set it up see stackoverflow.com/questions/9168759/…rgrebski
I now get: Target ""test.pdf"" does not exist in the project "{0} (run)".gerry
OK. I understand a little more. The reason it will not run is down to this: if (args.length != 1) { System.err.println("Usage: " + AddAnnotations.class.getName() + " <output-pdf>"); System.exit(1); } how and why do I make args.length = 1 ?gerry
when I now pass it "test.pdf" as an argument it says: Target "test.pdf" does not exist in the project "{0} (run)"gerry
You appear to pass "test.pdf" as an argument of the build process, not of the execution of the program itself. So this effectively is a question concerning how to use netbeans.mkl

1 Answers

0
votes

There are two possible solutions (based on Netbeans 8.2):

1) In the main method, add this at the beginning: args = new String[]{"c:/path/filename.pdf"}; and then build the subproject and then press SHIFT F6 to run, or right-click in the editor pane and choose "Run File". (If the subproject is open then you can skip the build step)

2) Go to the subproject properties (right-click on the left pane on "Apache PDFBox examples"), "Properties". A dialog box will appear. Choose "run" in the left pane. In the field "Main Class" enter org.apache.pdfbox.examples.pdmodel.AddAnnotations (or use the "Browse..." button), and in the field "Arguments" enter your file name with the path. Use quotes if there are spaces in the path. Then run by clicking the right mouse key on the subproject and choose "Run".