实施 PSPDFKit

发布于 2024-12-06 14:38:03 字数 3332 浏览 1 评论 0原文

我正在开发一个项目,可以查看从互联网上获取的 PDF。我正在使用 UIWebView,但后来我切换到 PSPDFKit,因为它看起来好多了,并且具有附加功能。当我使用下面的代码时,视图会加载,但 PDF 不会加载。

[self setSelectedObject:(CateRegulations*)[[theDictionary valueForKey:[[[self.theDictionary allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]objectAtIndex:indexPath.section-1]] objectAtIndex:indexPath.row]];
NSString *path = selectedObject.url;
PSPDFDocument *document = [PSPDFDocument PDFDocumentWithUrl:[NSURL fileURLWithPath:path]];
PSPDFViewController *objPdfViewController=[[PSPDFViewController alloc] initWithDocument:document];


[self.navigationController pushViewController:objPdfViewController animated:YES];
[objPdfViewController release];

我的调试器读取如下:

2011-09-25 21:06:29.494 Project[4509:12b03] Error: -[PSPDFDocument rectBoxForPage:]/224 Warning: Returning empty rect.
2011-09-25 21:06:29.495 Project[4509:12b03] Error: -[PSPDFPage displayDocument:page:pageRect:scale:]/92 Warning: Invalid page rect given: {{0, 0}, {0, 0}}
2011-09-25 21:06:29.495 Project[4509:12b03] Error: -[PSPDFViewController scrollToPage:animated:hideHUD:]/1027 Error: Cannot scroll outside boundaries(0), scrolling to last page.
2011-09-25 21:06:29.495 Project[4509:14503] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 0 (pageCount: 0)
2011-09-25 21:06:29.498 Project[4509:12b03] Error: -[PSPDFDocument rectBoxForPage:]/224 Warning: Returning empty rect.
2011-09-25 21:06:29.498 Project[4509:12b03] Error: -[PSPDFPage displayDocument:page:pageRect:scale:]/92 Warning: Invalid page rect given: {{0, 0}, {0, 0}}
2011-09-25 21:06:29.498 Project[4509:12b03] Error: -[PSPDFViewController scrollToPage:animated:hideHUD:]/1027 Error: Cannot scroll outside boundaries(0), scrolling to last page.
2011-09-25 21:06:29.498 Project[4509:14503] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 0 (pageCount: 0)
2011-09-25 21:06:29.531 Project[4509:14503] Error: -[PSPDFDocument pathForPage:]/303 Warning: Path for page 0 is missing!
2011-09-25 21:06:29.532 Project[4509:14503] Error: -[PSPDFGlobalLock openPDFDocumentWithPath:]/50 Error: pdfPath is nil!
2011-09-25 21:06:29.532 Project[4509:14503] Error: -[PSPDFGlobalLock openPDFWithPath:page:]/89 Error: As pdfDocument is nil, aquiring pageRef failed.
2011-09-25 21:06:29.532 Project[4509:14503] Error: -[PSPDFTilingView drawLayer:inContext:]/208 Missing PDF IMAGE FOR <PSPDFDocument uid:2100.2A.pdf files:1 pageCount:0>
2011-09-25 21:06:30.495 Project[4509:18803] Error: __45-[PSPDFCache cacheDocument:startAtPage:size:]_block_invoke_0/802 Warning: startPage:0 to high, resetting to 1.
2011-09-25 21:06:30.496 Project[4509:18803] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 1 (pageCount: 0)
2011-09-25 21:06:30.496 Project[4509:18803] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 0 (pageCount: 0)
2011-09-25 21:06:31.499 Project[4509:18803] Error: __45-[PSPDFCache cacheDocument:startAtPage:size:]_block_invoke_0/802 Warning: startPage:0 to high, resetting to 1.
2011-09-25 21:06:31.500 Project[4509:18803] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 1 (pageCount: 0)
2011-09-25 21:06:31.500 Project[4509:18803] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 0 (pageCount: 0)

I'm working on a project that views PDFs pulled from the internet. I was working with a UIWebView, but then I switched to PSPDFKit because it looks a whole lot better, with additional features. When I use the code below, the view loads, but the PDF does not.

[self setSelectedObject:(CateRegulations*)[[theDictionary valueForKey:[[[self.theDictionary allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]objectAtIndex:indexPath.section-1]] objectAtIndex:indexPath.row]];
NSString *path = selectedObject.url;
PSPDFDocument *document = [PSPDFDocument PDFDocumentWithUrl:[NSURL fileURLWithPath:path]];
PSPDFViewController *objPdfViewController=[[PSPDFViewController alloc] initWithDocument:document];


[self.navigationController pushViewController:objPdfViewController animated:YES];
[objPdfViewController release];

My debugger reads as follows:

2011-09-25 21:06:29.494 Project[4509:12b03] Error: -[PSPDFDocument rectBoxForPage:]/224 Warning: Returning empty rect.
2011-09-25 21:06:29.495 Project[4509:12b03] Error: -[PSPDFPage displayDocument:page:pageRect:scale:]/92 Warning: Invalid page rect given: {{0, 0}, {0, 0}}
2011-09-25 21:06:29.495 Project[4509:12b03] Error: -[PSPDFViewController scrollToPage:animated:hideHUD:]/1027 Error: Cannot scroll outside boundaries(0), scrolling to last page.
2011-09-25 21:06:29.495 Project[4509:14503] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 0 (pageCount: 0)
2011-09-25 21:06:29.498 Project[4509:12b03] Error: -[PSPDFDocument rectBoxForPage:]/224 Warning: Returning empty rect.
2011-09-25 21:06:29.498 Project[4509:12b03] Error: -[PSPDFPage displayDocument:page:pageRect:scale:]/92 Warning: Invalid page rect given: {{0, 0}, {0, 0}}
2011-09-25 21:06:29.498 Project[4509:12b03] Error: -[PSPDFViewController scrollToPage:animated:hideHUD:]/1027 Error: Cannot scroll outside boundaries(0), scrolling to last page.
2011-09-25 21:06:29.498 Project[4509:14503] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 0 (pageCount: 0)
2011-09-25 21:06:29.531 Project[4509:14503] Error: -[PSPDFDocument pathForPage:]/303 Warning: Path for page 0 is missing!
2011-09-25 21:06:29.532 Project[4509:14503] Error: -[PSPDFGlobalLock openPDFDocumentWithPath:]/50 Error: pdfPath is nil!
2011-09-25 21:06:29.532 Project[4509:14503] Error: -[PSPDFGlobalLock openPDFWithPath:page:]/89 Error: As pdfDocument is nil, aquiring pageRef failed.
2011-09-25 21:06:29.532 Project[4509:14503] Error: -[PSPDFTilingView drawLayer:inContext:]/208 Missing PDF IMAGE FOR <PSPDFDocument uid:2100.2A.pdf files:1 pageCount:0>
2011-09-25 21:06:30.495 Project[4509:18803] Error: __45-[PSPDFCache cacheDocument:startAtPage:size:]_block_invoke_0/802 Warning: startPage:0 to high, resetting to 1.
2011-09-25 21:06:30.496 Project[4509:18803] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 1 (pageCount: 0)
2011-09-25 21:06:30.496 Project[4509:18803] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 0 (pageCount: 0)
2011-09-25 21:06:31.499 Project[4509:18803] Error: __45-[PSPDFCache cacheDocument:startAtPage:size:]_block_invoke_0/802 Warning: startPage:0 to high, resetting to 1.
2011-09-25 21:06:31.500 Project[4509:18803] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 1 (pageCount: 0)
2011-09-25 21:06:31.500 Project[4509:18803] Error: -[PSPDFCache enqueueItem:]/608 Warning: Page is invalid: 0 (pageCount: 0)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝眼泪 2024-12-13 14:38:03

检查你的网址可能是空的

check your url may be it is empty

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文