- 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
Convert PDF coordinates to view layout coord
IP: 192.168.0.71
8 years 6 months ago #12883
by geertvm
Convert PDF coordinates to view layout coord was created by geertvm
Hi,
I have a custom layout (RelativeLayout) which holds a PDFLayoutView
and a custom toolbar (also a RelativeLayout with some imagebuttons)
First of all I want to detect if the user tapped on a visible signature field.
I think we can handle that by implementing the setOnTouchListener and converting the raw x and
y coordinates with the PDFLayout.PDFPos pdfPos = m_view.PDFGetPos(x, y);
I also want to draw some kind of overlay on visible signature fields (with known PDF coordinates).
I've started by implementing the PDFLayoutView.PDFLayoutListener() and the OnPageDisplayed
So I suppose it could be possible to draw a rectangle on the canvas...
How can I convert these PDF coordinates to the layout coordinates so that I can draw an rectangle on top of a visible signature field
(It's possible that this field is only visible after some scrolling...)
Thanks
Geert
I have a custom layout (RelativeLayout) which holds a PDFLayoutView
and a custom toolbar (also a RelativeLayout with some imagebuttons)
First of all I want to detect if the user tapped on a visible signature field.
I think we can handle that by implementing the setOnTouchListener and converting the raw x and
y coordinates with the PDFLayout.PDFPos pdfPos = m_view.PDFGetPos(x, y);
I also want to draw some kind of overlay on visible signature fields (with known PDF coordinates).
I've started by implementing the PDFLayoutView.PDFLayoutListener() and the OnPageDisplayed
So I suppose it could be possible to draw a rectangle on the canvas...
How can I convert these PDF coordinates to the layout coordinates so that I can draw an rectangle on top of a visible signature field
(It's possible that this field is only visible after some scrolling...)
Thanks
Geert
IP: 192.168.0.71
8 years 6 months ago - 8 years 6 months ago #12887
by nermeen
Replied by nermeen on topic Convert PDF coordinates to view layout coord
You can implement PDFLayoutListener.OnPDFAnnotTapped (which get fired when an annot is tapped) and filter based on Annot type and annot filed type to detect a signature field.
You can also get the annotation rectangle (position) in PDF coordinates and convert it to view coordinates to be used later in OnPageDisplayed, check the below code:
Note: m_view.PDFGetX() and m_view.PDFGetY() are introduced in the latest version 3.14.2, you can add them in PDFLayoutView:
You can also get the annotation rectangle (position) in PDF coordinates and convert it to view coordinates to be used later in OnPageDisplayed, check the below code:
Code:
@Override
public void OnPDFAnnotTapped(VPage vpage, Annotation annot)
{
...
if(annot != null && annot.GetType() == 20 && annot.GetFieldType() == 4) {
float[] annotRect = annot.GetRect();
float tmp = annotRect[1];
annotRect[0] = vpage.GetVX(annotRect[0]) - m_view.PDFGetX();
annotRect[1] = vpage.GetVY(annotRect[3]) - m_view.PDFGetY();
annotRect[2] = vpage.GetVX(annotRect[2]) - m_view.PDFGetX();
annotRect[3] = vpage.GetVY(tmp) - m_view.PDFGetY();
}
...
}
Code:
public float PDFGetX() {
return m_layout != null ? m_layout.vGetX() : 0;
}
public float PDFGetY() {
return m_layout != null ? m_layout.vGetY() : 0;
}
Last edit: 8 years 6 months ago by nermeen.
IP: 192.168.0.71
8 years 6 months ago #12888
by geertvm
Replied by geertvm on topic Convert PDF coordinates to view layout coord
The digital signature field isn't recognized...
but the code helped me in displaying the overlay...
but the code helped me in displaying the overlay...
IP: 192.168.0.71
8 years 6 months ago #12891
by nermeen
Replied by nermeen on topic Convert PDF coordinates to view layout coord
The pdf you have sent does not contain a signature field (it only contains a text).
As a consequence the code above wont work.
Same behavior with Acrobat and other readers.
As a consequence the code above wont work.
Same behavior with Acrobat and other readers.
IP: 192.168.0.71
8 years 6 months ago #12893
by geertvm
Replied by geertvm on topic Convert PDF coordinates to view layout coord
sorry, uploaded the wrong pdf... 
This one has 2 visible signature fields...
This one has 2 visible signature fields...
IP: 192.168.0.71
8 years 6 months ago #12894
by nermeen
Replied by nermeen on topic Convert PDF coordinates to view layout coord
We have tested your new pdf with the above code, and the annotations can be recognized.
Can you retest by adding the above code into the demo project?
Can you retest by adding the above code into the demo project?
Time to create page: 0.395 seconds