hello. i want to set custom annotation icon. i use this code:
Page mPage = m_doc.GetPage(m_pageno);
if (mPage != null) {
mPage.ObjsStart();
Annotation annotation = mPage.GetAnnot(mPage.GetAnnotCount() - 1);
if (annotation != null) {
Document.DocForm form = m_doc.NewForm();
PageContent content = new PageContent();
content.Create();
Bitmap icon = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.pdf_custom_stamp);
Document.DocImage dimg = m_doc.NewImage(icon, true);
ResImage rimg = form.AddResImage(dimg);
Matrix mat = new Matrix( 20, 20, 0, 0 );
content.GSSetMatrix(mat);
mat.Destroy();
content.DrawImage(rimg);
content.GSRestore();
form.SetContent(content, 0, 0, 20, 20);
boolean success = annotation.SetIcon("MyIcon", form);
icon.recycle();
content.Destroy();
}
mPage.Close();
}
but i have problem with this line: ResImage rimg = form.AddResImage(dimg);
I got rimg = null and icon doesnt change.
method AddResImage(dimg) is:
public ResImage AddResImage(Document.DocImage dimg)
{
if(dimg == null) return null;
long ret = addFormResImage(m_doc.hand_val, hand, dimg.hand);
if(ret == 0) return null;
ResImage res_img = new ResImage();
res_img.hand = ret;
return res_img;
}
and native method addFormResImage(m_doc.hand_val, hand, dimg.hand) return 0.
What are the reasons for this?