简体   繁体   English

顶部/底部,左/右边缘带有白线的PDF渲染

[英]PDF rendering with white lines on top/bottom, left/right edges

I'm using the (excellent) vfr-reader in several iOS applications. 我在几个iOS应用程序中使用(优秀的) vfr-reader It works like a charm, but I'm having problems with the rendering of some PDF files. 它就像一个魅力,但我有一些PDF文件的渲染问题。

In VFR-Reader, I'm seeing white lines at the top and bottom, and/or left and right edges, which is very annoying with full-page photos. 在VFR-Reader中,我在顶部和底部,和/或左右边缘看到白线,这对于整页照片非常烦人。

They appear in the rendered page and the page thumbnails in the ThumbsViewController: 它们出现在ThumbsViewController中的渲染页面和页面缩略图中:

在此输入图像描述左右边缘带有白线的页面缩略图

The white lines become (a little) bigger when zooming in: 放大时白线变大(略大):

(bottom edge, though difficult to see against the white page background) (底边,虽然很难看到白页背景)

放大了

and I can change their color by modifying 我可以通过修改来改变颜色

CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); // White

in ReaderContentPage.m / drawLayer. 在ReaderContentPage.m / drawLayer中。

I naively tried to set the RGBFillColor to black, but then all text pages (usually on white background) in the PDF would appear all black as well. 我天真地尝试将RGBFillColor设置为黑色,但是PDF中的所有文本页面(通常在白色背景上)也会显示为全黑。

I assume the problem lies in some aspect ratio/PDF page dimensions, that for some reason do not perfectly fill the drawing area, so the white background color "bleeds" out. 我认为问题在于某些宽高比/ PDF页面尺寸,由于某种原因,它不能完美地填充绘图区域,因此白色背景颜色“流血”。

The PDFs themselves seem fine, they render perfectly (without white lines) in Safari and GoodReader. PDF本身看起来很好,它们在Safari和GoodReader中完美呈现(没有白线)。

I'd appreciate any hint how to fix this, or the general direction I should be investigating. 我很感激任何暗示如何解决这个问题,或者我应该调查的总体方向。

The author of VFR answered me via email: VFR的作者通过电子邮件回复了我:

"I suspect that it is caused by the PDF page size not exactly matching the size of the CATiledLayer-backed UView that shows the page. When the PDF page is rendered by iOS, it does an aspect fit, thus leaving white borders. In ReaderContentPage.m, in the -drawLayer:inContext: method, try changing true to false in this function call: CGPDFPageGetDrawingTransform(_PDFPageRef, kCGPDFCropBox, self.bounds, 0, true)" “我怀疑它是由PDF页面大小与显示页面的CATiledLayer支持的UView的大小完全匹配造成的。当iOS页面呈现PDF页面时,它会适合方面,因此会留下白色边框。在ReaderContentPage中.m,在-drawLayer:inContext:方法中,尝试在此函数调用中将true更改为false:CGPDFPageGetDrawingTransform(_PDFPageRef,kCGPDFCropBox,self.bounds,0,true)“

which indeed has fixed the issue! 这确实解决了这个问题!

(To fix the thumbnails, I modified the same line in ReaderThumbRender.m) (为了修复缩略图,我修改了ReaderThumbRender.m中的同一行)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UIScreenEdgePanGestureRecognizer:顶部和底部边缘 - UIScreenEdgePanGestureRecognizer: top and bottom edges IOS:如何在 4 侧(顶部、右侧、底部和左侧)为 UIView 制作阴影 - IOS: How to make a shadow for UIView on 4 side (top,right,bottom and left) 边界测试仅适用于顶部/底部,不适用于左/右 - Boundary testing only works for top/bottom but not left/right 如何在iOS中获得安全区域的顶部,底部,右侧,左侧值? - How to get safe area top,bottom,right,left value in iOS? 从下到上而不是从右到左关闭 UIViewController - Dismiss a UIViewController from bottom to top instead of right to left Swift:如何知道谷歌地图的右上角和左下角坐标 - Swift: How to know the top right and bottom left coordinates of a google map 如何从上到下然后从左到右排列UICollectionVewCell - How to arrange UICollectionVewCell from top to bottom then left to right 如何为 UIView 的左下角、右下角和左上角设置 cornerRadius? - how to set cornerRadius for only bottom-left,bottom-right and top-left corner of a UIView? UICollectionViewScrollDirectionHorizo​​ntal:如何更改从上到下到左右的顺序 - UICollectionViewScrollDirectionHorizontal: how to change order from top-bottom to left-right iPad ViewController弹出动画样式从右滑到左滑到下滑到上滑 - IPad ViewController pop animation style changed from sliding from right to left to sliding from bottom to top
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM