aspose-free-consulting / projects

The starting point for Aspose free consulting projects
5 stars 5 forks source link

Android PDF LIb- Not converting PDF to HTML #213

Open cupatil opened 2 years ago

cupatil commented 2 years ago

HI Team,

We are evaluating Android aspose pdf library and trying to convert pdf to html but the file is not generating.

We are using below code for the same:

InputStream i = null;
try {
    i = this.context.getApplicationContext().getContentResolver().openInputStream(uris[0]);
    Document d = new Document(i);
    App.closeStream(i);

    File output = new File(context.getFilesDir(), "html/Aspose_DocToHTML.html");
    d.save(output.toString(), SaveFormat.);

    return output.toString();
} catch (Exception x) {
    this.error = x;
} finally {
    App.closeStream(i);
}

To apply license, Using below code

License license = new License();
InputStream i = null;
try {
    i = getResources().getAssets().open(getString(R.string.aspose_pdf_license_asset_file));
    license.setLicense(i);
    closeStream(i);
} catch (Exception x) {
    Log.e(App.class.getName(), Log.getStackTraceString(x));
} finally {
    closeStream(i);
}

Added below lib in gradle:

  compile (
  group: 'com.aspose',
  name: 'aspose-pdf',
  version: '20.11',
  classifier: 'android.via.java')

Please suggest, We have did same thing to Aspose word library ther it work properly but here we are not getting any error also not generating html file. We have also cross checked the write external storage permission for the same.

tahir-manzoor commented 2 years ago

@cupatil

Could you please share your share your PDF and HTML here for testing? We will investigate the issue and provide you more information on it.

cupatil commented 2 years ago

We are not able to convert any pdf to html and not able to find saved html file . But From below link you can download the PDF that i am using to convert and save the html file. PDF Link: https://unec.edu.az/application/uploads/2014/12/pdf-sample.pdf

FYI: We are trying to open PDF inside our application for this we are converting PDF to HTML and show that html in web view for this purpose we need this. If you have any anther solution also please let us know

tahir-manzoor commented 2 years ago

@cupatil

Are you facing any exception while saving PDF to HTML? It seems that you are facing issue with your application to view the HTML. Please call App.closeStream(i) after Document.save method. You can save the output HTML to disk to verify PDF to HTML conversion.

cupatil commented 2 years ago

@tahir-manzoor No we are not facing any exception while executing file conversion code. Actually, The main problem is html file not generated and saved so we are getting file not found while view in the application . We have also called App.closeStream(i) after Document.save method. You can also check in above shared code snippet

And the pattern of code will work with Aspose word library.

tahir-manzoor commented 2 years ago

@cupatil

We have logged this problem in our issue tracking system as PDFANDROID-626. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.