Convert or Print CGPDFStringRef string

廉价感情. 提交于 2019-12-06 00:49:03

NSString is capable of handling of unicode characters itself, you just need to convert the CGPDFString to NSString and further you can use it as follows:

NSString *tempStr = (NSString *)CGPDFStringCopyTextString(objectString);

although UPT's answer is correct, it will produce a memory leak

from the documentation: CGPDFStringCopyTextString "...You are responsible for releasing this object."

the correct way to do this would be:

CFStringRef _res = CGPDFStringCopyTextString(pdfString);
NSString *result = [NSString stringWithString:(__bridge NSString *)_res];
CFRelease(_res);

It's not a bad idea, even if you can access the CGPDFString directly using CGPDFStringGetBytePtr. You will also need CGPDFStringGetLength to get the string length, as it may not be null-terminated.

See the documentation for more info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!