Alignment issue while converting docx to html content

Hello support team,

I am facing an alignment issue while converting Docx binary data to HTML string for the attached file.
Kyle_Tucker.docx (14.2 KB)

I also tried with aspose online converter tool and faced the same issue
https://products.aspose.app/words/conversion

@khyatitank, please consider the following code:

Document doc = new Document("Kyle_Tucker.docx");
HtmlSaveOptions so = new HtmlSaveOptions();
so.ExportPageMargins = true;
doc.Save("Kyle_Tucker123.html", so);

To achieve the most similar layout in the output document, you can also consider

doc.Save("Kyle_Tucker123.html", SaveFormat.HtmlFixed);

I am not able to see any option “so.ExportPageMargins = true;” in aspose 13.3.0.0 version

Is it available on the latest version?

Also when i use “doc.Save(“Kyle_Tucker123.html”, SaveFormat.HtmlFixed);” option then i am getting error “Resource file(s) cannot be written to disk. When saving the document to a stream either ResourceFolder should be specified or ExportEmbeddedImages, ExportEmbeddedFonts and ExportEmbeddedCss should be set or custom streams should be provided via ResourceSavingCallback.”

@khyatitank

Yes. We strongly recommend that you use the latest version of Aspose.Words.

To fix this error, you can explicitly specify the ResourcesFolder.

HtmlFixedSaveOptions so = new HtmlFixedSaveOptions();
so.ResourcesFolder = "Kyle_Tucker";
doc.Save("Kyle_Tucker.html", so);

Is there any feasibility to solve this issue by using aspose 13.3.0.0 version?

@khyatitank as I mentioned in the previous post, you can try exporting to HtmlFixed format with an explicit ResourcesFolder. In this case the resulting layout will be as close as possible to the original one.

I tried it but the “ResourcesFolder” option is also not exists in Aspose 13.3.0.0 version.

@khyatitank actually the ResourcesFolder option is available in version 13.3, you may be confusing HtmlFixedSaveOptions and HtmlSaveOptions. Please check it again.

I also checked with " HtmlFixedSaveOptions" and still getting alignment issue by using this option.
Please find attached screenshot for more details

image.png (16.9 KB)

@khyatitank actually, the screenshot you sent doesn’t look similar to saving with HtmlFixedSaveOptions option. Most probably, you have not passed the option to Save() method.

HtmlFixedSaveOptions so = new HtmlFixedSaveOptions();
so.ResourcesFolder = "Kyle_Tucker";
doc.Save("Kyle_Tucker.html", so);

I am attaching the conversion result with HtmlFixedSaveOptions option on the latest version of Aspose.Words.
Output.zip (65.3 KB)

I have written the same code in Aspose 13.3.0.0 version and it is not working that’s why I send the above-mentioned image which was the output HTML.

My Code :

Output :

@khyatitank

But I see completely different results in the screenshot posted above and in the screenshot posted below. Yet the source code was different, wasn’t it?

How did you get the output specified in the screenshot, whereas you state that the code does not work? Do you mean it works without errors, but it doesn’t produce the result you want?

In any case, as I have pointed out above, HtmlFixed gives the result that is as close as possible to Docx layout. If you are not satisfied with the conversion result of HtmlFixed version 13.3, then I can only recommend you to upgrade to Aspose.Words latest version. In the latest version the layout result is identical to that of Docx (see my attachment above).

How did you get the output specified in the screenshot, whereas you state that the code does not work? Do you mean it works without errors, but it doesn’t produce the result you want?

=> Yes, it works without error but doesn’t produce the result I want.

@khyatitank, please update to the latest version of Aspose.Words.