简体   繁体   English

解析 Pdf 以获取 Objective-c 中 pdf 页面中的图像边界

[英]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? 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来自 XObject 和图像宽度和高度的数据,但我还需要图像的 x 和 y 坐标。关于如何通过解析 pdf 页面获取图像坐标的任何想法?

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 的苹果开发人员页面: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf_scan/dq_pdf_scan.ZFC35FDC70D5FC69D269883A822C7A

XObjects do not contain any position data as they just describe image data that can be reused through the pdf. XObject 不包含任何 position 数据,因为它们仅描述可通过 pdf 重复使用的图像数据。

From http://itext-general.2136553.n4.nabble.com/finding-the-position-of-xobject-in-an-existing-pdf-td2157152.html来自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 pars “一个 XObject 是一个 stream 可以在许多不同的其他流中重用。例如:您可以有一个徽标的图像 XObject 出现在文档的每一页上。假设您有一些横向页面和一些纵向页面。那么logo在这些不同的页面上会有不同的坐标。所以XObject的position NEVER STORED with the XObject,position可以在ZF7B44CFAFD5C52223D5498196C52223D5498196C8A2EZ中找到,那么你的反应是:“哦,那是指XObject。”简单:我必须查看使用 XObject 的页面的内容 ZF7B44CFFAFD5C52223D5498196C8A2E7BZ。“是的,也不是。这确实是你应该看的地方,但它并不简单。因为实际的 position 取决于当前 Z9EDEZ9E2EA93412EF576B 的转换矩阵图像已添加。pars 的编程工作相当多e the content stream and calculate the position of an XObject. e 内容 stream 并计算 XObject 的 position。 " "

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.如果您仍然确定您将不得不使用 CGPDFScanner 并通过页面查找转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM