Rendering a single page to android.graphics.Bitmap - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about Android development and PDF
  • Page:
  • 1

TOPIC: Rendering a single page to android.graphics.Bitmap

Rendering a single page to android.graphics.Bitmap 3 years 7 months ago #8899

  • Kin Chung
  • Kin Chung's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0
After the PDF is opened, I executed the code below:

float w = pdfReader.PDFGetDoc().GetPageWidth(0);
float h = pdfReader.PDFGetDoc().GetPageHeight(0);
float ih = 44 * getDensity();
float iw = ih / h * w;
Page page = pdfReader.PDFGetDoc().GetPage(0);
Bitmap bmp = Bitmap.createBitmap((int) iw, (int) ih, Bitmap.Config.ARGB_8888);
bmp.eraseColor(Color.WHITE);
page.RenderThumb(bmp);

However, the bmp object is still blank. Did I miss out something?

Please Log in or Create an account to join the conversation.

Last edit: by Kin Chung.

Rendering a single page to android.graphics.Bitmap 3 years 7 months ago #8901

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Karma: 18
  • Thank you received: 65
Hi.
if you want to add the bitmap to the page you have to use:
page.RenderToBmp(Bitmap bitmap)
instead of :
page.RenderThumb(bmp);

For more info you can check the documentation and look at this knowledge-base article .
The following user(s) said Thank You: Kin Chung

Please Log in or Create an account to join the conversation.

Last edit: by Davide.
  • Page:
  • 1
Powered by Kunena Forum