Hi,
Is there any way to identify Bullet points in HTML version after converting docx to html
Thanks,
Renjith
Hi,
Is there any way to identify Bullet points in HTML version after converting docx to html
Thanks,
Renjith
Please try using the following code:
Document doc = new Document("E:\\temp\\in.docx");
doc.UpdateListLabels();
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
// Identify what are the bullet/list items in document
if (para.IsListItem)
{
Console.WriteLine(para.ToString(SaveFormat.Text));
}
}
// Identify bullet/list items in generated HTML by forllowing tags
// <ol>, <ul> and <li>
HtmlSaveOptions opts = new HtmlSaveOptions(SaveFormat.Html);
opts.PrettyFormat = true;
opts.ExportListLabels = ExportListLabels.ByHtmlTags;
doc.Save("E:\\Temp\\19.11.html", opts);
For more details about Document.UpdateListLabels method, please refer to the following link:
Document.UpdateListLabels method
In case you have further inquiries or need any help, please let us know.
Thanks for quick response. It worked fine with HtmlSaveOptions. But in my application I am using HtmlFixedSaveOptions. I cannot find the same property for HtmlFixedSaveOptions. I will be adding the save options what I am using below.
HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
options.setSaveFormat(SaveFormat.HTML_FIXED);
options.setPageIndex(0);
options.setPageCount(doc.getPageCount());
options.setExportEmbeddedImages(true);
options.setNumeralFormat(NumeralFormat.SYSTEM);
options.setExportEmbeddedCss(true);
options.setUseHighQualityRendering(true);
options.setPrettyFormat(true);
options.setExportEmbeddedSvg(true);
options.setExportEmbeddedFonts(true);
options.setCssClassNamesPrefix("Plag_lw_");
options.setExportFormFields(true);
Could you please help me do the same with HtmlFixedSaveOptions ?
In HtmlFixed file format, Aspose.Words saves the document in the HTML format by using absolutely positioned elements. So, in this case, it will not use standard HTML elements like <ol>, <ul> and <li>
for lists. Moreover, you cannot reload such HtmlFixed file back into Aspose.Words DOM (document object model) for reprocessing (Word-HtmlFixed-Word round-trip not supported). As a workaround, you may enclose the list items inside Bookmarks and then identify them in HtmlFixed. Sample HTML in this case will look like this:
<div class="awdiv" style="left:18pt; top:44.98pt; z-index:1;">
<a name="listBm1" style="left:0pt; top:0pt;">
</a>
<span class="awspan awtext001" style="font-size:11pt; left:0pt; top:0pt;">1.</span>
<span class="awspan awtext001" style="font-size:11pt; left:18pt; top:0pt;">First line in list item</span>
</div>
Thanks @awais.hafeez. The work around you provided works fine. Once again thanks for the quick response.