- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对过去两天没有找到任何与 CGPDF 相关的适当文件感到震惊。我尝试了所有可能的方法,但我失败了。这就是我想要做的。我有一个要显示的 PDF,我正在 UIWebView 中显示它。我使用 pdf 所在的路径 (NSURL) 创建了一个 CORE GRAPHICS PDF 文档引用。我在它上面创建了一个 UIView 并处理了一个触摸事件。当 PDF 加载并且用户单击 View 时,我希望页面滚动到特定页面。我知道这可以通过计算页面高度和宽度来完成。我想知道 CGPDF 中是否有一种方法可以传递页码并滚动到相关页面。下面是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
// set the pdfPafeHeight to -1 so it gets calculated.
self.pdfPageHeight = -1;
// set the delegate of the UIWebView's underlying UIScrollView to self.
self.webView.scrollView.delegate = self;
// create an NSURLRequest to load the PDF file included with the project
_filePath = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"pdf"];
_url = [NSURL fileURLWithPath:_filePath isDirectory:NO];
_urlRequest = [NSURLRequest requestWithURL:_url];
// create a Core Graphics PDF Document ref using the same NSURL
_pdf = CGPDFDocumentCreateWithURL((CFURLRef) _url);
// use CGPDFDocumentGetNumberOfPages to get the number of pages in the document
self.pdfPageCount = (int)CGPDFDocumentGetNumberOfPages(_pdf);
// load the PDF file into the UIWebVie
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSingleTap:)];
[self.view addGestureRecognizer:singleFingerTap];
[self.webView loadRequest:_urlRequest];
}
这是我想要在 UIVIEW 上处理单击的方式。我只是想知道 CGPDF 中是否有任何方法可以在我将页码传递给它时滚动到特定页面
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
}
最佳答案
没有 API 可以实现您想要实现的目标,即使您能够使用私有(private) API,如果此应用程序仅用于企业安装并且不需要转到 App Store - 这将很棘手并且任何解决方法都可能会随着 iOS 版本的重大更新而失效。如果你想走这条路,你可以内省(introspection) View Controller 层次结构,你会发现Apple内部有一个名为 CorePDF 的框架。它有一个您可能能够访问的内部私有(private) API - 但要小心并知道这不是 App Store 应用程序的解决方案。
另一种方法是从头开始,使用 CGContextDrawPDFPage 绘制 PDF 页面,构建您自己的缓存、 ScrollView 和 View Controller +手势处理。我们用商业广告做到了 PSPDFKit SDK我自 2010 年起就开始从事这项工作 - 这比你想象的要多。我们最终还继续使用自定义渲染器来提高与各种可用 PDF 文件的兼容性,并提供比 Apple 渲染器更好的性能,但并非每个用例都需要这样做。
关于ios - 使用 CGPDF 滚动到特定页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35827458/
根据 Adobe 的“文档管理 - 可移植文档格式 - 第 1 部分:PDF 1.7” ( Pdf32000_2008.pdf ),第 12.3.2.1 节指出: A destination de
我对过去两天没有找到任何与 CGPDF 相关的适当文件感到震惊。我尝试了所有可能的方法,但我失败了。这就是我想要做的。我有一个要显示的 PDF,我正在 UIWebView 中显示它。我使用 pdf 所
我在 iOS 10 下使用 CGPDF 保存一个 PDF 文件。为此,我加载一个现有的 PDF 页面,并将其写入一个带有上下文的新文件。这样做时,旋转信息会丢失,生成的 PDF 文件会将所有页面重新排
是否有任何方法可以使用 CGPDF 创建 PDF 对象(例如,带有自定义 PDF 生产者/消费者/查看者所需参数的 PDF 字典),或者我是否必须编写自己的解析器并创建新预告片、外部参照等以便向 PD
多年来,我一直在努力尝试为 iPhone/iPad 制作一个可用的 PDF 阅读器,但它永远不会停止消耗内存。看来所有用CGContextDrawPDFPage绘制的页面都被内部缓存起来,永远不会释放
给定pdf文档的页面,我希望能够使用objetive-C找到文本的页边距。 我意识到已经有很多与CGPDF...有关的问题,但是我找不到任何有用的东西。我也看过了PDF规范文档。我确定它一定在某个地方
我正在为工作编写一个 PDF 解析器,我们正在使用 Core Graphics 通过回调读取所有数据,然后使用 Lib Haru 将其写出,因为我们的客户需要写出“真实”注释和 CG做不到。 好吧,我
我正在制作一个 PDF 阅读器,它对大多数 PDF 都能很好地工作。在使用一堆不同的文档(在 iPad 上)进行测试时,我发现一个会使应用程序崩溃的文档 - 它大量使用矢量图形和图像,所以我并不感到惊
我有一个 pdf 文件,我想在 ipad 上渲染它。但是我不知道如何获取命名目的地以及如何在 ipad 上执行 GoTo Action。 Names > Dests > Kids > Names >
我需要在 iOS 中创建一个 pdf 查看器应用程序。我发现使用 Quartz CGPDF 可以实现这个我找不到合适的开始。我检查了苹果文档。 https://developer.apple.com/
我试图在 PDF 文档的页面上找到所有超链接,并在它们上面放置一个 UIButton。 我已经找到并试用了下面的脚本,它应该能够做到这一点。它找到超链接并将 UIButtons 放置在它们不在链接顶部
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 7 年前。 Improve this ques
这里有人有使用 CGPDF*(即 native API)在 iOS 中渲染多层 PDF 的经验吗?您能分享一下您的经验吗?您遇到性能问题了吗? 最佳答案 PDF 图层在 PDF 规范中称为可选内容。它
我是一名优秀的程序员,十分优秀!