Aspose Html to Word conversion is failing

We are evaluating Aspose.Words .Net Core based solution for Html -> Word conversion for our live application.

While converting a file from html -> word, the output word file is not coming that well.

The code used for conversion is mentioned below
Aspose.Words.Document doc = new Aspose.Words.Document(dataDir + “cover_page.html”);
doc.Save(dataDir + “cover_page.doc”);

The input html file and converted word file are attached with this post.Aspose.Words.zip (53.6 KB)

Please have a look at it at the earliest.

Regards,
Nipun Jain

@nipunjainindia,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-17443. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Hi team,

We are considering Aspose.Words as a replacement for cloud convert for our Live Application. But for that we need this issue to be fixed.

When can we expect this issue to be fixed.

Regards,
Nipun Jain

@nipunjainindia,

Thanks for being patient. Your issue is currently pending for analysis and is in the queue. There are no estimates available at the moment. Once the analysis of this issue is completed, we may then be able to calculate and share the ETA with you. We apologize for any inconvenience.

Hi Team,

Can we expedite the process to resolve this issue.

Regards,
Nipun Jain

@nipunjainindia,

If this issue is important to you, and for the fast resolution of this issue, please have a look at paid support options - e.g. purchasing Paid Support will allow you to post your issues in our Paid Support Helpdesk and raise the priority of this issue. Many Paid Support customers find that this leads to their issue being fixed in the next release of the software.

If you would like to take advantage of Paid Support then please request a quote in our purchase forum - Aspose.Purchase - Free Support Forum - aspose.com

@nipunjainindia,

Regarding WORDSNET-17443, the source HTML document has the following structure (only relevant parts are shown):

<style>
    .ql-container.ql-snow {
        background-color: #e8e8e8;
    }
    .ql-container > .ql-editor {
        background-color: #fefefe;
    }
</style
<body class="ql-container ql-snow">
    <div class="ql-editor">
        <!-- ... -->
    </div>
</body>

Background color of the <body> element is gray, and Aspose.Words uses it as Page Color. However, gray color is not visible in browsers, because <body> is fully covered with white <div>, which is not imported by Aspose.Words. MS Word produces better results for this document, because it does not import “background-color” of <body> elements as Page Color.

I think, we could improve import logic of Page Color by adding special processing for cases where <body> elements are fully covered by nested block-level elements (<div>, for example). We could import “background-color” of the innermost block as Page Color.

As a workaround, you can remove the "background-color: #e8e8e8" declaration from the stylesheet of the HTML document. Hope, this helps.

@nipunjainindia,

After further investigation, we would like to suggest you to use any of the following workarounds:

Reset background color of the document programmatically:

Document doc = new Document("in.html");
doc.BackgroundShape = null;
doc.Save("out.docx");

Or edit the source HTML document and remove the “background-color” style from the <body> element:

.ql-container.ql-snow {
    <!-- background-color: #e8e8e8; -->
    font-size: 12pt;
}

Hope, this helps.