Search code examples
iosswiftpdfkit

Is there any way to read pdf file by swiping left to move to next page using PdfKit


I want to read document from right to left but in this scenario its scrolling from left to right below is the code I am using to read file but can't read from left side to onward e.g reading book from last page to onward

 pdfView.displayMode = .singlePageContinuous
        pdfView.usePageViewController(true, withViewOptions: nil)
        pdfView.pageBreakMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        pdfView.displayDirection = .horizontal
        pdfView.displaysAsBook = true
        pdfView.translatesAutoresizingMaskIntoConstraints = false
        pdfView.setValue(true, forKey: "forcesTopAlignment")
        pdfView.autoresizingMask = [.flexibleHeight,.flexibleWidth,.flexibleTopMargin,.flexibleBottomMargin]
        
        
        pdfView.displayBox = .bleedBox
        
        let temp = JuzzPdfViewController.juzzIndex
        
        let resourse = "parah\(temp)"

        ParahNo = JuzzPdfViewController.juzzIndex
        let fileURL = Bundle.main.url(forResource: resourse, withExtension: "pdf")
        
       resumeQuranURl = fileURL
        
        
        pdfView.document = PDFDocument(url: fileURL!)

Solution

  • Try the following:

    pdfView.displaysRTL = true
    pdfView.usePageViewController(true)
    

    The displaysRTL does not seem to work as well without using the page view controller.