I have a problem when I want to include a text in a shape.
I am doing a report from java using aspose.words. I want to put a lateral text in the document and my idea is include a shape in a header-footer because I can move to the place where I want in the document.
I have declared the shape as ShapeType.TEXT_BOX but I don’t know how to write in; I can’t use the method appendChild for add a run or paragraph…
Is there some way to solve this problem?
Thanks for your inquiry. You can use code like the following to insert text into textbox:
// Create document and Documentbuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create textbox.
Shape textbox = new Shape(doc, ShapeType.TEXT_BOX);
textbox.setWidth(100);
textbox.setHeight(100);
// Add paragraph into the textbox.
textbox.appendChild(new Paragraph(doc));
// Insert text box into the document.
builder.insertNode(textbox);
// Move documentBuilder cursot to the paragraph inside the textbox.
builder.moveTo(textbox.getFirstParagraph());
// Insert some text.
builder.write("This is text inside textbox");
doc.save("C:\\Temp\\out.doc");
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.