Text Indentation Not Preserved from docx->html->docx

Left paragraph indentation is not preserved when document is converted from word to html and then back to html. In this case actually the html itself is not preserving the indentation properly which is why the output word document is having the problem

See the screenshot below

image.png (800.9 KB)

I have also attached the in out and intermediat html documents . I would like to know root cause of this as this i not happen will all documents only with random few.

IN.docx (274.8 KB)
out.docx (81.2 KB)
out-0hml.zip (68.6 KB)

@cyrusdaru1 Unfortunately, I was unable to reproduce the issue you mentioned.
Please provide the code that perform the roundtrip you specified. We will check it and provide you more information.

Below is the Code

string dataDir = folderDgl.SelectedPath + @"\";
string selectedFile = fileDlg.FileName;
Document doc = new Document(selectedFile);
HtmlSaveOptions options = new HtmlSaveOptions
{
    HtmlVersion = Aspose.Words.Saving.HtmlVersion.Xhtml,
    ExportFontsAsBase64 = true,
    CssStyleSheetType = CssStyleSheetType.Embedded,
    ExportImagesAsBase64 = true,
    PrettyFormat = true,
    ExportPageSetup = true,
    ExportHeadersFootersMode = ExportHeadersFootersMode.None,
    //DocumentSplitCriteria = DocumentSplitCriteria.HeadingParagraph,
    //DocumentSplitHeadingLevel = 6,
    //ExportPageMargins = true,
    ExportRoundtripInformation = true,
    AllowNegativeIndent = true,
    //ExportDocumentProperties = true,
    //ExportListLabels = ExportListLabels.ByHtmlTags,
};
// Convert word document to HTML
doc.Save(dataDir + "main.html", options);

Document htmlDoc = new Document(dataDir + "main.html");

htmlDoc.Save(dataDir + "out-roundtrip.docx");

also attached the resulting input , output html and output doc file
Output.zip (405.6 KB)

@cyrusdaru1 Thank you for additional information. I have logged it as WORDSNET-24463. We will keep you informed and let you know once it is resolved.

Hi Vadim unfortunately i can not provide this answer to my customer to whome we are providing soultion based on your product. I also understand that you may fix this bug in your product some time in the future in the mean time i need to provide working solution to the customer. If you can tell me once the html is generated what style is going wrong and what do I it need to correct it in html. How do u intepreet Word Property to HTml and then back . I need some work around solution and can’t keep telling my customer that there are bugs in ASPOSE they have logged the ticket and they will address it some time. This is not a first bug that we have encountered there are many such issues.

@cyrusdaru1 Unfortunately, it is difficult to provide you a workaround at the moment. Once our developers complete analyzing the issue we will be able to provide you more information and if possible the workaround.

Hi please do u have any updates on the above . I am not expecting a fix in your code. All i am expecting what properties in the HTML should look for and change it to fix it when i convert it back to Word.

@cyrusdaru1 As a workaround, you can remove the ExportPageSetup from the roundtrip options and add manual copying of the PageSetup settings. Please consider the following code.

Document doc = new Document(selectedFile);
HtmlSaveOptions options = new HtmlSaveOptions
{
    HtmlVersion = Aspose.Words.Saving.HtmlVersion.Xhtml,
    ExportFontsAsBase64 = true,
    CssStyleSheetType = CssStyleSheetType.Embedded,
    ExportImagesAsBase64 = true,
    PrettyFormat = true,
    // ExportPageSetup = true,
    ExportHeadersFootersMode = ExportHeadersFootersMode.None,
    //DocumentSplitCriteria = DocumentSplitCriteria.HeadingParagraph,
    //DocumentSplitHeadingLevel = 6,
    //ExportPageMargins = true,
    ExportRoundtripInformation = true,
    AllowNegativeIndent = true,
    //ExportDocumentProperties = true,
    //ExportListLabels = ExportListLabels.ByHtmlTags,
};
// Convert word document to HTML
doc.Save(dataDir + "main.html", options);

Document htmlDoc = new Document(dataDir + "main.html");
PageSetup docPageSetup = doc.FirstSection.PageSetup;
PageSetup htmlDocPageSetup = htmlDoc.FirstSection.PageSetup;
htmlDocPageSetup.PageWidth = docPageSetup.PageWidth;
htmlDocPageSetup.PageHeight = docPageSetup.PageHeight;
htmlDocPageSetup.LeftMargin = docPageSetup.LeftMargin;
htmlDocPageSetup.RightMargin = docPageSetup.RightMargin;
htmlDocPageSetup.TopMargin = docPageSetup.TopMargin;
htmlDocPageSetup.BottomMargin = docPageSetup.BottomMargin;
htmlDocPageSetup.DifferentFirstPageHeaderFooter = docPageSetup.DifferentFirstPageHeaderFooter;
htmlDocPageSetup.HeaderDistance = docPageSetup.HeaderDistance;
htmlDocPageSetup.FooterDistance = docPageSetup.FooterDistance;

htmlDoc.Save(dataDir + "out-roundtrip.docx"); 

Please accept our apologies for your inconvenience.

The issues you have found earlier (filed as WORDSNET-24463) have been fixed in this Aspose.Words for .NET 23.6 update also available on NuGet.