I tried adding a textmessage in Textbox, Initially I added it in a plain docx page and got the xml as shown below
- Code: Select all
<w:p>
<w:pict>
<v:shapetype id="_x0000_t202" coordsize="21600,21600"
o:spt="202" path="m,l,21600r21600,l21600,xe">
<v:stroke joinstyle="miter" />
<v:path gradientshapeok="t" o:connecttype="rect" />
</v:shapetype>
<v:shape id="Text Box 195" o:spid="_x0000_s1026" type="#_x0000_t202"
style="position:absolute;margin-left:-7.2pt;margin-top:16.45pt;width:2in;height:110pt;z-index:251623936;visibility:visible;mso-wrap-style:square;mso-width-percent:0;mso-height-percent:0;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;mso-width-percent:0;mso-height-percent:0;mso-width-relative:page;mso-height-relative:page;v-text-anchor:top"
filled="f" stroked="f">
<v:textbox>
<w:txbxContent>
<w:p w:rsidR="002E57F9" w:rsidRDefault="0030198C">
<w:pPr>
<w:jc w:val="center" />
</w:pPr>
<w:r>
<w:rPr>
<w:sz w:val="28" />
<w:szCs w:val="19" />
</w:rPr>
<w:t>Suresh</w:t>
</w:r>
</w:p>
</w:txbxContent>
</v:textbox>
</v:shape>
</w:pict>
</w:p>
The following code I developed to achive the above
- Code: Select all
public static void addTextBoxContent(String designText) throws Exception {
//starting a paragraph
startParg();
//starting a run
startRun();
CTShape objCTShape = new CTShape();
vmlFactory.createShape(objCTShape);
org.docx4j.vml.CTTextbox objCTTextbox = new CTTextbox();
org.docx4j.wml.CTTxbxContent objCTTxbxContent = new CTTxbxContent();
objCTTxbxContent.getEGBlockLevelElts().add(designText);
objCTTextbox.setTxbxContent(objCTTxbxContent);
Pict pict = wmlFactory.createPict();
pict.getAnyAndAny().add(objCTTextbox);
bean.getCurrentParg().getParagraphContent().add(pict);;
endRun();
endParg();
}
but while running the code I am getting the following exception
- Code: Select all
[com.sun.istack.internal.SAXException2: unable to marshal type "org.docx4j.vml.CTTextbox" as an element because it is missing an @XmlRootElement annotation]
Please advice me where I am doing the mistake.
Thanks & Regards,
B.V.Suresh Babu.