Knowledge Base - How to add Edit PDF Text annotation on iOS using RadaeePDF

This article shows how to add an Edit Text annotation to a pdf:

if is not available, add addEditTextBox method in PDFObjc class (in PDFPage implementation):

-(bool)addEditTextBox:(const PDF_RECT *)rect :(int) line_clr :(float) line_w :(int) fill_clr :(float) tsize :(int) text_clr
{
    return Page_addAnnotEditbox2(m_page, rect, line_clr, line_w, fill_clr, tsize, text_clr);
}

Then add vAddEditText method in PDFView class:

-(void)vAddEditText:(CGPoint)point

{

    PDF_RECT rect;

    rect.left=point.x;

    rect.right=point.x + 300;

    rect.top=point.y;

    rect.bottom=point.y + 50;

    PDFVPage *vpage = [m_view vGetPage:m_cur_page];

    if( !vpage ) return;

    PDFPage *page = [vpage GetPage];

    if (!page) {

        return;

    }

    PDFMatrix *mat = [vpage CreateInvertMatrix:self.contentOffset.x * m_scale :self.contentOffset.y * m_scale];

    [mat transformRect:&rect];

    [page addEditTextBox:&rect :0xFF000000 :0xFFFF00FF :0xFFFFFFFF :12 :0xFFFF0000];

    PDFAnnot *textAnnot = [page annotAtIndex: [page annotCount] - 1];

    [textAnnot setEditText:@"example text"];

    [m_view vRenderSync:m_cur_page];

    [self refresh];

    [m_doc save];

} 

vAddEditText method will add an Edit Text in a specific point.

rect.right and rect.bottom are width and height of the Edit Text and you can customize also these values

You can call vAddEditText in RDPDFViewController with something like:

//Add the Edit Text
[m_view vAddEditText:CGPointMake(100, 100)];

 

Applies To

RadaeePDF SDK for iOS

Details

Created : 2016-02-08 11:41:04, Last Modified : 2021-05-27 13:37:07