将 pdf 图像转换为 Parse.com 的 NSData [英] Converting a pdf image to NSData for Parse.com

查看:54
本文介绍了将 pdf 图像转换为 Parse.com 的 NSData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用矢量图形,并想在 Parse.com 上存储一些.我需要在上传之前先将这些转换为 NSData.是否可以将 pdf 文件转换为 NSData?

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);

我知道 NSData 允许使用 jpg 的 png 表示,但是 pdf 呢?任何有关此的提示将不胜感激!

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

推荐答案

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

这篇关于将 pdf 图像转换为 Parse.com 的 NSData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆