如何使用PoDoFo库在iOS上注释PDF? [英] How can I use the PoDoFo library for annotating PDFs on iOS?

查看:159
本文介绍了如何使用PoDoFo库在iOS上注释PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iOS应用程序中注释PDF。我遇到了 PoDoFo库,但我不确定如何在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.

是否可以使用此库在iOS上注释PDF?如果是这样,怎么样?

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

推荐答案

请做这样的事情。

+ (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);

这篇关于如何使用PoDoFo库在iOS上注释PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆