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

TOPIC:

Freehand drawing Bezier path 10 years 10 months ago #6863

  • Mahesh007
  • Mahesh007's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 16
  • Thank you received: 0
for getting annotation rectangale we have used -(void)getRect:(PDF_RECT *)rect method.
but what is tha parameter of rect. please help on this.

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

Freehand drawing Bezier path 10 years 10 months ago #6865

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
like this:
PDF_RECT rect;
[annot getRect:&rect];

rect is in PDF coordinate, convert to bitmap coordinate like:

rect.left *= scale;
rect.right *= scale;
float height = [PDFPage getHeight];
float tmp - rect.top;
rect.top = (height - rect.bottom) * scale;
rect.bottom = (height - tmp) * scale;

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

Freehand drawing Bezier path 10 years 10 months ago #6867

  • Mahesh007
  • Mahesh007's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 16
  • Thank you received: 0
PDF_RECT rect;
[annot getRect:&rect];
NSLog(@"rectangle %f,%f,%f,%f",rect.top,rect.bottom,rect.left,rect.right);
o/p - 124.070862,267.284729,103.900085,402.496216
but these are wrong cordinate please suggest me if m i doing any wrong implementation.
i want to get annotation frame size on annotation click.
-(void)OnAnnotClicked:(PDFPage *)page :(PDFAnnot *)annot :(float)x :(float)y
in this method

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

Freehand drawing Bezier path 10 years 10 months ago #6869

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
get annotation rect codes like(in [PDFView onSingleTap])
[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];
and draw rect like:
-(void)drawAnnot:(CGContextRef)context
{
    if( m_status == sta_annot )
    {
        int dx = m_tx - m_px;
        int dy = m_ty - m_py;
        CGContextSetLineWidth(context, 1);
        CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
        CGRect rect1 = CGRectMake(self.contentOffset.x + (m_annot_rect.left+dx)/m_scale,
                                  self.contentOffset.y + (m_annot_rect.top+dy)/m_scale,
                                  (m_annot_rect.right - m_annot_rect.left)/m_scale,
                                  (m_annot_rect.bottom - m_annot_rect.top)/m_scale);
        CGContextStrokeRect(context, rect1);
    }
}

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

Freehand drawing Bezier path 10 years 10 months ago #6874

  • Mahesh007
  • Mahesh007's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 16
  • Thank you received: 0
I am using your code from your give step but this gives me wrong cordinate like this.
PDFVPage *pg =[[PDFVPage alloc] init:m_doc :2];
PDF_RECT rect;
float m_scale = [[UIScreen mainScreen] scale];
[annot getRect:&rect];
rect.left = [pg GetX] - m_view.contentOffset.x * m_scale + [pg ToDIBX:rect.left];
rect.right = [pg GetX] - m_view.contentOffset.x * m_scale + [pg ToDIBX:rect.right];
float tmp = rect.top;
rect.top = [pg GetY] - m_view.contentOffset.y * m_scale + [pg ToDIBY:rect.bottom];
rect.bottom = [pg GetY] - m_view.contentOffset.y * m_scale + [pg ToDIBY:tmp];
-2
906
-2
906
if am i doing wrong please suggest me.i want to know annotation frame area. actually i want to capture frame (annotation area) so i will convert into image. please help on this asap.








i have print rect this gives me

m_annot_rect = {
left = 103.89996
top = 124.48999
right = 402.49994

bottom = 267.70996
}


please look mahesh (ink annotation) area. this does not match with area
Attachments:

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

Last edit: by felipe1234. Reason: Add some description.
  • Page:
  • 1
  • 2
Powered by Kunena Forum