Alua-Kinzhebayeva / iOS-PDF-Reader

PDF Reader for iOS written in Swift
MIT License
532 stars 150 forks source link

Some PDFs display blank white page #97

Open tomlongo opened 6 years ago

tomlongo commented 6 years ago

I cant seem to work out what is causing this, but some PDFs that get fed to it are displaying as blank white pages. If I take those PDFs and re-save them in something like Preview, then it works, so I"m guessing it's something to do with the way in which they were exported.

Has anyone come across this? Not sure how to troubleshoot as I cant reliably replicate 🤔

lightman73 commented 6 years ago

@tomlongo

I had the same problem with a couple of PDFs there were created with an old version of Ghostscript (which had a documented bug).

The only way I found to overcome the problem has been to use a recent version of gs to re-save them, e.g. gs -sDEVICE=pdfwrite -oCorrect_PDF.pdf Problematic_PDF.pdf .

That said, I can't understand why Preview, iBooks and iOS 11 PDFKit (which I'd prefer not to use for my particular app because of the way the thumbnail bar behaves) all can correctly open the original PDFs.

ZaidSA commented 5 years ago

@Alua-Kinzhebayeva Any solution for this?

mahmutpinarbasi commented 4 years ago

This seems to be related with this one.

I've changed changed the rotation code blocks with the following on PDFDocument & TiledView.

 // Flip the context so that the PDF page is rendered right side up.
context.translateBy(x: 0.0, y: scaledPageRect.height)
context.scaleBy(x: 1.0, y: -1.0)
let transform = page.getDrawingTransform(CGPDFBox.mediaBox, rect: scaledPageRect, rotate: 0, preserveAspectRatio: true)
context.concatenate(transform)

These changes seems to fixed the issue in my case.