实施 PSPDFKit
我正在开发一个项目,可以查看从互联网上获取的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查你的网址可能是空的
check your url may be it is empty