【发布时间】:2017-06-01 10:05:05
【问题描述】:
我正在尝试在 Objective C 中从 iPhone 中的 iCloud 上传 pdf。以下是我在点击时触发的代码。
UIDocumentPickerViewController *doc = [[UIDocumentPickerViewController alloc]initWithDocumentTypes:@[@"public.composite-content"] inMode:UIDocumentPickerModeImport];
doc.delegate = (id)self;
doc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:doc animated:YES completion:nil];//getting the path of the file selected through didPickDocumentAtURL
NSString *path = [url path];//converting in to data in two different ways but getting truncated nsdata
NSData *data3 = [[NSFileManager defaultManager] contentsAtPath:path];//Truncating
NSData *data1 = [NSData dataWithContentsOfFile:path];//Truncating Both data3 and data1 are getting truncated after 32767 characters.
问题:
- 这是将 .pdf 导入
NSData的正确格式吗? -
NSData有限制吗? (我问这个是因为它在 32767 个字符之后被截断)
【问题讨论】:
-
实际问题/结果是什么?你有什么期待?
-
你为什么不用
CGPDFDocumentCreateWithURL? -
要将 pdf 上传到服务器,我需要将 pdf 转换为 base64 字符串所以我使用 [data3 base64EncodedStringWithOptions:kNilOptions] 将文件转换为数据和数据到 base64String;
-
@PiyushPatel 我是 iOs 家族的新手,到目前为止我还没有使用过 CGPDFDocumentCreateWithURL
标签: ios objective-c pdf nsdata