Converting a pdf image to NSData for Parse.com

╄→гoц情女王★ 提交于 2019-12-25 04:15:11

问题


I am using vector graphics in my application and want to store some on Parse.com. I need to first convert these to NSData before upload. Is it possible to convert a pdf file to NSData?

UIImage *image = [UIImage imageNamed:@"coolImage.pdf"];
NSData *data = UIImageJPEGRepresentation(image);

I know NSData allows for a jpg of png representation but what about pdfs? Any tips on this would be greatly appreciated!


回答1:


//to convert pdf to NSData
NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@"test.pdf"]; 
NSData *myData = [NSData dataWithContentsOfFile:pdfPath]; 


来源:https://stackoverflow.com/questions/28849795/converting-a-pdf-image-to-nsdata-for-parse-com

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