Adding pdf files in app

Please i need help and guide the app i want to create has pdf files that i want to add and i don’t know how to add them.

HI @AhmadRufai Welcome!

I placed a number of pdf’s in the bundle and called a method with the var named name. Here is the code.

 if let path = Bundle.main.path(forResource: name, ofType: "pdf") {
            let url = URL(fileURLWithPath: path)
            if let pdfDocument = PDFDocument(url: url) {
                pdfView.displayMode = .singlePageContinuous
                pdfView.autoScales = true
                pdfView.displayDirection = .vertical
                pdfView.document = pdfDocument
            }
        }

Blessings,
—Mark

2 Likes