I am trying to read a PDF file name main.pdf from raw folder and then open it on an ImageView. It's showing no error, but the bitmap is returning null. The main purpose of my application is to open only one PDF file which will be embedded in the application, and users can read only this PDF file. If there is another solution, you can suggest me.
private void read()
{
InputStream in;
try
{
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
in = getResources().openRawResource(R.raw.main);
System.out.println("input stream = " + in);
BufferedInputStream buffer = new BufferedInputStream(in);
System.out.println("buffer stream = " + buffer);
Bitmap bitmap = BitmapFactory.decodeStream(buffer, null, options);
System.out.println("bitmap = " + bitmap);
Matrix imageMatrix = image.getImageMatrix();
image.setImageMatrix(imageMatrix);
image.setImageBitmap(bitmap);
image.invalidate();
in.close();
} catch (Exception e)
{
Log.e("tag", e.getMessage());
System.err.print(e);
}
}