[英]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.