Insert text in a shape

Hi!

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 attention and your time…

Eduardo Prisco

Hi

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");

Hope this helps.
Best regards.

Hi,

Thanks for your answer, I’ve used this code and it’s ok. It’s wouldn’t be the last inquiry…

Best regards.