Display Bitmap and Drawable contents on the pages - 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

TOPIC: Display Bitmap and Drawable contents on the pages

Display Bitmap and Drawable contents on the pages 3 years 1 month ago #9648

  • jorisk
  • jorisk's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 37
  • Karma: 1
  • Thank you received: 0
Hello,

I am trying to load Bitmap and Drawable contents over an annotation on a page.

For this, I first load a "classic" annotation zone with the function page.AddAnnotURI(), that I load in the file PDFReaderAct.java, precisely in the OnPageChanged(int pageno) method.

This works great but now I would like to add Bitmap and Drawable files over this kind of zone.

I checked these links on the forum but nothing resolved my problem yet:
How to add an image to a pdf? (Android)
NPE in annotation.setIcon(String, PageContent)
Bitmap Annotations does not show image

This works great:
page.ObjsStart();
page.AddAnnotURI(rect, function);
m_view.vRenderAsync(m_vpage);

But this doesn't display my Bitmap:
page.ObjsStart();
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.my_drawable);
PageContent pageContent = new PageContent();
pageContent.Create();
pageContent.GSSave();
com.radaee.pdf.Matrix mat = new com.radaee.pdf.Matrix(rect[0], rect[1], rect[2], rect[3]);
pageContent.GSSetMatrix(mat);
mat.Destroy();
Document.DocImage docimage = m_doc.NewImage(bitmap, false);
page.AddAnnotBitmap(bitmap, false, rect);
//Page.ResImage rimage = page.AddResImage(docimage);
//pageContent.DrawImage(rimage);
pageContent.GSRestore();
pageContent.Destroy();
page.Close();
m_view.vRenderAsync(m_vpage);

I put comments on the Page.ResImage lines: it crashes because docimage is null, so maybe the problem is here?
Even if I save the document after, the pictures are not displayed.

License Type: RadaeePDF Professional
SDK Version: 3.1

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

Display Bitmap and Drawable contents on the pages 3 years 1 month ago #9650

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Karma: 17
  • Thank you received: 65
Hi,
yes the problem is that you are using a very old version of the library, the methods used in the knowledge base article are new and available from the new versions of the library.
I suggest you to upgrade your library and all will work.

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

Last edit: by Davide.

Display Bitmap and Drawable contents on the pages 3 years 1 month ago #9659

  • jorisk
  • jorisk's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 37
  • Karma: 1
  • Thank you received: 0
Hi Davide,
I upgraded the library to the 3.5.1 version but it still doesn't work.
You were right for the version because now few methods are recognized, but:
- docimage still return null,
- res is not declared so I must put comments on the line where the variable res is used.
PageContent pageContent = new PageContent();
pageContent.Create();
pageContent.GSSave();
com.radaee.pdf.Matrix mat = new com.radaee.pdf.Matrix(rect[0], rect[1], rect[2], rect[3]);
pageContent.GSSetMatrix(mat);
mat.Destroy();
Document.DocImage docimage = m_doc.NewImage(bitmap, false); // I got "docimage: null"
page.AddAnnotBitmap(bitmap, false, rect);
ResImage rimage = page.AddResImage(docimage); // I changed this line because Page.ResImage is not working
pageContent.DrawImage(rimage);
pageContent.GSRestore();
//res = page.AddContent(pageContent, false);
pageContent.Destroy();
page.Close();

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

Display Bitmap and Drawable contents on the pages 3 years 1 month ago #9660

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Karma: 17
  • Thank you received: 65
Hi,
to use these methods you need a premium license. What kind of License do you have?
I have removed "res" from the article: www.radaeepdf.com/support/knowledge-base?view=kb&kbartid=27
"Res" was a boolean used to check the result of the page.AddContent(pageContent, false); method.

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

Display Bitmap and Drawable contents on the pages 3 years 1 month ago #9662

  • jorisk
  • jorisk's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 37
  • Karma: 1
  • Thank you received: 0
We have a RadaeePDF Professional license. You should add the need of this license in this article too.

We only need this function in the Premium license. Is there any workaround for this?

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

Display Bitmap and Drawable contents on the pages 3 years 1 month ago #9663

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Karma: 17
  • Thank you received: 65
Hi,
sorry but with your license you can add an image using annotation (AddAnnotBitmap(Bitmap, boolean, float[])). as written in the license specification page : www.radaeepdf.com/ecommerce/technical-specification

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

Powered by Kunena Forum