RadaeePDF.com :: Topic: 3.2 Can't add bitmap (1/1)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about Android development and PDF

TOPIC: 3.2 Can't add bitmap

3.2 Can't add bitmap 2 years 11 months ago #8116

I am trying to upgrade from v2 to v3.2 and now I am unable to add Bitmaps to Pages. I have a Professional license which has been enabled. Here is what I see:

b = BitmapFactory.decodeFile(filePath, options); //Bitmap successfully loads
Document m_doc = new Document();
m_doc.Open(pdf.getAbsolutePath(), null); //static file path for temp file, is valid

//m_doc has a large negative hand_val on Android v5 which seems wrong
//on Android v4 m_doc has a large positive hand_val which seems correct

Page page = m_doc.GetPage(0); //this works
float dpix = m_doc.GetPageWidth(0);
float dpiy = m_doc.GetPageHeight(0);
dpix = Math.round((disp_w * 72) / dpix); //85.0
dpiy = Math.round(((disp_h - 50) * 72) / dpiy); //103.0

int w = (int) ((dpix * m_doc.GetPageWidth(0)) / 72); //720
int h = (int) ((dpix * m_doc.GetPageHeight(0)) / 72); //1184

Matrix mat = new com.radaee.pdf.Matrix(dpix / 72, -dpix / 72, 0, (dpix * m_doc.GetPageHeight(0)) / 72);
DIB dib = new DIB();
dib.CreateOrResize(w, h);

page.RenderPrePare(dib);
float rect[] = { 0, 0, m_doc.GetPageWidth(0), m_doc.GetPageHeight(0) };
boolean add_bitmap = page.AddAnnotBitmap(b, false, rect); // **** returns false! *****

// now i save and close the document, but it's just a blank document



I have completely replaced the old version of PDFViewer with the new one including the libs directory. What do I need to change?
The administrator has disabled public write access.

3.2 Can't add bitmap 2 years 11 months ago #8131

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
ver 3.2 has example to show how to add bitmap anotations.
just click "Stamp" button, and then drag on screen.

AddAnnotBitmap need conditions:
1. Document.SetCache() invoked, and only once for each Document, and do not share same cache file name for different Documents at one time.
2. Bitmap must be RGBA32 pixel format.
3. professional or premium license actived.
The administrator has disabled public write access.
Powered by Kunena Forum