- Posts: 16
- 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
OnPDFDoubleTapped parameter
IP: 79.60.238.187
6 years 8 months ago #14521
by tommaso
OnPDFDoubleTapped parameter was created by tommaso
Hi,
I need to read pdf clicked text (With com.radaee.pdf.Page -> "objs") but I've a problem with pdf position,
On OnPDFDoubleTapped event I receive x,y wrong position,
when device is in portrait the position seems to be upsidedown, when in landscape seems correct but page number returned is always the left page regardless of what I click(com.radaee.reader.PDFGLLayoutView -> "PDFGetDoc").
I've found that vGetPos function return correct values but I can't use it without change library and in any case i can't return the right page Nr from double click event
Have any hint
Thanks in advance
Regards Tommaso Honoré
I need to read pdf clicked text (With com.radaee.pdf.Page -> "objs") but I've a problem with pdf position,
On OnPDFDoubleTapped event I receive x,y wrong position,
when device is in portrait the position seems to be upsidedown, when in landscape seems correct but page number returned is always the left page regardless of what I click(com.radaee.reader.PDFGLLayoutView -> "PDFGetDoc").
I've found that vGetPos function return correct values but I can't use it without change library and in any case i can't return the right page Nr from double click event
Have any hint
Thanks in advance
Regards Tommaso Honoré
Code:
final int x = (int)e.getX();
final int y = (int)e.getY();
final GLLayout.PDFPos pos = m_layout.vGetPos(x, y);
m_layout.vSetPos(x, y, pos);
Log.e("", "Pagina " + pos.pageno + ".");
if (m_listener == null || !m_listener.OnPDFDoubleTapped(pos.x, pos.y))
return false;
IP: 212.97.62.176
6 years 8 months ago - 6 years 8 months ago #14524
by luca.f
Replied by luca.f on topic OnPDFDoubleTapped parameter
Dear user,
the coordinates you are receiving from the OnPDFDoubleTapped event are screen coordinates, which always have the origin point in the upper left corner.
PDF instead uses a coordinate system with the origin point located in the bottom left corner.
vGetPos already does this conversion for you, and always returns the correct point/page in pdf coordinates, even when it's zoomed/offset.
Just use:
and then retreive the vaules with pos.x, pos.y and pos.pageno
the coordinates you are receiving from the OnPDFDoubleTapped event are screen coordinates, which always have the origin point in the upper left corner.
PDF instead uses a coordinate system with the origin point located in the bottom left corner.
vGetPos already does this conversion for you, and always returns the correct point/page in pdf coordinates, even when it's zoomed/offset.
Just use:
Code:
final int x = (int)e.getX();
final int y = (int)e.getY();
final GLLayout.PDFPos pos = m_layout.vGetPos(x, y);
Last edit: 6 years 8 months ago by luca.f.
IP: 79.60.238.187
6 years 8 months ago #14527
by tommaso
Replied by tommaso on topic OnPDFDoubleTapped parameter
Ok I've managed my own function to retrieve pdfposition.
Thanks
Thanks
Code:
public GLLayout.PDFPos MyGetPos(float posX, float posY) {
//Trasformo Coordinate view in Coordinate Pdf.
final int x = (int)posX;
final int y = (int)posY;
final GLLayout.PDFPos pos = m_layout.vGetPos(x, y);
return pos;
}
Time to create page: 0.482 seconds