I'm a newbie for android developing. I'm working on converting Pdf to Image and storing it in a location. I have used the PdfRenderer (API level 21) to convert the PDF to bitmap Image. The converted image is Transparent background. Please guide me to convert the image with white background. So that I can convert it to binary digits.
PdfRenderer renderer = new PdfRenderer(ParcelFileDescriptor.open(pdfFile, ParcelFileDescriptor.MODE_READ_ONLY));
Bitmap bitmap;
final int pageCount = renderer.getPageCount();
System.out.println("pageCount"+pageCount);
for (int i = 0; i < pageCount; i++) {
PdfRenderer.Page page = renderer.openPage(i);
int width = getResources().getDisplayMetrics().densityDpi / 72 * page.getWidth();
int height = getResources().getDisplayMetrics().densityDpi / 72 * page.getHeight();
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_PRINT);
storeImage(bitmap,"test.bmp");//I have wrote a function here to save the image
This is the Transparent Image I get after converting
Thanks in advance.