Reputation: 46
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
Upvotes: 3
Views: 2215
Reputation: 460
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
Upvotes: 5
Reputation: 11
Try the following:
core.drawPage(bm, page, pageW, pageH, patchX, patchY, patchW, patchH);
Upvotes: 1
Reputation: 2123
If you just want to generate a thumbnail image of the first page for a PDF file, you can use the command line tool mudraw:
mudraw -w 128 -h 128 -o thumbnail.png file.pdf 1
Upvotes: 0