miliagile.blogg.se

Pdfkit swift
Pdfkit swift






pdfkit swift

#Pdfkit swift pdf

Let’s start with the UIScrollView containing views with single PDF pages.Īs I mentioned before this was the solution I had to implement a few years ago, I cut some corners for the Swift porting as I don’t expect to use this in production now that iOS supports it in the framework. Using a Webview is so simple I didn’t feel the need to write the example, I’m sure there are tons of them available. Where I put two implementations: the scrollview with PDF pages and the one with PDFView. Recently I wanted to port my Objective-C code to Swift and I decided to share the implementation, so I created this GitHub project I started working on the custom solution back when we didn’t have WKWebViews nor PDF Kit, so my only alternatives were displaying PDFs in a UIWebView or implementing a custom solution. The third alternative is drawing PDF pages and place them on a UIScrollView. In iOS 11 Apple introduced a new class PDFView, a subclass of UIView that comes with a configuration, so you can have side-by-side pages, vertical and horizontal scrolling and many more options. I said we have 3 ways to show the PDF and we just saw one, so what are the remaining two? The only downside is the scrolling is only vertical, which is fine for most apps but you may want to provide some customisations, for example the ability to scroll horizontally and to have two pages side-by-side in landscape. Just like loading a local page, or a remote one, you can provide the URL of the PDF and the WKWebView will take care of it.

pdfkit swift

There are three possible ways of displaying a PDF. It could be a privacy policy document, an invoice, a flyer the company distributes on paper and via its app, a magazine. Showing PDFs is pretty common for an iOS app.








Pdfkit swift