0
NSURL *documentURL = [[[NSBundle mainBundle] resourceURL] URLByAppendingPathComponent:@"item_70_1_3.ppt"];
PSPDFDocument *document = [PSPDFDocument documentWithURL:documentURL];
NSURL *tempURL = PSPDFTempFileURLWithPathExtension(@"flattened_signaturetest", @"pdf");

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
        [[PSPDFProcessor defaultProcessor] generatePDFFromDocument:document pageRange:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, document.pageCount)] outputFileURL:tempURL options:@{kPSPDFProcessorAnnotationTypes : @(PSPDFAnnotationTypeAll)} progressBlock:^(NSUInteger currentPage, NSUInteger numberOfProcessedPages, NSUInteger totalPages) {
            // Access UI only from main thread.
            dispatch_async(dispatch_get_main_queue(), ^{
                [PSPDFProgressHUD showProgress:(numberOfProcessedPages+1)/(float)totalPages status:PSPDFLocalize(@"Preparing...")];
            });
        } error:NULL];

        // completion
        dispatch_async(dispatch_get_main_queue(), ^{
            [PSPDFProgressHUD dismiss];
            PSPDFDocument *flattenedDocument = [PSPDFDocument documentWithURL:tempURL];
            PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:flattenedDocument];
            UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pdfController];
            [self presentViewController:navController animated:YES completion:NULL];
        });
    });

我使用上面的代码打开一个空内容:(

4

1 回答 1

2

PSPDFProcessor 功能是实验性的。请尝试使用 Safari 打开 PPT 文件是否有效,它主要使用 Apple 的库,并且某些文件可能会失败。这里的代码看起来像是从我在 PSPDFCatalog 中的示例中简单复制的,因此很好。

于 2013-05-20T05:23:10.150 回答