Hello Cristi
Running your first docx through the docx4j sample OpenAndSaveRoundTripTest results in content Word 2007 doesn't want to open
On closer inspection, the problem is that the input docx (ie the one created by Jasper Reports), includes in its styles.xml:
Using xml Syntax Highlighting
<w:rPr>
<w:sz w:val="1.0" />
</w:rPr>
Parsed in 0.000 seconds, using
GeSHi 1.0.8.4
(There is similar content in document.xml as well eg <w:sz w:val="24.0" /> )
The wml xsd defines sz:
Using xml Syntax Highlighting
<xsd:element name="sz" type="CT_HpsMeasure" minOccurs="0">
<xsd:annotation>
<xsd:documentation>Font Size
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="CT_HpsMeasure">
<xsd:annotation>
<xsd:appinfo>
<jaxb:class name="HpsMeasure"/>
</xsd:appinfo>
</xsd:annotation>
<xsd:attribute name="val" type="xsd:unsignedLong" use="required">
<xsd:annotation>
<xsd:documentation>Half Point Measurement
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
Parsed in 0.001 seconds, using
GeSHi 1.0.8.4
which in docx4j becomes:
Using java Syntax Highlighting
@XmlType
(name
= "CT_HpsMeasure")
public class HpsMeasure
implements Child
{
@XmlAttribute
(namespace
= "http://schemas.openxmlformats.org/wordprocessingml/2006/main", required
= true)
@XmlSchemaType
(name
= "unsignedLong")
protected BigInteger val
;
Parsed in 0.015 seconds, using
GeSHi 1.0.8.4
When docx4j opens the docx and encounters the invalid attribute value (a decimal, not an integer), it is dropped.
When the docx is saved, you get an empty <w:sz/> element, which Word doesn't like.
So the solution is an upstream fix in JasperReports. (That should be easy enough to do since JasperReports is open source, but if not, you could traverse your docx in docx4j, looking for empty sz elements and removing them.)
Please feel free to copy the contents of this post if you make a new issue in their tracker.
cheers .. Jason
cheers .. Jason