iCloudからPDFファイルを入手し、そのPDFファイルをバイナリに変換したい。Objective CでPDFをバイナリに変換する方法
コードスニペット:私はiCloud上からPDFファイルを持って、このコードを使用して
-(IBAction)iCloudDriveFullFolder:(id)sender
{
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"]
inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
}
#pragma mark - iCloud files
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
if (controller.documentPickerMode == UIDocumentPickerModeImport)
{
NSString *alertMessage = [NSString stringWithFormat:@"Successfully imported %@", [url lastPathComponent]];
NSLog(@"alertMessage %@",alertMessage);
}
。 alertMessageそのPDFファイルを入手しました。どのように私はバイナリに変換することができます。助けて。感謝の前進。
次のコードを使用できます。 NSData * data = [NSData dataWithContentsOfFile:strURL]; – Janmenjaya
どのように私はこのコードを使用します。 alertMessage文字列をstrURLに渡します。しかし、私はnullを得た。 – saravanar
ここでは、PDFのパスURLを指定する必要があります。 PDFをインポートした後は、そのパスを使用してPDFをどこかに保存しておく必要があります。私はこのようなものをインポートしたことはありませんが、パスがあればこのメソッドを使用してバイナリデータを取得することができます – Janmenjaya