import UIKit\nimport PDFKit\n\nclass ViewController: UIViewController {\n\n @IBOutlet weak var pdfView: PDFView!\n\n lazy var pdfDoc:PDFDocument? = {\n guard let path = Bundle.main.path(forResource: "6368", ofType: "pdf") else {return nil}\n let url = URL(fileURLWithPath: path)\n return PDFDocument(url: url)\n }()\n\n override func viewDidLoad() {\n super.viewDidLoad()\n self.setupPDFView()\n self.save()\n }\n\n func setupPDFView() {\n //Setup and put pdf on view\n pdfView.autoScales = true\n pdfView.displayMode = .singlePageContinuous\n pdfView.displayDirection = .horizontal\n pdfView.document = pdfDoc\n\n self.add(annotation: self.circleAnnotation(), to: 0)\n }\n\n func add(annotation: PDFAnnotation, to page:Int){\n self.pdfDoc?.page(at: page)?.addAnnotation(annotation)\n }\n\n func circleAnnotation()->PDFAnnotation …
Run Code Online (Sandbox Code Playgroud)