How to get exact X and Y origin values of pdf page in iOS, PDFKit, swift

975 Views Asked by At

I'm using PDFKit to display pdf using pdfview to user and it works perfectly. here is my implementation of pdfview. and here are the properties of pdfview.

if let pdfdoc = PDFDocument(url: docurl) {
    print("working")
    pdfdocument = pdfdoc
    pdfview.document = pdfdocument
    pdfview.autoScales = false
    pdfview.delegate = self
    pdfview.displayMode = .singlePageContinuous
}

now what I want is to get exact origin of the current page. but it gives always (0,1) for each and every page. this is how I tried.

let currentpage = pdfview.currentPage
print(currentpage?.bounds(for: .mediaBox).origin.x)

the X value is always 0.

I have attached a screenshot which I want to get the x and y value of the page.

enter image description here

How can I get this x and y value of the pdf page. hope your help with this.

1

There are 1 best solutions below

0
On

I'm using the following:

const pdfDoc = new PDFDocument({
  size: [
    pageParameters.width,
    pageParameters.height
  ],
  margins: {
    printing: 'highResolution',
    top: 0,
    bottom: 0,
    left: 0,
    right: 0
  }
})