2

I'm having trouble using PDFKit in my application. I have a table cell in which I'm trying to render a PDF using PDFKit. I'm able to load/render the PDF, but what's happening is the PDF is clear at the top but as you scroll down it becomes blurry.

See below (yes, TextEdit is over the screen shot, just using it to block content): enter image description here

As you can see, the PDF gets unreadable as you get lower.

Here's my relevant code:

containerView.addSubview(documentView)

 fileprivate lazy var documentView: PDFView = {
let view = PDFView();
view.translatesAutoresizingMaskIntoConstraints = false
if let document = PDFDocument(url: url) {
  view.document = document
}
view.autoScales = true;
view.isHidden = false
return view
}()

And I also set constraints:

   let margin: CGFloat = 30
containerView.addConstraints([
  spinnerView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
  spinnerView.centerYAnchor.constraint(equalTo: containerView.centerYAnchor),
  documentView.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 0),
  documentView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: margin),
  documentView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -margin),
  documentViewBottomConstraint
])

Any ideas what's going on? Thanks!

user1513171
  • 1,912
  • 6
  • 32
  • 54
  • So it seems like this is partially caused by it being in a table which has it's own scroll bar. If I allow this pdf to be scrolled individually, the it looks fine. However if I make my cell the full height of the pdf so that there is no scroll, this is where the problem lays. It seems like the PDFKit doesn't fully load the content unless you scroll to it? – user1513171 Dec 03 '18 at 18:47

0 Answers0