Dear Aspose Team,
is there any possibility to create multiline bookmarks using Aspose.Words and export them within an anchor tag to HTML?
Within an document I can create single line bookmarks using this way:
builder.startBookmark("myid");
builder.write("some text");
builder.endBookmark("myid");
and the resulting HTML output will be
<a id="myid">some text</a>
but if I insert multiple lines
builder.startBookmark("myid");
builder.writeln("some");
builder.write("text");
builder.endBookmark("myid");
the resulting HTML output will be
<p><a id="myid">some</a></p>
<p>... text </p>
(i removed all the layouting stuff here for clarification)
My goal is to import HTML using builder.insertHtml( some_text, true) within an bookmark.
Best regards,
Andreas
@andreas.gerasch,
Please check this HTML (awjava-21.6.zip (456 Bytes)) was produced by using the following code of Aspose.Words for Java 21.6:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.startBookmark("myid");
builder.writeln("some");
builder.write("text");
builder.endBookmark("myid");
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.HTML);
htmlSaveOptions.setPrettyFormat(true);
doc.save("C:\\Temp\\awjava-21.6.html", htmlSaveOptions);
And when I inserted this above HTML by using the following code, the multi-line bookmark was preserved in output Word DOCX document (see awjava-21.6.docx (7.2 KB)):
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
String data = new String(Files.readAllBytes(Paths.get("C:\\Temp\\awjava-21.6.html")));
builder.insertHtml(data);
doc.save("C:\\Temp\\awjava-21.6.docx");
So, please upgrade to the latest (21.6) version of Aspose.Words for Java and see how it goes on your end?
Hi @awais.hafeez,
Thank you very much. I understand that a multiline bookmark in HTML is realised by aspose using a follow-up span tag with a special style attribute:
<div>
<p style="margin-top:0pt; margin-bottom:0pt">
<a name="myid"><span>some</span></a>
</p>
<p style="margin-top:0pt; margin-bottom:0pt">
<span>text</span><span style="-aw-bookmark-end:myid"></span>
</p>
</div>
But what is the reason, for not using a single anchor tag around the full bookmark section? I would expect the following:
<div>
<a name="myid">
<p style="margin-top:0pt; margin-bottom:0pt">
<span>some</span>
</p>
<p style="margin-top:0pt; margin-bottom:0pt">
<span>text</span>
</p>
</a>
</div>
Best regards,
Andreas
@andreas.gerasch,
We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-22474. We will further look into the details of this requirement and will keep you updated here on the status of the linked ticket. We apologize for any inconvenience.