We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Insert text in a shape


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


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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



// Add paragraph into the textbox.

textbox.appendChild(new Paragraph(doc));

// Insert text box into the document.


// Move documentBuilder cursot to the paragraph inside the textbox.


// Insert some text.

builder.write("This is text inside textbox");


Hope this helps.

Best regards.


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

Best regards.