4

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.

thomers
  • 2,603
  • 4
  • 29
  • 50
  • is there some particular reason you want to use VFR ? Why not use Safari, or GoodReader since they work ok ? – SashaZd Apr 04 '13 at 14:04
  • 1
    Because I need an open source PDF library to include in my own apps, and not a finished, independent PDF reader app. – thomers Apr 04 '13 at 16:46
  • How about opening the pdfs in a UIWebView ? Since Safari can read them, if you load them into UIWebView, you should be able to do the same. – SashaZd Apr 04 '13 at 16:52
  • No, I am already using VFR since it does many things PDFs shown in a UIWebView cannot. – thomers Apr 05 '13 at 06:06
  • Can you post a sample PDF file so I can take a look at it? – Mihai Iancu Apr 05 '13 at 06:58

1 Answers1

4

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)

thomers
  • 2,603
  • 4
  • 29
  • 50