Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

Display Bitmap and Drawable contents on the pages

More
10 years 6 months ago #9648 by jorisk
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:
Code:
page.ObjsStart(); page.AddAnnotURI(rect, function); m_view.vRenderAsync(m_vpage);

But this doesn't display my Bitmap:
Code:
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
More
10 years 6 months ago - 10 years 6 months ago #9650 by Davide
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.
Last edit: 10 years 6 months ago by Davide.
More
10 years 6 months ago #9659 by jorisk
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.
Code:
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();
More
10 years 6 months ago #9660 by Davide
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.
More
10 years 6 months ago #9662 by jorisk
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?
More
10 years 6 months ago #9663 by Davide
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
Time to create page: 0.416 seconds
Powered by Kunena Forum