Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF
  • Page:
  • 1

TOPIC:

Conversion coordintes 6 years 7 months ago #12836

  • ichrak22
  • ichrak22's Avatar Topic Author
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 2
  • Thank you received: 0
Hello,
How can I calculte the right position of an Object within PDF through PDF_RECT ?
What is the error in the code snippet below?
 struct PDFV_POS pos1;
    PDF_RECT rect;
    [m_view vGetPos:&pos1 :frame.origin.x * m_scale :frame.origin.y * m_scale];
    rect.left = pos1.x;
    rect.top = pos1.y;
    int dx;
    int dy;
    [m_view vGetDeltaToCenterPage:pos1.pageno :&dx :&dy];
    y =(rect.top +self.contentOffset.y + dy)/m_scale;
       x =(rect.left+self.contentOffset.x + dx)/m_scale ;
Thank you

Please Log in or Create an account to join the conversation.

Conversion coordintes 6 years 7 months ago #12837

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,

you can take a look at onSingleTap method of PDFView class, where it get the rect of a selected annotation and convert it to screen size in this way:
[m_annot getRect:&m_annot_rect];
m_annot_rect.left = [vpage GetX] - self.contentOffset.x * m_scale + [vpage ToDIBX:m_annot_rect.left];
m_annot_rect.right = [vpage GetX] - self.contentOffset.x * m_scale + [vpage ToDIBX:m_annot_rect.right];
float tmp = m_annot_rect.top;
m_annot_rect.top = [vpage GetY] - self.contentOffset.y * m_scale + [vpage ToDIBY:m_annot_rect.bottom];
m_annot_rect.bottom = [vpage GetY] - self.contentOffset.y * m_scale + [vpage ToDIBY:tmp];

Then you can get the CGRect with something like:
CGRectMake(m_annot_rect.left, m_annot_rect.top, m_annot_rect.right - m_annot_rect.left, m_annot_rect.bottom - m_annot_rect.top)
The following user(s) said Thank You: ichrak22

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum