Hi,
We are trying to convert docx to html, but facing different issues regarding layout. Following are the two ways we tried converting:
-
Using HtmlSaveOptions:
htmlSaveOptions.setCssStyleSheetType(CssStyleSheetType.EMBEDDED); htmlSaveOptions.setExportImagesAsBase64(true); htmlSaveOptions.setExportFontsAsBase64(true); htmlSaveOptions.setUseHighQualityRendering(true); htmlSaveOptions.setEncoding(StandardCharsets.UTF_8); htmlSaveOptions.setPrettyFormat(true); com.aspose.words.Document wordsDocument = new com.aspose.words.Document(new ByteArrayInputStream(FileUtils.readFileToByteArray(new File("C:\\Project_Data\\sblc\\Enhancement at TCFE322.docx")))); wordsDocument.save(outputStreamHtml, htmlSaveOptions);
With this approach, the converted html is not properly aligned and has missing fields as well as many bookmarks attached.
So we tried another approach:
-
Using HtmlFixedSaveOptions:
com.aspose.words.HtmlSaveOptions htmlSaveOptions = new com.aspose.words.HtmlSaveOptions(); htmlSaveOptions.setCssStyleSheetType(CssStyleSheetType.EMBEDDED); htmlSaveOptions.setExportImagesAsBase64(true); htmlSaveOptions.setExportFontsAsBase64(true); htmlSaveOptions.setUseHighQualityRendering(true); htmlSaveOptions.setEncoding(StandardCharsets.UTF_8); htmlSaveOptions.setPrettyFormat(true); com.aspose.words.Document wordsDocument = new com.aspose.words.Document(new ByteArrayInputStream(FileUtils.readFileToByteArray(new File("C:\\Project_Data\\sblc\\Enhancement at TCFE322.docx")))); wordsDocument.save(outputStreamHtml, htmlSaveOptions);
We this approach the converted html looks fine but still first two fields are getting overlapped. And also the converted html size is 1135 Kb, whereas with first approach it was just 64 Kb.
===================================================================
I’ve attached docx file. Please help with the same.
Thanks!Enhancement at TCFE322.docx (25.9 KB)