Is possible to extract the exact position from an XObject? #4354
Replies: 2 comments
-
Transferring this to "Discussions" because all information you need is already present. |
Beta Was this translation helpful? Give feedback.
-
You can use pprint(page.get_xobjects())
[(13, 'fzFrm0', 0, (100.0, 642.0, 200.0, 742.0)),
(12, 'fullpage', 13, (0.0, 0.0, 100.0, 100.0))] As you see, objects at xref 12 and xref 13 are interconnected: Each of the xobject in this chain has print(doc.xref_object(12))
<<
/Type /XObject
/Subtype /Form
/BBox [ 0 0 100 100 ]
/Matrix [ 1 0 0 1 0 0 ]
/Resources 5 0 R
/Length 122
/Filter /FlateDecode
>>
print(doc.xref_object(13))
<<
/Type /XObject
/Subtype /Form
/BBox [ 0 0 100 100 ]
/Matrix [ 1 0 0 1 100 642 ]
/Resources <<
/XObject <<
/fullpage 12 0 R
>>
>>
/Length 20
/Filter /FlateDecode
>> Starting with the endpoint of this chain, multiply all matrices and finally multiply
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I want to extract the bbox from an XObject so that I can add a border in the original PDF document, I can extract the XObject properly as seen in this example: https://github.com/pymupdf/PyMuPDF-Utilities/tree/master/examples/extract-xobj, but when I try to extract the exact position I'm always getting something like: BBox [ 0 0 531 650 ] so it is always starting in (0,0) also tried applying the transformation matrix which is something like: Matrix [ .75 0 0 .75 0 0 ], but it doesn't affect the position. Is this something it can be done right now? Can you help me with that? Thanks
Beta Was this translation helpful? Give feedback.
All reactions