We're sorry Aspose doesn't work properply without JavaScript enabled.

Not able to save wavy underlines for text while saving docx to html format

hi…I am using aspose for save docx data, When I upload docx & save data with Japanese & English text but some text has wavy underline so while saving docx to html it saves as plain under line instead of wavy underlines.

@kamlesh1293 Thank you for reporting this problem to us. Aspose.Words in this case mimics MS Word behavior, it also does not preserve underline style. However, we will consider preserving it in Aspose.Words. I have logged this issue as WORDSNET-23782. We will keep you informed and let you know once it is resolved.

@alexey.noskov thanks for reply, You have any timeline for this fix/release? or if you have any other workaround then please provide workaround in meanwhile.

@kamlesh1293 Unfortunately, currently it is not possible to provide you an estimate. We will be able to provide you additional information once our developers complete the analysis of this issue.
Currently you can try using SaveFormat.HtmlFixed instead of Html, in this case wavy underline is preserved. But this type of HTML is not recommended to use if you need to edit your HTML.

Document doc = new Document("C:\\Temp\\in.docx");
doc.Save("C:\\Temp\\out.html", SaveFormat.HtmlFixed);


I am trying to do this kind of code, and it gives this error while running the java project, so any way to workaround that will be helpful. please find JAVA project code zip file and error screenshot.
aspose-sample.zip (57.0 KB)

image.png (79.4 KB)

@kamlesh1293 You can pass only HTML or TEXT save format into Node.toString(SaveFormat) method. In your case, you can import the required node into a separate document and then use code like the following to het it’s HtmlFixed string:

HtmlFixedSaveOptions opt = new HtmlFixedSaveOptions();
opt.setExportEmbeddedSvg(true);
opt.setExportEmbeddedImages(true);
opt.setExportEmbeddedCss(true);
opt.setExportEmbeddedFonts(true);

ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
doc.save(dstStream, opt);

byte[] htmlBytes = dstStream.toByteArray();
String html = new String(htmlBytes, StandardCharsets.UTF_8);


image.png (159.3 KB)
@alexey.noskov i am facing one more column width related issue, after saving as html not able to retain width of column so its shows 1 or 2 characters per line, can you please provide some solution for that.

@kamlesh1293 Could you please attach your input and output document here for testing? We will check the issue and provide you more information.

Ok… PFA Input documnet and output html which inside zip folder…output.zip (63.4 KB)
Sample_File_Coverpage.docx (48.3 KB)

@kamlesh1293 Thank you for additional information. I cannot reproduce the problem on my side using the latest 22.5 version of Aspose.Words. Here code I used for testing:

Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out.html", SaveFormat.HtmlFixed);


[quote=“alexey.noskov, post:6, topic:245235”]

@alexey.noskov Thanks, But we are not converting whole document to html we are converting selective section from whole document so please try this type of code and provide solution.

FYI, I have used the latest 22.4 of aspose words JAVA.so with it i am also able to convert whole document but we have to perform same thing on selective section. PFA i have attached code to run as JAVA Project. & code screenshot
aspose-sample.zip (60.3 KB)
image.png (69.3 KB)

@kamlesh1293 You can use code like the following to export a separate node to HTML Fixed:

private static String NodeToHtmlFixed(Node node) throws Exception {
if (node.getNodeType() != NodeType.PARAGRAPH && node.getNodeType() != NodeType.TABLE)
throw new InvalidParameterException("Node must be block level - Paragraph of Table");

Document doc = (Document) node.getDocument().deepClone(false);
doc.ensureMinimum();

Node importedNode = doc.importNode(node, true, ImportFormatMode.USE_DESTINATION_STYLES);
doc.getFirstSection().getBody().removeAllChildren();
doc.getFirstSection().getBody().appendChild(importedNode);

// Save as Fixed HTML
HtmlFixedSaveOptions opt = new HtmlFixedSaveOptions();
opt.setExportEmbeddedSvg(true);
opt.setExportEmbeddedImages(true);
opt.setExportEmbeddedCss(true);
opt.setExportEmbeddedFonts(true);

ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
doc.save(dstStream, opt);

byte[] htmlBytes = dstStream.toByteArray();
return new String(htmlBytes, StandardCharsets.UTF_8);
}


But you should note that it will be exported as a page.

Regarding the original issue, unfortunately, it has been postponed till later date.