You could use PDFKit (iOS 11 only), WebKit, or DocumentInteractionController to display the document in your app. I have limited experience with DocumentInteractionController, no experience with the others.
I did the following in an older app to get a UIImage of a page from a local PDF file. It was originally done in Xcode 6 or 7 with Objective C, now in Xcode 8.3.2 with Swift, so it may need tweaks for Xcode 9 / Swift 4. It still works, but there might be a much simpler way to do the same thing now.
if let pdfDocument = CGPDFDocument(fileURL as CFURL) {
if let pdfPageForThumbnail = pdfDocument.page(at: 1) {
if let pdfPageDict = pdfPageForThumbnail.dictionary {
var pdfThumbStream : CGPDFStreamRef? = nil
var thumbnailExistsInPDF = CGPDFDictionaryGetStream(pdfPageDict, "Thumb", &pdfThumbStream)
if thumbnailExistsInPDF {
var pdfThumbFormat = CGPDFDataFormat.raw
if let pdfThumbData = CGPDFStreamCopyData(pdfThumbStream!, &pdfThumbFormat) {
thumbImage = UIImage(data: pdfThumbData as Data)
if thumbImage == nil {
thumbnailExistsInPDF = false
}
}
}
if !thumbnailExistsInPDF {
let pdfPageRect = pdfPageForThumbnail.getBoxRect(.cropBox)
UIGraphicsBeginImageContext(pdfPageRect.size)
if let pdfContext = UIGraphicsGetCurrentContext() {
pdfContext.translateBy(x: pdfPageRect.minX, y: pdfPageRect.maxY)
pdfContext.scaleBy(x: 1.0, y: -1.0)
pdfContext.translateBy(x: -(pdfPageRect.origin.x), y: -(pdfPageRect.origin.y))
let rgbColorSpace = CGColorSpaceCreateDeviceRGB()
let rgbaComponentsArray: [CGFloat] = [255.0, 255.0, 255.0, 1.0]
if let whiteColor = CGColor(colorSpace: rgbColorSpace, components: rgbaComponentsArray) {
pdfContext.setFillColor(whiteColor);
pdfContext.fill(pdfPageRect);
pdfContext.drawPDFPage(pdfPageForThumbnail);
thumbImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
}
}
}
}
}