Parse Pdf to get the boudaries of image in the pdf page in Objective-c
I have an iPad app that displays pdf pages.I need to add annotations on the image (if exists on the pdf page) for which i need the coordinates at which the image is situated in the 开发者_运维百科pdf page.I am able to get the image data from the XObject and the image width and height,but i also need the x and y coodrinate of the image.Any idea about how to obtain the coordinates of image by parsing pdf page?
Im assuming you have seen this apple developer page describing how to parse XObjects: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf_scan/dq_pdf_scan.html
XObjects do not contain any position data as they just describe image data that can be reused through the pdf.
From http://itext-general.2136553.n4.nabble.com/finding-the-position-of-xobject-in-an-existing-pdf-td2157152.html
"An XObject is a stream that can be reused in many different other streams. For instance: you could have an image XObject of a logo that appears on every page in the document. Suppose that you have some pages in landscape and some in portrait. Then the logo will have different coordinates on these different pages. Therefore the position of the XObject IS NEVER STORED with the XObject, the position can be found in the stream that refers to the XObject. Maybe your reaction is: "Oh right, then it's simple: I have to look in the content stream of the pages using the XObject." Yes and no. That's indeed where you should look, but it's not simple. Because the actual position depends on the current transformation matrix of the state at the moment the image is added. It's quite some programming work to parse the content stream and calculate the position of an XObject. "
I think you should find another option and avoid this all together.
If your still determined you will have to use CGPDFScanner and find the transforms through the page.
精彩评论