aspose. word for java sets the page header left-center right layout, and the does not wrap,and text lengt not unfixed
new.zip (2.9 KB)
aspose. word for java sets the page header left-center right layout, and the does not wrap,and text lengt not unfixed
new.zip (2.9 KB)
@Mikeykiss In your example content is aligned using whitespaces, which is not the best practice. You can achieve what you need using table. For example see the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Move to header
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
// Create table with 3 cells to align content left-center-right
builder.startTable();
builder.getCellFormat().getBorders().setLineStyle(LineStyle.NONE);
builder.insertCell();
builder.getParagraphFormat().setAlignment(ParagraphAlignment.LEFT);
builder.write("LEFT");
builder.insertCell();
builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
builder.write("CENTER");
builder.insertCell();
builder.getParagraphFormat().setAlignment(ParagraphAlignment.RIGHT);
builder.write("RIGHT");
builder.endRow();
builder.endTable();
doc.save("C:\\Temp\\out.docx");