你好我正在使用这个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);
}
答案 0 :(得分:2)
我不明白您使用reinterpret_cast
的原因,并且在构建data1
时肯定会被误用。
您是否只是尝试过:
PoDoFo::PdfString sTitle([title UTF8String]);
PoDoFo::PdfString sContent([content UTF8String]);
PoDoFo::PdfFileSpec data1([myString UTF8String], true, doc);