Adding indent to a list

Hi Team,

I need help in setting indent to a list. In the below code snippet, I have 2 independent lists. I want them both to have left indents of 50. Additionally, I want the second list to gain extra left indent depending upon user’s input. In this case, it’s the variable ‘extraIndent’ resembling that user input. The output I get is two lists having the same left indent. Why is the second list not having the extra indent?

          public static void main(String args[]) throws Exception
     {
	AsposeUtils.setupLicense();
	double extraIndent = 18;
	Document doc = new Document();
	DocumentBuilder docBuilder = new DocumentBuilder(doc);
	
	//Paragraph level indent - 50 applied
	docBuilder.getParagraphFormat().setLeftIndent(50);

	//List1 begins here
	docBuilder.getListFormat().applyNumberDefault();
	docBuilder.getListFormat().getListLevel().setNumberStyle(NumberStyle.BULLET);
	docBuilder.getListFormat().getListLevel().setNumberFormat("\u00B7"); //$NON-NLS-1$
	docBuilder.getListFormat().getListLevel().getFont().setName("Symbol"); //$NON-NLS-1$

	docBuilder.getCurrentParagraph().getParagraphBreakFont().clearFormatting();
	docBuilder.write("Bullet List Main");
	docBuilder.getFont().clearFormatting();
	
	//List 2 begins here
	docBuilder.writeln();
	docBuilder.getParagraphFormat().clearFormatting();
	
	//Again Paragraph level indent - 50 applied
	docBuilder.getParagraphFormat().setLeftIndent(50);
	docBuilder.getFont().clearFormatting();
	docBuilder.getListFormat().applyNumberDefault();
	docBuilder.getListFormat().getListLevel().setNumberStyle(NumberStyle.BULLET);
	docBuilder.getListFormat().getListLevel().setNumberFormat("\u00B7"); //$NON-NLS-1$
	docBuilder.getListFormat().getListLevel().getFont().setName("Symbol"); //$NON-NLS-1$
	
            //EXTRA INDENT of 18 being added
	ListLevel listLevel = docBuilder.getListFormat().getListLevel();
	double numberPosition = listLevel.getNumberPosition();
	double textPosition = listLevel.getTextPosition();
	docBuilder.getListFormat().getListLevel().setNumberPosition(numberPosition + extraIndent);
	docBuilder.getListFormat().getListLevel().setTextPosition(textPosition + extraIndent);
	listLevel.setTabPosition(listLevel.getTextPosition());
	
	
	docBuilder.getParagraphFormat().setBidi(false);
	docBuilder.getCurrentParagraph().getParagraphBreakFont().clearFormatting();
	docBuilder.write("Bullet list with extra indent of 18");
	docBuilder.getFont().clearFormatting();
	
	doc.updateFields();
	doc.save("D:\\ABCDE\\trial\\test3.doc");
        }

@Akash007

Thanks for your inquiry. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

test3.zip (5.7 KB)
The attached zip has the expected word output.

@Akash007

Thanks for sharing the detail. The ListLevel.NumberPosition corresponds to LeftIndent plus FirstLineIndent of the paragraph.You can use ParagraphFormat.LeftIndent property to achieve your requirement.