How I can show/display pdf document to full screen on pdfView?

I took pdfView, and I am trying to load pdf document on this pdfView. Pdf is not displaying/showing full screen w.r.t its pdfView as I added in storyboard. It has some gaps from top and bottom.

Here is the code, I wrote
Code Block swift
if let path = Bundle.main.path(forResource: "file-sample_150kB", ofType: "pdf") {
            if let pdfDocument = PDFDocument(url: URL(fileURLWithPath: path)) {
                
                pdfView.autoresizesSubviews = true
                pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight, .flexibleTopMargin, .flexibleLeftMargin]
                pdfView.displayDirection = .vertical
                pdfView.autoScales = true
                pdfView.displayMode =  .singlePage
                pdfView.displaysPageBreaks = true
                pdfView.document = pdfDocument
                pdfView.maxScaleFactor = 4.0
                pdfView.minScaleFactor = pdfView.scaleFactorForSizeToFit
                pdfView.usePageViewController(true, withViewOptions: [:])
            }
        }



How I can remove that extra space from top and bottom and make/show/display that pdf document to full to screen w.r.t pdfView which I added in storyboard that same size.

Any solution for this?


Note - In my code/requirement displaying single page is needed
i.e pdfView.displayMode =  .singlePage


Here is project link - [https://github.com/MallikarjunH/TestPDFFullScreen1)


Please check the following Link

Code Link - https://github.com/MallikarjunH/TestPDFFullScreen1.git

I was trying to do the same thing today, using iOS 15 and discovered that autoScales stops working if used in conjunction with pdfView.usePageViewController.

If you set autoScales = true and displayMode = .singlePageContinuous without usePageViewController, you will see your pages scale to fill the PDF view

I have not found a way to use them together, usePageViewController and autoScales, I searched for possible options to use in the parameters of usePageViewController, but i havent succeeded

So I decided to use SinglePageContinuous as the display mode and work with multiple pages at once. Another option would be use Singlepage and add swipe gestures (up and down) to navigate between PDF pages.

How I can show/display pdf document to full screen on pdfView?
 
 
Q