The xml part created from Word is
- Code: Select all
<w:p w14:paraId="67A261C9" w14:textId="0AE29CEA" w:rsidR="008E71E3" w:rsidRPr="008E71E3" w:rsidRDefault="008E71E3" w:rsidP="008E71E3">
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:pict w14:anchorId="4E50C000">
<v:line
id="Straight Connector 2"
o:spid="_x0000_s1027"
style="position:absolute;z-index:251659264;visibility:visible;mso-wrap-style:square;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text"
from="0,8.5pt"
to="270pt,8.5pt"
o:gfxdata="..."
strokecolor="black [3213]"
strokeweight="2pt">
<v:shadow on="t" opacity="24903f" mv:blur="40000f" origin=",.5" offset="0,20000emu"/>
</v:line>
</w:pict>
</w:r>
</w:p>
and my java code is
- Code: Select all
org.docx4j.wml.ObjectFactory wFactory = new org.docx4j.wml.ObjectFactory();
P p = wFactory.createP();
mdp.getContent().add(p);
R r = wFactory.createR();
p.getContent().add(r);
RPr rPr = wFactory.createRPr();
rPr.setNoProof(new BooleanDefaultTrue());
r.getContent().add(rPr);
CTLine line = vFactory.createCTLine();
line.setStrokecolor("black [3213]");
line.setStrokeweight("2pt");
line.setFrom("0,8.5pt");
line.setTo("270pt,8.5pt");
Pict pict = wFactory.createPict();
pict.getAnyAndAny().add(line);
r.getContent().add(pict);
But I got
[main] ERROR org.docx4j.openpackaging.parts.JaxbXmlPart - null
javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "org.docx4j.vml.CTLine" as an element because it is missing an @XmlRootElement annotation]
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:311)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)
at org.docx4j.openpackaging.parts.JaxbXmlPart.marshal(JaxbXmlPart.java:406)
at org.docx4j.openpackaging.parts.JaxbXmlPart.marshal(JaxbXmlPart.java:355)
at org.docx4j.openpackaging.io3.stores.ZipPartStore.saveJaxbXmlPart(ZipPartStore.java:237)
at org.docx4j.openpackaging.io3.Save.saveRawXmlPart(Save.java:278)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:424)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:387)
at org.docx4j.openpackaging.io3.Save.save(Save.java:192)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:693)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:616)
at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:604)
I am quite unsure of pict.getAnyAndAny().add(line);
How should i do to draw a horizontal line?