我是iOS开发的新手,对iOS和PDF有一个相当普遍的问题。我知道在iOS4+中有内置的PDF支持,但是否可以打开一个PDF进行查看,然后在上面做笔记并再次保存?
我肯定有一些选项,比如打开PDF作为背景,在它上面覆盖一个“可写的”,将其保存为图像,然后将其写入PDF,但我想知道是否有更“固有”的方法来做到这一点。
谢谢。
发布于 2011-08-02 06:51:43
要进行搜索,请参阅以下答案:Text searching PDF
对于覆盖,你可以自己绘制pdf,然后添加你自己的覆盖:
UIGraphicsBeginImageContextWithOptions(pageRect.size, NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
// Flip the context so that the PDF page is rendered
// right side up.
CGContextTranslateCTM(context, 0.0, pageRect.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
// Scale the context so that the PDF page is rendered
// at the correct size for the zoom level.
CGContextScaleCTM(context, pdfScale, pdfScale);
CGContextTranslateCTM(context, -pageRect.origin.x, -pageRect.origin.y);
CGContextDrawPDFPage(context, pdfPage);
CGContextRestoreGState(context);
// callback for custom overlay drawing (example_
if ([document shouldDrawOverlayRectForSize:size]) {
[document drawOverlayRect:pageRect inContext:context forPage:page zoomScale:1.0 size:size];
}更新:只需注意,pdf可以包含旋转信息,因此实际绘制应该读取该元数据并相应地转换上下文。
发布于 2011-04-12 06:20:56
我也在研究同样的问题。我开始关注FastPDFKit http://mobfarm.eu/fastpdfkit ..。你应该能够添加书签,查看大纲,执行搜索和突出显示。我正在试着看看我是否可以覆盖一系列的东西,比如图像,图形和文本元素。然后我需要将pdf与添加的内容合并。
我认为我们正在尝试做同样的事情。
https://stackoverflow.com/questions/5531041
复制相似问题