Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use the PoDoFo library for annotating PDFs on iOS?

I would like to annotate PDFs within an iOS application. I came across the PoDoFo library, but I'm not sure how to use this in an iOS application.

Is it possible to use this library to annotate PDFs on iOS? If so, how?

like image 850
siva Avatar asked Oct 04 '11 05:10

siva


People also ask

How to Annotate PDFs on iPad?

Here's how to annotate a PDF on an iPad. Hit Select A File to navigate to your file, whether it's on your iPad or a cloud-based service. Sign in to make annotations, and use the tools to highlight, strike through, or add text. Add new comments or reply to previous ones.


1 Answers

Please do something like this.

+ (void)createUTFAnnotationTextOnPage:(NSInteger)pageIndex 
                                  doc:(PdfDocument*)doc   // PdfMemDocument instance
                                 rect:(PdfRect)rect 
                                title:(NSString*)title 
                              content:(NSString*)content
                                bOpen:(Boolean)bOpen
                               colorR:(double)r 
                               colorG:(double)g 
                               colorB:(double)b {
    PdfPage* pPage = doc->GetPage(pageIndex);
    if (! pPage) {
        // couldn't get that page
        return;
    }
    PdfAnnotation* anno;

    anno = pPage->CreateAnnotation(ePdfAnnotation_Text, rect);

    PdfString sTitle(reinterpret_cast<const pdf_utf8*>([title UTF8String]));
    PdfString sContent(reinterpret_cast<const pdf_utf8*>([content UTF8String]));

    anno->SetTitle(sTitle);
    anno->SetContents(sContent);
    anno->SetColor(r, g, b);
    anno->SetOpen(bOpen);
}

// ----------- 
    PdfError::EnableDebug(false);   // or true
    NSString* inFile = [[NSBundle mainBundle] pathForResource:@"forTesting.pdf" ofType:nil];
    PoDoFo::PdfMemDocument doc( [inFile UTF8String] );
    [YourPodofoObj createUTFAnnotationTextOnPage:0 doc:&doc rect:PdfRect(50, 50, 50, 50) title:@"author by XX" content:@"I use it for test" bOpen:true colorR:1.0 colorG:.0 colorB:.0];
    doc.Write(OUT_PUT_PATH);
like image 124
Alix Avatar answered Oct 11 '22 21:10

Alix