PDFtoExcel.zip (909.7 KB)
I have convert PDFtoExcel sample to gradle version and add aspose.pdf jar(v19) to the libs dir.
But when I step over into the code:
Document doc = new Document(inputPath);
There are no any response.
public class MainActivity extends Activity {
@SuppressWarnings("static-access")
private static void PDFtoExcel()
{
String path=Environment.getExternalStorageDirectory().getPath();
String inputPath = path + "/Documents/test.pdf";
String outputPath = "/storage/emulated/0/Documents/Table_out.xlsx";
// '/storage/emulated/0/Documents/my.pdf'
// Method 1
File file=new File(inputPath);
if (file.exists()) {
Document doc = new Document(inputPath);
doc.save(outputPath, SaveFormat.Excel);
}
// Method 2
ExcelSaveOptions options = new ExcelSaveOptions();
options.setInsertBlankColumnAtFirst(false);
options.setMinimizeTheNumberOfWorksheets(true);
//Save document in XLSX format
options.setFormat(ExcelSaveOptions.ExcelFormat.XLSX);
Document pdfDocument = new Document(inputPath);
pdfDocument.save(outputPath, options);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PDFtoExcel();
try
{
TextView tx = (TextView)findViewById(R.id.textBox);
tx.setText("Done.");
}catch (Exception ex){
ex.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}