Hi,
We are encountering additional line space between the note information(bullet points list) and the next paragraph and when bullet points are needed, that the letter produces extra line spacing between the bullet point and the next paragraph.
Testing with Aspose 21.4 version
Is there a way to correct that in the letter template standpoint and please let us know the expected behavior as per the Aspose product.
Thank you.
@jcash_casenetllc_com Could you please also provide your data source and code, which will allow us to reproduce the problem? We will check the issue and provide you more information.
@alexey.noskov As mentioned in the previous comment, I extracted the code working with the template into a minimal console application and able to reproduce the problem with the template.
Instruction to run the sample console application:
@jcash_casenetllc_com You are using an old version of Aspose.Words, in newer version of Aspose.Words you can use HtmlInsertOptions.REMOVE_LAST_EMPTY_PARAGRAPH
to avoid an empty paragraph after inserting block level nodes from HTML. The code will look like this:
documentBuilder.insertHtml(userNote, HtmlInsertOptions.REMOVE_LAST_EMPTY_PARAGRAPH);
In your code you reset font size of the empty paragraph to zero, which also does the trick as I can see.
@jcash_casenetllc_com
-
This feature has been added in 21.7 version of Aspose.Words:
https://releases.aspose.com/words/java/release-notes/2021/aspose-words-for-java-21-7-release-notes/
-
You already have this code in the project you have shaped earlier:
for(Paragraph paragraph :(Iterable<Paragraph>)doc.getChildNodes(NodeType.PARAGRAPH, true))
{
if(paragraph.getNextSibling() != null && paragraph.getPreviousSibling() != null
&& paragraph.toString(SaveFormat.TEXT).trim().length() == 0)
paragraph.getParagraphBreakFont().setSize(1.0);
}
- No, unfortunately, there is no way to resolve this problem in the template, since it is caused by insertion of HTML into the document.
@alexey.noskov ,
- As you mentioned above, I verified the problem by placing the following piece of code in the 21.7 version of Aspose.Words, still I can see the problem.
documentBuilder.insertHtml(userNote, HtmlInsertOptions.REMOVE_LAST_EMPTY_PARAGRAPH);
- You mentioned with the following code, the problem should not happen in the sample console application with 21.4 versions of Aspose.Words but why it is still happening, Is it I’m doing in the wrong way or is there any other changes also required.
for(Paragraph paragraph :(Iterable<Paragraph>)doc.getChildNodes(NodeType.PARAGRAPH, true))
{
if(paragraph.getNextSibling() != null && paragraph.getPreviousSibling() != null
&& paragraph.toString(SaveFormat.TEXT).trim().length() == 0)
paragraph.getParagraphBreakFont().setSize(1.0);
}
Thank you
@jcash_casenetllc_com There is no empty paragraph after list item:
You can save the document as DOCX to make sure there is no empty paragraph.
The space is caused by paragraph spacing after: