2

I tried to add an annotation to the page in pdf. it works. but not in the desired position. here is the way I added annotation.

let annotaionpos = CGRect(origin: points, size: CGSize(width: 80, height: 30))
let annotation = PDFAnnotation(bounds: annotaionpos, forType: .text, withProperties: nil)
annotation.backgroundColor = .purple
pdfView.currentPage?.addAnnotation(annotation)

in above code, the x position is correct and the y position seems like opposite value. ex: if x = 100 and y = 10 then it added to the correct x position and y position stars from the bottom of the page. why is this. hope your help with this.

Marlon Brando aka Ben
  • 863
  • 1
  • 14
  • 33
  • Hello Marlon, can you please share the screenshot of expected result and what you are getting? – Harjot Singh Apr 09 '19 at 06:13
  • 3
    Because PDF coordinates are defined that way. "The origin, or 0,0 point is located in the bottom left hand corner of the page. Horizontal, or X, coordinates increase to the rights and vertical, or Y, coordinates increase towards the top" https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm – derpirscher Apr 09 '19 at 06:20

1 Answers1

0

The Apple develop document should be helped.

https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/PDFKitGuide/PDFKit_Prog_Conc/PDFKit_Prog_Conc.html#//apple_ref/doc/uid/TP40001863-CH201-CHDIGGFD

Figure: View space versus page space

Bob Chang
  • 31
  • 2
  • 1
    While providing a documentation link is a good practice, you could at least try to extract parts of it which you believe would help with the original question. – Michał Góral Jul 14 '20 at 08:12