Get position of CTShape/Pict/CTImageData
Posted: Tue Apr 12, 2011 12:10 am
Hi,
I'm new to docx4j and I'm currently using it to load and evaluate DOCX documents. The documents I need to read contain a couple of images that may contain labels above (z-level-above) the images.
Now, parsing the files I realized, that the order of how elements appear in MS Word is not the same as I get it from using the TraversalUtil. E.g., I constructed an example document with two images next to each other (image "A" left, image "B" right). Both images have labels, image "A" is labeled "L1" and image "B" is labeled "R2". Traversing the document, I get the images in the order they appear (first "A" then "B"), after that, however, I get the label "R2" (belongs to image "B") then label "L1" (belongs to image "A"). With text paragraphs it gets even more complicated, as the paragraphs may even be returnd in any order.
So, my idea is to use the location of the images (CTShape/Pict/CTImageData) and the texts (P) in order to associate the label texts with the images. But I don't now how to get the location for a P, Pict, CTShape, or CTImageData element. While debugging I saw, that CTImageData has a private parent field that is a JAXBElement having set a style that at least contains width and height. But I don't know how to get this information as there's no getter for the parent on CTImageData.
Can anyone help me, please?
Regards
Robert
I'm new to docx4j and I'm currently using it to load and evaluate DOCX documents. The documents I need to read contain a couple of images that may contain labels above (z-level-above) the images.
Now, parsing the files I realized, that the order of how elements appear in MS Word is not the same as I get it from using the TraversalUtil. E.g., I constructed an example document with two images next to each other (image "A" left, image "B" right). Both images have labels, image "A" is labeled "L1" and image "B" is labeled "R2". Traversing the document, I get the images in the order they appear (first "A" then "B"), after that, however, I get the label "R2" (belongs to image "B") then label "L1" (belongs to image "A"). With text paragraphs it gets even more complicated, as the paragraphs may even be returnd in any order.
So, my idea is to use the location of the images (CTShape/Pict/CTImageData) and the texts (P) in order to associate the label texts with the images. But I don't now how to get the location for a P, Pict, CTShape, or CTImageData element. While debugging I saw, that CTImageData has a private parent field that is a JAXBElement having set a style that at least contains width and height. But I don't know how to get this information as there's no getter for the parent on CTImageData.
Can anyone help me, please?
Regards
Robert