-1

您好,我正在使用这个来实现注释,但面临一个图像附件问题,它提供了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);
}
4

1 回答 1

2

我不明白你为什么要使用reinterpret_cast,而且它肯定被滥用在data1.

您是否简单地尝试过:

PoDoFo::PdfString sTitle([title UTF8String]);
PoDoFo::PdfString sContent([content UTF8String]);
PoDoFo::PdfFileSpec data1([myString UTF8String], true, doc);
于 2013-08-22T08:07:28.800 回答