I found that when trying to appendHtml text that contains hyperlink anchor tag <a> into existing document, the style of hyperlink is not applied on the hyperlink anchor text inside tag, but it is applied to text following the hyperlink.
So the hyperlink text is generated with standard black color and the following text is blue color and underlined. Only style is applied incorrectly, hyperlink is clickable only inside <a> tags not on the style basic text.
This happens until first use of <p> tag inside appended htmlText. Then the is everything correct.
Used spire.doc for Java version: 11.3
I have to mention that I am saving document to PDF (saving to DOCX works correctly)
Appended html text:
- Code: Select all
First use of hyperlink: <a href="https://www.e-iceblue.com" target="_blank" rel="noopener">www.e-iceblue.com</a> Bad style applied to basic text and not applied to hyperlink until second hyperlink start: <a href="https://www.e-iceblue.com" target="_blank" rel="noopener">www.e-iceblue.com</a>
<p>Use of paragraph tag inside appended htmlText and the hyperlink and text style is correct.<a href="https://www.e-iceblue.com" target="_blank" rel="noopener">www.e-iceblue.com</a></p>
Text and hyperlink style after usage of paragraph tag inside htmlText is correct:<a href="https://www.e-iceblue.com" target="_blank" rel="noopener">www.e-iceblue.com</a>
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);