I'm with my hands in my hair on this one.
I'm using Apache PDFBox, because I want to read pdf files line by line in JAVA and deal with the contents later on. However I have the following problem.. I've used the code below in a seperate java program (in the main method) and it works fine there. However when I use it in my tomcat server applet in combination with a quartz scheduler something goes wrong and I can't figure out why. Bear in mind I copy+pasted the lines below from the working seperate testing program into my own bigger project so it's the exact same code. However in my bigger project tHe program runs until the String x1 = .. line where I've put a breakpoint. When i try to step over it doesnt' give any errors, console output or anything and jumps over the catch clause straight to the finally. I've put breakpoints in the catch clause and they'er not being triggered.
this is my code:
PDFTextStripper stripper;
PDDocument doc = null;
try{
doc = PDDocument.load("00026614_F_21Jan2013-18Feb2013.pdf");
stripper = new PDFTextStripper();
String x1= stripper.getText(doc); //SOMETHING GOES WRONG HERE
//break up the file content returned as a string into individual lines
List<String> ans= Arrays.asList(x1.split("\r\n"));//THIS IS NEVER REACHED
}
catch(Exception e){
e.printStackTrace(); //THIS IS NEVER REACHED EITHER
}
finally{
if(doc!=null) //IT GOES FROM STRING X1 STRAIGHT TO HERE.
doc.close();
}
The only output i get is from the LOG4J which had to be initialized for some other part of the program and the final few lines of output are
34212 [DefaultQuartzScheduler_Worker-1] DEBUG org.apache.pdfbox.util.PDFStreamEngine - processing substream token: PDFOperator{Tm}
34212 [DefaultQuartzScheduler_Worker-1] DEBUG org.apache.pdfbox.util.PDFStreamEngine - processing substream token: COSName{ttf0}
34212 [DefaultQuartzScheduler_Worker-1] DEBUG org.apache.pdfbox.util.PDFStreamEngine - processing substream token: COSInt{10}
34212 [DefaultQuartzScheduler_Worker-1] DEBUG org.apache.pdfbox.util.PDFStreamEngine - processing substream token: PDFOperator{Tf}
Now the thing that bugs me is how can I figure out what goes wrong in that call? Like I said if I put the code in a seperate java program it runs fine.. but I"m not able to get any error output or catch any exceptions (I'm trying to catch Exception even though it should give IOException and yes I've tried that as well).
I hope any of you know what to do with this. Kind regards
Looks like someone already answered this, but adding a catch for the error did the trick for a similar problem I was having.
I added this 'catch' (for error) after the 'catch' for exception:
catch (Error err){
err.printStackTrace();
throw (err);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With