Kex Kex - 20 days ago 6
iOS Question

Converting a pdf image to NSData for Parse.com

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!

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