I'm using mupdf library in my android application to view the pdf files. Can anyone tell me how to get the bitmap images of each page of a pdf using mupdf library? Thanks in advance....
-
any body knw the answer??? – Prijin Koshy Alex Mar 25 '13 at 06:24
-
please help http://stackoverflow.com/questions/24545152/compiling-mupdf-lib-in-eclipse-cannot-unlink-nul-invalid-argument-android-nd – Qadir Hussain Jul 04 '14 at 10:07
-
Did you solved your problem?! Please see my related questoin: http://stackoverflow.com/questions/30858689/using-mupdf-with-curl-flip-effect – Dr.jacky Jun 16 '15 at 06:04
3 Answers
use function in MUPDFcore.class
,it is called drawPage(int page, int PDF width,int PDF height, 0,0,int bitmap width,int bitmap height)
This function return bitmap image. 1st parameter is the page that will be rendered.
The 2nd and 3rd parameter are the size of PDF.
The 4th and 5th parameter are the beginning of the bitmap position to be filled with PDF rendered image (this is assumption, because there is no exact documentation regarding these parameters)
THe 6th and 7th parameter are the bitmap size that will be filled with PDF rendered image.
I have already done it within the sample project given by them. Now I'm trying to use it in another project but I still have difficulties.

- 11
- 2
-
Please see my related question: http://stackoverflow.com/questions/30858689/using-mupdf-with-curl-flip-effect – Dr.jacky Jun 16 '15 at 05:59
-
The only drawPage in MUPDFCore.java is this line::::: public synchronized void drawPage(Bitmap bm, int page,int pageW, int pageH,int patchX, int patchY,int patchW, int patchH,MuPDFCore.Cookie cookie) {gotoPage(page);drawPage(bm, pageW, pageH, patchX, patchY, patchW, patchH, cookie.cookiePtr);} – Dr.jacky Jun 16 '15 at 06:03
-
-
okie i hope i can help u.. @Mr.Hyde.. did u checked in MuPDF Lib..? – Saravana Kumar Chinnaraj Jun 16 '15 at 10:18
-
@SaravanaKumarChinnaraj Yup, in whole project. Please see my original question: http://stackoverflow.com/questions/30858689/using-mupdf-with-curl-flip-effect – Dr.jacky Jun 16 '15 at 10:27
I found the solution for generate bitmap.
ThumbnailsActivity.mBitmapList=new ArrayList<Bitmap>();
for(int i=0;i<core.countPages();i++){
Bitmap bitmap=core.drawPage(i, 200, 200, 0, 0, 200, 200);
if(bitmap!=null){
ThumbnailsActivity.mBitmapList.add(bitmap);
}
}
I hope this may help others.Thanks!

- 2,418
- 4
- 25
- 51
-
please help http://stackoverflow.com/questions/24545152/compiling-mupdf-lib-in-eclipse-cannot-unlink-nul-invalid-argument-android-nd – Qadir Hussain Jul 04 '14 at 10:07
-
1There is not method drawPage with parameters you show. However there is : drawPage(Bitmap bm, int page, int pageW, int pageH, int patchX, int patchY, int patchW, int patchH) – support_ms Jul 21 '14 at 07:08
The library seems to be updated and doesn't render images if called drawPage() but works fine if we give updatePage()
Find snippet below from the sample source code
//Activity onCreate()
int x = Utils.getScreenSize(this)[0];
int y = Utils.getScreenSize(this)[1];
final ImageView imageView = (ImageView) findViewById(R.id.holderimageview);
final Bitmap mSharedHqBm = Bitmap.createBitmap(x,y, Bitmap.Config.ARGB_8888);
new CancellableAsyncTask<Void, Void>(getDrawPageTask(mSharedHqBm, x,y, 0, 0, x, y)) {
@Override
public void onPreExecute() {
imageView.setImageBitmap(null);
imageView.invalidate();
// Show some imageholder/spinner/progress etc.
}
@Override
public void onPostExecute(Void result) {
imageView.setImageBitmap(mSharedHqBm);
imageView.invalidate();
}
}
// method in activity
protected CancellableTaskDefinition<Void, Void> getDrawPageTask(final Bitmap bm, final int sizeX, final int sizeY, final int patchX, final int patchY, final int patchWidth, final int patchHeight) { return new MuPDFCancellableTaskDefinition<Void, Void>(core) {
@Override
public Void doInBackground(MuPDFCore.Cookie cookie, Void ... params) {
// Workaround bug in Android Honeycomb 3.x, where the bitmap generation count
// is not incremented when drawing.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) bm.eraseColor(0);
core.updatePage(bm, somepagenumber, sizeX, sizeY, patchX, patchY, patchWidth, patchHeight, cookie);
return null;
}
};
}

- 11,843
- 6
- 29
- 47
-
Please see my related question: http://stackoverflow.com/questions/30858689/using-mupdf-with-curl-flip-effect – Dr.jacky Jun 16 '15 at 06:23