【问题标题】:how to add FileAttachment annotations of pdf如何添加pdf的FileAttachment注释
【发布时间】:2013-08-22 08:00:04
【问题描述】:

您好,我正在使用此 library 执行注释,但面临一个图像附件问题,它提供了 PdfFileSpec 目标 c++ 函数我试图将此函数转换为目标 c,但在下图中出现错误

class PODOFO_DOC_API PdfFileSpec : public PdfElement {
 public:
    PdfFileSpec( const char* pszFilename, bool bEmbedd, PdfDocument* pParent );

    PdfFileSpec( const char* pszFilename, bool bEmbedd, PdfVecObjects* pParent );

    /* Petr P. Petrov 17 September 2009*/
    /** Embeds the file in memory from "data" buffer under "pszFileName" fie name.
      */
    PdfFileSpec( const char* pszFilename, const unsigned char* data, ptrdiff_t size, PdfVecObjects* pParent);

    PdfFileSpec( PdfObject* pObject );

    /** \returns the filename of this file specification.
     *           if no general name is available 
     *           it will try the Unix, Mac and DOS keys too.
     */
    const PdfString & GetFilename() const;

 +(void)createFreeTextAnnotationOnPage:(NSInteger)pageIndex doc:(PdfMemDocument*)aDoc rect:(CGRect)aRect borderWidth:(double)bWidth title:(NSString*)title content:(NSString*)content bOpen:(Boolean)bOpen color:(UIColor*)color {
    PoDoFo::PdfMemDocument *doc = (PoDoFo::PdfMemDocument *) aDoc;
    PoDoFo::PdfPage* pPage = doc->GetPage(pageIndex);
    if (! pPage) {
        // couldn't get that page
        return;
    }
    PoDoFo::PdfAnnotation* anno;
    PoDoFo::EPdfAnnotation type= PoDoFo::ePdfAnnotation_Text;

    PoDoFo::PdfRect rect;
    rect.SetBottom(aRect.origin.y);
    rect.SetLeft(aRect.origin.x);
    rect.SetHeight(aRect.size.height);
    rect.SetWidth(aRect.size.width);
    NSData *data=UIImagePNGRepresentation([UIImage imageNamed:@"Add_button.png"]);
    anno = pPage->CreateAnnotation(type , rect);
    NSString *myString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    PoDoFo::PdfString sTitle([title UTF8String]);
    PoDoFo::PdfString sContent([content UTF8String]);
    PoDoFo::PdfFileSpec data1([myString UTF8String], true, doc);
}

【问题讨论】:

    标签: iphone ios objective-c podofo


    【解决方案1】:

    我不明白你为什么使用reinterpret_cast,而且它肯定被滥用在data1 的构造中。

    您是否尝试过:

    PoDoFo::PdfString sTitle([title UTF8String]);
    PoDoFo::PdfString sContent([content UTF8String]);
    PoDoFo::PdfFileSpec data1([myString UTF8String], true, doc);
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 2019-12-03
    • 2020-11-25
    相关资源
    最近更新 更多