- Posts: 34
- Thank you received: 0
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
Add Handwriting Annotation
- sparklellama
- Topic Author
- Offline
- Junior Member
-
Less
More
IP: 192.168.0.70
12 years 2 months ago #4932
by sparklellama
Add Handwriting Annotation was created by sparklellama
The following code is intended to insert an HWriting annotation into a PDF. The HWriting has been perviously successfully drawn. However, the code only causes the HWriting to vanish. It is not inserted into the PDF. I have used this code pattern successfully for other annotation types (Ink, Rects, Circles, Comments etc), but it does not work for HWriting. Any clues? Thanks if you can help.
Code:
// elsewhere mWw is defined as new HWriting([view width], [view height], 1.0f, 3.0f, 0, 0, 0);
@Override
public void persist(PDFVPage vpage, int x, int y)
{
Page page = vpage.GetPage();
if (page != null)
{
Matrix mat = vpage.CreateMatrix();
Log.v(this.getClass().getName(), String.format("Persisting hWriting at: %d %d", -vpage.GetVX(x), -vpage.GetVY(y)));
page.ObjsStart(); // Docs suggest that this might be a good idea, but doesn't seem to help
page.AddAnnotHWriting(mat, mHw,-vpage.GetVX(x), -vpage.GetVY(y)); // TODO: NOT WORKING
mat.Destroy();
}
}
IP: 192.168.0.70
12 years 2 months ago #4935
by radaee
Replied by radaee on topic Add Handwriting Annotation
plz check this:
Code:
@Override
public void persist(PDFVPage vpage)
{
Page page = vpage.GetPage();
if (page != null)
{
Matrix mat = vpage.CreateMatrix();
Log.v(this.getClass().getName(), String.format("Persisting hWriting at: %d %d", -vpage.GetVX(x), -vpage.GetVY(y)));
page.ObjsStart(); // Docs suggest that this might be a good idea, but doesn't seem to help
page.AddAnnotHWriting(mat, mHw,-vpage.GetVX(m_view.vGetX()), -vpage.GetVY(m_view.vGetY())); // TODO: NOT WORKING
mat.Destroy();
}
}
- sparklellama
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 34
- Thank you received: 0
IP: 192.168.0.70
12 years 2 months ago #4936
by sparklellama
Replied by sparklellama on topic Add Handwriting Annotation
Thanks so much for the suggestion. Unfortunately this time, it didn't have any effect. Let me know if you have any more ideas… thanks so much.
IP: 192.168.0.70
12 years 2 months ago - 12 years 2 months ago #4938
by radaee
Replied by radaee on topic Add Handwriting Annotation
i tested it, and fixed some bugs for this method. plz wait.
and try these codes for next version:
and try these codes for next version:
Code:
Init:
private HWriting m_writing = null;
m_writing = new HWriting( getWidth(), getHeight(), 1, 5, 255, 0, 0 );
case onTouchDown:
m_writing.OnDown(event.getX(), event.getY());
PDFPos pos = m_view.vGetPos((int)event.getX(), (int)event.getY());
PDFVPage vpage = m_view.vGetPage(pos.pageno);
case onTouchMove:
m_writing.OnMove(event.getX(), event.getY());
case onTouchUp:
m_writing.OnUp(event.getX(), event.getY());
Add to page:
Page page = vpage.GetPage();
Matrix mat = vpage.CreateMatrix();
page.AddAnnotHWriting(mat, m_writing, -vpage.GetVX(m_view.vGetX()), -vpage.GetVY(m_view.vGetY()));
mat.Destroy();
m_view.vRender(vpage);
m_writing.Destroy();
m_writing = null;
Last edit: 12 years 2 months ago by .
IP: 192.168.0.158
12 years 2 months ago #4943
by nermeen
Replied by nermeen on topic Add Handwriting Annotation
A new version
2.9.7beta5
has been pubblished..
This contains a fix to HWriting annotation
This contains a fix to HWriting annotation
- sparklellama
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 34
- Thank you received: 0
IP: 192.168.0.70
12 years 2 months ago #4956
by sparklellama
Replied by sparklellama on topic Add Handwriting Annotation
Thank you for the new beta version of the library. Unfortunately there was no change upon upgrading to the new library. I have updated the code to more closely reflect your example, but no luck. Thanks if you have any more ideas.
Code:
create:
mView = view;
mAndroidView = aview;
// width, height, min stroke width, max stroke width, 3x # = RGB col
mHw = new HWriting(mAndroidView.getWidth(), mAndroidView.getHeight(),
1.0f, 3.0f, 0, 0, 0);
mBitmap = Bitmap.createBitmap(mAndroidView.getWidth(),
mAndroidView.getHeight(), Bitmap.Config.ARGB_8888);
draw:
mBitmap.eraseColor(0);
int hndl = Global.lockBitmap(mBitmap);
mHw.OnDraw(hndl);
Global.unlockBitmap(mBitmap, hndl);
c.drawBitmap(mBitmap, 0, 0, null);
touchDown:
mHw.OnDown(x, y);
PDFPos pos = mView.vGetPos((int)x, (int)y);
aPage = mView.vGetPage(pos.pageno);
touchMove:
mHw.OnMove(x, y);
touchUp:
mHw.OnUp(x, y);
persist to page:
Page page = aPage.GetPage();
if (page != null)
{
Matrix mat = aPage.CreateMatrix();
Log.v(this.getClass().getName(),
String.format("Persisting hWriting at: %d %d",
vpage.GetVX(mView.vGetX()),
-vpage.GetVY(mView.vGetY())));
page.ObjsStart(); // Docs suggest that this might be a good idea,
// but doesn't seem to help
page.AddAnnotHWriting(mat, mHw, -vpage.GetVX(mView.vGetX()),
-vpage.GetVY(mView.vGetY())); // Not working
mat.Destroy();
mView.vRender(aPage);
mHw.Destroy();
mHw = null;
}
Time to create page: 0.462 seconds