Spanix Dev
Spanix Dev

Reputation: 111

Rotate PDF page with usePageViewController

I am working on PDFKit and try to rotate the page. It is rotating good but without using usePageViewController. With usePageViewController it won't update the frame of the page.

// At defining PDFVIEW object
pdfView.displayMode = .singlePageContinuous
pdfView.usePageViewController(true, withViewOptions: nil)
// For rotating screen
pdfView.currentPage?.rotation += 90

without usePageViewController pagination is not working. How to achieve both at same place.

https://i.sstatic.net/xifjV.jpg

https://i.sstatic.net/HUogU.jpg

Upvotes: 1

Views: 823

Answers (1)

Shehryar Khan
Shehryar Khan

Reputation: 81

You can do a trick, it works for me :). Before changing the rotation set

    usePageViewController(false) 

and after that

    usePageViewController(true)
guard let currentPage = self.pdfView.currentPage else {return}
self.pdfView.usePageViewController(false)
self.angle = self.angle + 90
currentPage.rotation = self.angle
self.pdfView.usePageViewController(true)
self.pdfView.autoScales = true
self.pdfView.go(to: currentPage)

Upvotes: 1

Related Questions