【发布时间】:2018-01-10 16:05:27
【问题描述】:
使用 PSPDFkit 7.0 版本,我创建了 PDF 文件。
此文件在所有浏览器和 PDF 查看器应用程序中都能完美运行。但一个问题是 IOS 设备浏览器 safari、Chrome 和 Firefox 没有显示此文档。它显示的是空文档。
但是当我在 iBook、文件浏览器和其他 PDF 查看器应用程序中打开此 pdf 文件时,它运行良好。
我的代码如下:
- (void)pdfDocumentDidSave:(PSPDFDocument *)document {
NSLog(@"Successfully saved document.");
//Get path directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//Create PDF_Documents directory
documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@"PDF_Documents"];
[[NSFileManager defaultManager] createDirectoryAtPath:documentsDirectory withIntermediateDirectories:YES attributes:nil error:nil];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory, @"hello123.pdf"];
// Create default configuration
PSPDFProcessorConfiguration *configuration = [[PSPDFProcessorConfiguration alloc] initWithDocument:document];
[configuration modifyAnnotationsOfTypes:PSPDFAnnotationTypeAll change:PSPDFAnnotationChangeEmbed];
// Start the conversion from `document` to `scaledDocumentURL`
[PSPDFProcessor generatePDFFromConfiguration:configuration securityOptions:nil outputFileURL:[NSURL URLWithString:filePath] progressBlock:nil error:NULL];
}
【问题讨论】:
标签: ios objective-c pdf-viewer pspdfkit