- Posts: 20
- 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
Caching highlights outside of PDF file
9 years 11 months ago #11282
by mrawy
Replied by mrawy on topic Caching highlights outside of PDF file
I called them before: page.AddAnnotMarkup(m_index1, m_index2, 0);
The result:
Code:
public void OnPDFSelectEnd()
{
PDFPos pos = m_view.vGetPos((int)myRects[0], (int)myRects[1]);
PDFVPage vpage = m_view.vGetPage(pos.pageno);
Page page = vpage.GetPage();
if( page != null )
{
page.ObjsStart();
float pt[] = new float[2];
pt[0] = pos.x;
pt[1] = pos.y;
int m_index1 = page.ObjsGetCharIndex(pt);
m_index1 = page.ObjsAlignWord(m_index1, -1);
pt[0] = vpage.ToPDFX(myRects[2], m_view.vGetX());
pt[1] = vpage.ToPDFY(myRects[3], m_view.vGetY());
int m_index2 = page.ObjsGetCharIndex(pt);
m_index2 = page.ObjsAlignWord(m_index2, 1);
page.AddAnnotMarkup(m_index1, m_index2, 0);
m_view.vRenderSync(vpage);
if( m_listener != null )
m_listener.OnPageModified(vpage.GetPageNo());
}
// if( m_listener != null )
// m_listener.OnSelectEnd(m_view.vGetSel());
}
9 years 11 months ago - 9 years 11 months ago #11289
by nermeen
Replied by nermeen on topic Caching highlights outside of PDF file
We have just tested your code, and it's working (the difference in only in the rect variables).
Make sure that index1 is smaller than index2:
Did you try with other documents? if this happens with only one pdf, can you send it to us please.
Make sure that index1 is smaller than index2:
Code:
float pt[] = new float[2];
pt[0] = x1;
pt[1] = y1;
m_index1 = m_page.ObjsGetCharIndex(pt);
pt[0] = x2;
pt[1] = y2;
m_index2 = m_page.ObjsGetCharIndex(pt);
if( m_index1 > m_index2 )
{
int tmp = m_index1;
m_index1 = m_index2;
m_index2 = tmp;
}
m_index1 = m_page.ObjsAlignWord(m_index1, -1);
m_index2 = m_page.ObjsAlignWord(m_index2, 1);
Did you try with other documents? if this happens with only one pdf, can you send it to us please.
Last edit: 9 years 11 months ago by nermeen.
9 years 11 months ago #11317
by mrawy
Replied by mrawy on topic Caching highlights outside of PDF file
Hi, It's working on English content only but not working properly on Arabic content.
Please check the attached screenshots and you can test it on attached file.
Your fast response is highly appreciated.
Please check the attached screenshots and you can test it on attached file.
Your fast response is highly appreciated.
9 years 11 months ago #11319
by nermeen
Replied by nermeen on topic Caching highlights outside of PDF file
Dear Mrawy,
We couldn't reproduce the issue usinf your file, can you reproduce it using the demo project?
Can you tells us the steps used to reproduce it?
We couldn't reproduce the issue usinf your file, can you reproduce it using the demo project?
Can you tells us the steps used to reproduce it?
9 years 11 months ago #11320
by mrawy
Replied by mrawy on topic Caching highlights outside of PDF file
Hi,
Steps to reproduce this issue using the demo project:
1- Modify PDFReader.class OnPDFSelecting method to be:
2- Modify PDFReader.class OnPDFSelectEnd method to be:
Or use attached PDFReader.class
Steps to reproduce this issue using the demo project:
1- Modify PDFReader.class OnPDFSelecting method to be:
Code:
public void OnPDFSelecting(Canvas canvas, int[] rect1, int[] rect2)
{
Paint paint = new Paint();
paint.setARGB(0x80, 0, 0, 0x80);
if( rect2[1] > rect1[3] )
{
canvas.drawCircle( rect1[0], rect1[1], 5, paint);
canvas.drawCircle( rect2[2], rect2[3], 5, paint);
float[] rect = new float[3];
rect[0] = rect1[0];
rect[1] = rect1[1];
rect[2] = rect2[2];
rect[3] = rect2[3];
myRects = rect;
}
else
{
canvas.drawCircle( rect2[0], rect2[1], 5, paint);
canvas.drawCircle( rect1[2], rect1[3], 5, paint);
float[] rect = new float[4];
rect[0] = rect2[0];
rect[1] = rect2[1];
rect[2] = rect1[2];
rect[3] = rect1[3];
myRects = rect;
}
}
Code:
public void OnPDFSelectEnd()
{
PDFPos pos = m_view.vGetPos((int)myRects[0], (int)myRects[1]);
PDFVPage vpage = m_view.vGetPage(pos.pageno);
Page page = vpage.GetPage();
if( page != null )
{
page.ObjsStart();
float pt[] = new float[2];
pt[0] = pos.x;
pt[1] = pos.y;
int m_index1 = page.ObjsGetCharIndex(pt);
// m_index1 = page.ObjsAlignWord(m_index1, -1);
pt[0] = vpage.ToPDFX(myRects[2], m_view.vGetX());
pt[1] = vpage.ToPDFY(myRects[3], m_view.vGetY());
int m_index2 = page.ObjsGetCharIndex(pt);
// m_index2 = page.ObjsAlignWord(m_index2, 1);
page.AddAnnotMarkup(m_index1, m_index2, 0);
m_view.vRenderSync(vpage);
if( m_listener != null )
m_listener.OnPageModified(vpage.GetPageNo());
}
// if( m_listener != null )
// m_listener.OnSelectEnd(m_view.vGetSel());
}
9 years 11 months ago #11322
by nermeen
Replied by nermeen on topic Caching highlights outside of PDF file
Dear Mrawy,
Try the following implementation (passing directly the rect values to the select end listener):
Change the OnPDFSelectEnd in PDFViewListener to:
In PDFView.motionSelect change the call to the listener to:
And finally change the implementation of the listener itself as:
Note; if you do not have the source code of the jar, please check here
Try the following implementation (passing directly the rect values to the select end listener):
Change the OnPDFSelectEnd in PDFViewListener to:
Code:
public void OnPDFSelectEnd(float x1, float y1, float x2, float y2);
Code:
if( m_listener != null ) m_listener.OnPDFSelectEnd(m_holdx, m_holdy, m_movex, m_movey);
Code:
public void OnPDFSelectEnd(float x1, float y1, float x2, float y2)
{
PDFPos pos = m_view.vGetPos((int)x1, (int)y1);
PDFVPage vpage = m_view.vGetPage(pos.pageno);
Page page = vpage.GetPage();
if( page != null )
{
page.ObjsStart();
float pt[] = new float[2];
pt[0] = pos.x;
pt[1] = pos.y;
int m_index1 = page.ObjsGetCharIndex(pt);
pt[0] = vpage.ToPDFX(x2, m_view.vGetX());
pt[1] = vpage.ToPDFY(y2, m_view.vGetY());
int m_index2 = page.ObjsGetCharIndex(pt);
if( m_index1 > m_index2 )
{
int tmp = m_index1;
m_index1 = m_index2;
m_index2 = tmp;
}
m_index1 = page.ObjsAlignWord(m_index1, -1);
m_index2 = page.ObjsAlignWord(m_index2, 1);
page.AddAnnotMarkup(m_index1, m_index2, 0);
m_view.vRenderSync(vpage);
if( m_listener != null )
m_listener.OnPageModified(vpage.GetPageNo());
}
// if( m_listener != null )
// m_listener.OnSelectEnd(m_view.vGetSel());
}
Note; if you do not have the source code of the jar, please check here
Time to create page: 0.421 seconds