I want to generate the image(thumbnail) from pdf file just like done by WhatsApp as shown below
I have tried
- PDFBox (https://github.com/TomRoush/PdfBox-Android)
- Tika (compile 'org.apache.tika:tika-parsers:1.11')
- AndroidPdfViewer (https://github.com/barteksc/AndroidPdfViewer)
and still unable to find a way to generate image from pdf.
PDFBox:
There is a github issue that deals with this problem (https://github.com/TomRoush/PdfBox-Android/issues/3) but this is still unresolved.
Note: I am successfully able to extract image from PDF using PDFBOX
AndroidPdfViewer:
Github issue (https://github.com/barteksc/AndroidPdfViewer/issues/49)
Use PdfiumAndroid as mentioned by barteksc here...
Sample Code for generating pdf thumb
Update:
Include library in build.gradle
For generating Image of any PDF Page:
Call the method generateImageFromPdf(uri) by passing any PDF uri that is stored in your storage.
The method will generate the PDF.png in PDF folder of your storage.