RadaeePDF.com :: Topic: Conversion coordintes (1/1)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about iOS development and PDF

TOPIC: Conversion coordintes

Conversion coordintes 2 months 1 week ago #12836

  • ichrak22
  • ichrak22's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 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
The administrator has disabled public write access.

Conversion coordintes 2 months 6 days ago #12837

  • emanuele
  • emanuele's Avatar
  • OFFLINE
  • Moderator
  • Posts: 440
  • Thank you received: 50
  • Karma: 14
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 administrator has disabled public write access.
The following user(s) said Thank You: ichrak22
Powered by Kunena Forum