I implemented E-Book App using Mupdf Library and want to generate thumbnail for each pdf file in my project Could Anyone tell me how to generate This? Thanks in advance
In Librelio they're using the old version of project muPDF without Cookie. In new versions you need to extend mu pdf core, like this:
class MuPDFThumb extends MuPDFCore{
public MuPDFThumb(Context context, String filename) throws Exception{
super(context, filename);
}
public Bitmap thumbOfFirstPage(int w, int h){
PointF pageSize = getPageSize(0);
float mSourceScale = Math.max(w/pageSize.x, h/pageSize.y);
Point size = new Point((int)(pageSize.x*mSourceScale), (int)(pageSize.y*mSourceScale));
final Bitmap bp = Bitmap.createBitmap(size.x,size.y, Bitmap.Config.ARGB_8888);
drawPage(bp,0,size.x, size.y, 0, 0, size.x, size.y,new Cookie());
return bp;
}
}
You need to extends, because Cookie is an internal class of MuPDFCore and it is required for calling drawPage.
The method thumbOfFirstPage takes 2 arguments: width and height of the ImageView to fill with bitmap:
thumbnailImageView.setImageBitmap(bPGenerated) in UIThread
Try the following:
core.drawPage(bm, page, pageW, pageH, patchX, patchY, patchW, patchH);
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