CGPDFDocumentRef from NSData

好久不见. 提交于 2019-11-30 00:32:44
viggio24

You can create a PDF document using this function:

CGPDFDocumentRef CGPDFDocumentCreateWithProvider (
   CGDataProviderRef provider
);

To create the provider you can use this function:

CGDataProviderRef CGDataProviderCreateWithCFData (
   CFDataRef data
);

and consider that NSData and CFDataRef are toll-free bridged so you can use them interchangeably.

So summarizing try this:

NSData *data = ... my data from SQLite ...
CFDataRef myPDFData = (CFDataRef)data;
CGDataProviderRef provider = CGDataProviderCreateWithCFData(myPDFData);
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(provider);

Don't forget to CFRelease all unused data.

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