从 Pdf 转换时 NSData 被截断
NSData getting trucated while converting from Pdf
我正尝试在 Objective C 中从 iPhone 中的 iClouds 上传 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 个字符后被截断)
我是调用UIDocumentPickerViewController的delegate方法解决的
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url{
if (controller.documentPickerMode== UIDocumentPickerModeImport) {
//taking the path of the file selected
NSString *path = [url path];
//converting to NSData
NSData *data = [[NSFileManager defaultManager] contentsAtPath:path];
//converting to base64 string
base64String = [data base64EncodedStringWithOptions:kNilOptions];
}
}
我正尝试在 Objective C 中从 iPhone 中的 iClouds 上传 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 个字符后被截断)
我是调用UIDocumentPickerViewController的delegate方法解决的
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url{
if (controller.documentPickerMode== UIDocumentPickerModeImport) {
//taking the path of the file selected
NSString *path = [url path];
//converting to NSData
NSData *data = [[NSFileManager defaultManager] contentsAtPath:path];
//converting to base64 string
base64String = [data base64EncodedStringWithOptions:kNilOptions];
}
}