My goal is to convert my fillable pdf document to an image and then save it to my database on Kumulos. I'm having issues converting the pdf document with PDFTron. The error that I am getting is that the file does not exist. However, I am able to pull the file and view it in the app.
switch (Global.g){
case 1:
InputStream is = res.openRawResource(R.raw.incident_report);
try{
doc = new PDFDoc(is);
}catch (PDFNetException e){
doc = null;
e.printStackTrace();
}catch (IOException e){
doc = null;
e.printStackTrace();
}
try {
mPDFViewCtrl.setDoc(doc);
save_Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try{
String output_path = "../../raw/Output/";
PDFDraw draw=new PDFDraw(); // PDFDraw class is used to rasterize PDF pages.
ObjSet hint_set=new ObjSet();
PDFDoc doc=new PDFDoc((mPDFViewCtrl + "incident_report.pdf"));
// Initialize the security handler, in case the PDF is encrypted.
doc.initSecurityHandler();
draw.setDPI(72); // Set the output resolution is to 72 DPI.
// Use optional encoder parameter to specify JPEG quality.
Obj encoder_param=hint_set.createDict();
encoder_param.putNumber("Quality", 80);
// Traverse all pages in the document.
for (PageIterator itr=doc.getPageIterator(); itr.hasNext();) {
Page current=(Page)(itr.next());
String filename=output_path+"incident_report"+current.getIndex() + ".jpg";
System.out.println(filename);
draw.export(current, filename, "JPEG", encoder_param);
}
doc.close();
}catch(PDFNetException e){
e.printStackTrace();
}
finish();
}
});
cancel_Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
} catch (PDFNetException e) {
e.printStackTrace();
}
break;