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
Asked
Active
Viewed 2,081 times
3
-
1Your question is similar to http://stackoverflow.com/questions/15358461/create-image-of-all-pages-in-pdf-using-mupdf-library/15382454#15382454 – Librelio Jun 28 '13 at 15:03
3 Answers
5
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

ldd
- 440
- 5
- 9
-
I was having the same problem with the internal class `Cookie`. Thanks to your comment now we know that we are forced to extend MuPDFCore – MatPag Jan 13 '17 at 12:04
1
Try the following:
core.drawPage(bm, page, pageW, pageH, patchX, patchY, patchW, patchH);

Andrew Schuster
- 3,229
- 2
- 21
- 32

user2589629
- 11
- 1
0
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

ccxvii
- 1,873
- 1
- 13
- 11
-
1sorry i want to generate it inside code to deal with it and display it in grid view – Bibo Wagdy Jun 28 '13 at 19:07
-
-
Please when i press search button, search text box does not appear in portrait mode and it does not support arabic words for search – Bibo Wagdy Sep 19 '13 at 19:07