Question

I'm using the (excellent) vfr-reader in several iOS applications. It works like a charm, but I'm having problems with the rendering of some PDF files.

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.

They appear in the rendered page and the page thumbnails in the ThumbsViewController:

enter image description here Page Thumbnails with White Lines on Left and Right Edge

The white lines become (a little) bigger when zooming in:

(bottom edge, though difficult to see against the white page background)

zoomed in

and I can change their color by modifying

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

in 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.

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.

The PDFs themselves seem fine, they render perfectly (without white lines) in Safari and GoodReader.

I'd appreciate any hint how to fix this, or the general direction I should be investigating.

Was it helpful?

Solution

The author of VFR answered me via email:

"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)"

which indeed has fixed the issue!

(To fix the thumbnails, I modified the same line in ReaderThumbRender.m)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top