使用 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];
}