My app generates pdf files which I currently email to users for their records. I would like to display them in my app using WebKit View or perhaps PDFView.
Nothing I have tried works.
do {
let pdfFilename = "/var/mobile/Containers/Data/Application/BAF53A56-848D-48C0-ADF0-4DC1F945A3D1/Documents/myPDF.pdf"
let url = NSURL(fileURLWithPath: pdfFilename)
do{
let data2 = try Data(contentsOf: url as URL)
print(data2)
let data = NSData(contentsOfFile: pdfFilename)!
webView.load(data, mimeType: "application/pdf", characterEncodingName:"", baseURL: pdfURL.deletingLastPathComponent())
view.addSubview(webView)
data and data2 are empty and no webWiew is generated
I thought PDFKit might be an alternative. But
"A PDFView user interface element is available in Interface Builder, so you should use that wherever you want your application to display PDF content. Note that you need to install the PDF Kit palette in
/Developer/Extras/Palettes/PDFKit.palette
to make PDFViews available."Searching the Apple Developer site and Xcode resources found no such palette.
What am I doing wrong this time?