As in my application we are retrieving the data from the database and tying to implement a document file using ASPOSE.WORD api please could you provide a code snippet from the scenario.
As i had attached the target file for reference.
As in my application we are retrieving the data from the database and tying to implement a document file using ASPOSE.WORD api please could you provide a code snippet from the scenario.
As i had attached the target file for reference.
Hi Mahesh,
Thanks for your inquiry. Please read following documentation link for your kind reference.
https://docs.aspose.com/words/java/using-documentbuilder-to-modify-a-document/
Following code example shows how to set page margin, writing contents with list items and font formatting. Hope this helps you.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set page margin
builder.getPageSetup().setLeftMargin(36);
builder.getPageSetup().setRightMargin(36);
builder.getPageSetup().setTopMargin(36);
builder.getPageSetup().setBottomMargin(36);
builder.getPageSetup().getBorders().setLineStyle(LineStyle.SINGLE);
// Set font size
builder.getFont().setSize(10);
builder.getFont().setBold(true);
builder.getFont().setUnderline(Underline.SINGLE);
builder.writeln("SECTION");
builder.writeln();
builder.getFont().setUnderline(Underline.NONE);
List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);
list.getListLevels().get(0).setNumberStyle(NumberStyle.ARABIC);
list.getListLevels().get(1).setNumberStyle(NumberStyle.ARABIC);
list.getListLevels().get(0).setNumberFormat("\u0000.");
list.getListLevels().get(1).setNumberFormat("\u0000.\u0001");
list.getListLevels().get(0).getFont().setBold(true);
list.getListLevels().get(1).getFont().setBold(true);
builder.getListFormat().setList(list);
builder.writeln("ABC");
builder.getListFormat().listIndent();
builder.getFont().setBold(true);
builder.write("ABC: ");
builder.getFont().setBold(false);
builder.writeln(": The sample text which is coming from database from and need to attached to "
+ "the document. sample text which is coming from database from and need to attached to the document. ");
builder.getFont().setBold(true);
builder.write("ABC: ");
builder.getFont().setBold(false);
builder.writeln(": The sample text which is coming from database from and need to attached to "
+ "the document. sample text which is coming from database from and need to attached to the document. ");
builder.getListFormat().removeNumbers();
doc.save(MyDir + "Out.docx");