Create custom Annotation from coordinates - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about iOS development and PDF
  • Page:
  • 1

TOPIC: Create custom Annotation from coordinates

Create custom Annotation from coordinates 4 weeks 1 day ago #14208

  • Faris
  • Faris's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
Hi support team,

I would like to create custom rectangular annotations, based on coordinates received (x, y, height, width) , programmatically on the PDF files when the viewer started.
Would also want the annotations to be clickable to do some actions (open a new view controller / alertDialog etc.)

For example,
I would like to annotate the text like in attachment picture, and the user will be only able to click on them but can't do any editing.

Would like ask the support team whether this possible with radaeepdf kit?

Thanks in advance,
Faris
Attachments:

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

Create custom Annotation from coordinates 3 weeks 2 days ago #14212

  • emanuele
  • emanuele's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 525
  • Karma: 20
  • Thank you received: 60
Dear Faris,

if you want to add an annotation using the view coordinate system, you can add this slice of code in PDFView class and customize it based on your needs:
    // get the vpage to calculate the annot size based on current scale value
    PDFVPage *vpage = [m_view vGetPage:0];
    PDFPage *page = [vpage GetPage];
    
    // customize this part to modify the rect size and position
    int x = 50;
    int y = 100;
    int width = 500;
    int height = 100;
    
    // convert the coordinate system from screen to pdf
    struct PDFV_POS pos1;
    struct PDFV_POS pos2;
    
    [m_view vGetPos:&pos1 :(x - self.contentOffset.x) * m_scale :(y - self.contentOffset.y) * m_scale];
    [m_view vGetPos:&pos2 :(x - self.contentOffset.x + width) * m_scale :(y - self.contentOffset.y + height) * m_scale];
    
    PDF_RECT rect;
    
    rect.left = pos1.x;
    rect.right = pos2.x;
    rect.top = pos2.y;
    rect.bottom = pos1.y;
    
    // add the annotation
    [page addAnnotRect:&rect: g_rect_Width * m_scale / [m_view vGetScaleMin:0]: g_rect_color: 0];
    
    // refresh the page
    [m_view vRenderSync:0];
    [self refresh];

this code shows how to add a rect annotation on page 0, then you can add your custom action on OnAnnotClicked method of RDPDFViewController class
The following user(s) said Thank You: Faris

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

Create custom Annotation from coordinates 1 week 4 days ago #14229

  • smgtechmobile
  • smgtechmobile's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 0
Hi Emanuele,

Can this annotation method be done on a Swift project?

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

Create custom Annotation from coordinates 1 week 4 days ago #14230

  • emanuele
  • emanuele's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 525
  • Karma: 20
  • Thank you received: 60
Hi,

the Swift module is distributed with the Obj-C lib project and you are free to add this feature and create a custom library with the make file.

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

  • Page:
  • 1
Powered by Kunena Forum