When trying to appendHtml text to existing document, the text is cut before use of <a> or <br> tag
If htmlString to be appended to paragraph is as follows,
- Code: Select all
Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br>
Curabitur hendrerit. Phasellus (<a target=\"_blank\" href=\"https://www.e-iceblue.com\">www.e-iceblue.com</a>)
Etiam odio pretium molestie. Vestibulum
appended result is cut before <br> tag:
- Code: Select all
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
If htmlString to be appended to paragraph is as follows,
- Code: Select all
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur hendrerit. Phasellus (<a target=\"_blank\" href=\"https://www.e-iceblue.com\">www.e-iceblue.com</a>)
Etiam odio pretium molestie. Vestibulum
appended result is cut before <a> tag:
- Code: Select all
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur hendrerit. Phasellus (
Hotfix to this behaviour is to add at the end of appended htmlString empty <p></p> tag.
if htmlString to be appended to paragraph is as follows,
- Code: Select all
Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br>
Curabitur hendrerit. Phasellus (<a target=\"_blank\" href=\"https://www.e-iceblue.com\">www.e-iceblue.com</a>)
Etiam odio pretium molestie. Vestibulum
<p></p>
appended result is as expected:
- Code: Select all
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur hendrerit. Phasellus (www.e-iceblue.com) Etiam odio pretium molestie. Vestibulum
Code used to append htmlString to existing document is:
- Code: Select all
Section tempSection = document.addSection();
tempSection.addParagraph().appendHTML(htmlString);
TextBodySelection selection = new TextBodySelection(tempSection.getBody(), 0, tempSection.getBody().getChildObjects().getCount() - 1, 0, 0);
TextBodyPart bodyPart = new TextBodyPart(selection);
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
bookmarkNavigator.moveToBookmark(bookmarkName);
bookmarkNavigator.replaceBookmarkContent(bodyPart);
document.getSections().remove(tempSection);