The document is rendered completely on the device , Now , the call to the RenderIsFinised is returning true.
Now , I am trying to generate the thumbnail of that specific page of the document on a button click using the following code:
public Bitmap generateThumbNails(Document mdoc, int pageNo, int quality) {
Page page = mdoc.GetPage(pageNo);
Bitmap bmp = null;
try {
float w = mdoc.GetPageWidth(pageNo);
float h = mdoc.GetPageHeight(pageNo);
bmp = Bitmap.createBitmap(quality, (int) (h / (w / quality)), Bitmap.Config.ARGB_8888);
int ih = (int) (h / (w / quality));
bmp.eraseColor(0);
float ratiox = quality / w;
float ratioy = ih / h;
if (ratiox > ratioy)
ratiox = ratioy;
if (!page.RenderThumb(bmp)) {
Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setARGB(255, 255, 255, 255);
canvas.drawRect((quality - w * ratiox) / 2, (ih - h * ratiox) / 2, (quality + w * ratiox) / 2, (ih + h
* ratiox) / 2, paint);
Matrix mat = new Matrix(ratiox, -ratiox, (quality - w * ratiox) / 2, (ih + h * ratiox) / 2);
page.RenderToBmp(bmp, mat);
mat.Destroy();
if (!page.RenderIsFinished()) {
bmp.recycle();
bmp = null;
}
}
page.Close();
} catch (Exception e) {
}
return bmp;
}
In the above code , RenderIsFinised is returning as false and an empty thumbnail is getting generated.
Kindly provide your inputs.