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

Free Support Forum - aspose.com

Question about using TextBox and Document Builder

Hi,

i’m trying to put some text at a special position on a page using a textbox. i get the textbox placed where i want to. but there are two issues i’m tackling with:

1. how can i format the border of the textbox ? i don’t want any type of border aroung the box)
2. the text i’m adding appears in the regular context and does not bind to the textbox. what am i doing wrong here?

the code i set up till now is the following:

Shape textBox = new Shape(doc, ShapeType.TEXT_BOX);

textBox.setWrapType(WrapType.NONE);

textBox.setHorizontalAlignment(HorizontalAlignment.RIGHT);

textBox.setVerticalAlignment(VerticalAlignment.TOP);

textBox.setHeight(20);

textBox.setWidth(100);

// trying to remove the border

textBox.setStroked(false);

textBox.setStrokeWeight(0);


// inserting the shape

builder.insertNode(textBox);

// inserting a paragraph 4 text

builder.insertParagraph();

builder.writeln("Text 4 the TextBox");


thanks a lot for your help!

best regards,

christian

Hi Christian,

Thanks for using Aspose.Words.

Please try the code below, the textbox appears properly in the output on my side.

Shape textBox = new Shape(doc, ShapeType.TEXT_BOX);

textBox.setWrapType(WrapType.NONE);
textBox.setHorizontalAlignment(HorizontalAlignment.RIGHT);
textBox.setStroked(false);

textBox.setVerticalAlignment(VerticalAlignment.TOP);

textBox.setHeight(20);

textBox.setWidth(100);

Paragraph para = new Paragraph(doc);
Run run = new Run(doc);
run.setText("Text 4 the Textbox");
para.appendChild(run);

textBox.appendChild(para);

// inserting the shape

builder.insertNode(textBox);

Thanks,

hi Adam,

thanks a lot for this very valuable Information ! I hadn’t found any example - till now - where it was shown to combine those “run-methods” with the “document builder way” (as there are may examples using the “run-method” of building a document and not that much which use the DocumentBuilder).

best regards,
christian

Hi Christian,

Thanks for bringing this to my attention, I will look into making this more clearer in the documentation.

Thanks,