Hi,
We are currently using Aspose.Words Java 14.7.0 in our application. While doing the evaluation of Aspose.Words Java 15.9.0, we got some strange results for shapes/groupshapes present in header and footers.
We ran following code:
public void testShapeSize() throws Exception {
Document sample = new Document(“Office2013_Header_Footer_With_Paragraph_BookMarks_FieldCode_Author.docx”);
NodeCollection hfChildNodes = sample.getSections().get(0).getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY).getChildNodes();
for (int i = 0; i < hfChildNodes.getCount(); i++) {
if (hfChildNodes.get(i).getNodeType() == NodeType.PARAGRAPH) {
Paragraph para = (Paragraph)hfChildNodes.get(i);
for (int j = 0; j < para.getChildNodes().getCount(); j++) {
if (para.getChildNodes().get(j).getNodeType() == NodeType.GROUP_SHAPE) {
GroupShape grpShape = (GroupShape)para.getChildNodes().get(j);
for (int k = 0; k < grpShape.getChildNodes().getCount(); k++) {
if (grpShape.getChildNodes().get(k).getNodeType() == NodeType.SHAPE) {
Shape shape = (Shape)grpShape.getChildNodes().get(k);
java.awt.geom.Rectangle2D.Float bounds = shape.getBoundsInPoints();
System.out.println("X coordinate of this Rectangle2D: " + bounds.x);
System.out.println("Y coordinate of this Rectangle2D: " + bounds.y);
System.out.println("the X coordinate of the upper-left corner of the framing rectangle: " + bounds.getX());
System.out.println("the Y coordinate of the upper-left corner of the framing rectangle: " + bounds.getY());
System.out.println("Height of this Rectangle2D: " + bounds.getHeight());
System.out.println("Width of this Rectangle2D: " + bounds.getWidth());
java.awt.geom.Point2D.Float size = shape.getSizeInPoints();
System.out.println("the X coordinate of this Point2D in double precision: " + size.getX());
System.out.println("the Y coordinate of this Point2D in double precision: " + size.getX());
System.out.println("The X coordinate of this Point2D: " + size.x);
System.out.println("The Y coordinate of this Point2D: " + size.y);
}
}
}
}
}
}
}
Aspose Words Java 14.7.0 output:
X coordinate of this Rectangle2D: 0.0
Y coordinate of this Rectangle2D: 0.0
the X coordinate of the upper-left corner of the framing rectangle: 0.0
the Y coordinate of the upper-left corner of the framing rectangle: 0.0
Height of this Rectangle2D: 61.20000076293945
Width of this Rectangle2D: 327.6000061035156
the X coordinate of this Point2D in double precision: 327.6000061035156
the Y coordinate of this Point2D in double precision: 327.6000061035156
The X coordinate of this Point2D: 327.6
The Y coordinate of this Point2D: 61.2
X coordinate of this Rectangle2D: 0.0
Y coordinate of this Rectangle2D: 0.0
the X coordinate of the upper-left corner of the framing rectangle: 0.0
the Y coordinate of the upper-left corner of the framing rectangle: 0.0
Height of this Rectangle2D: 42.600616455078125
Width of this Rectangle2D: 327.0015869140625
the X coordinate of this Point2D in double precision: 327.0015869140625
the Y coordinate of this Point2D in double precision: 327.0015869140625
The X coordinate of this Point2D: 327.0016
The Y coordinate of this Point2D: 42.600616
Aspose Words Java 15.9.0 output:
I am unable to understand why we are getting different results for same sample document when running same code in different aspose versions.X coordinate of this Rectangle2D: NaN
Y coordinate of this Rectangle2D: NaN
the X coordinate of the upper-left corner of the framing rectangle: NaN
the Y coordinate of the upper-left corner of the framing rectangle: NaN
Height of this Rectangle2D: NaN
Width of this Rectangle2D: NaN
the X coordinate of this Point2D in double precision: NaN
the Y coordinate of this Point2D in double precision: NaN
The X coordinate of this Point2D: NaN
The Y coordinate of this Point2D: NaN
Please help us in resolving this issue.
The sample document is attached with this post for your reference.
Thanks
Manisha