HTML content not rendering as expected using the LINQ reporting engine

Hi Team,

I have tested the template syntaxes mentioned below in my template and am trying to render the attached HTML content using the LINQ reporting engine.

Tag and Expression:
<<html [HtmlContent]>>

Tag, Expression and switch:
<<html [HtmlContent] -sourceStyles>>

Expression and switch:
<<[HtmlContent] -html>>

HTML content:

<hr style="height: 4px; color: rgb(36,69,116);">
    <table width="100%" style="background-color: rgb(237,237,237);">
        <tr>
            <td colspan="1" rowspan="1">
                <table width="40%" cellspacing="0" cellpadding="0" style="color: rgb(38,68,116); font-size: 9px; font-family: Arial;">
                    <tr>
                        <th align="left" colspan="1" rowspan="1" width="50%">Service Plan</th>
                        <th align="center" colspan="1" rowspan="1" width="50%">4 Year</th>
                    </tr>
                    <tr>
                        <td colspan="1" rowspan="1">Multi-Year Discount</td>
                        <td colspan="1" rowspan="1" style="text-align: center;">10%</td>
                    </tr>
                    <tr>
                        <td colspan="1" rowspan="1">POS Discount</td>
                        <td colspan="1" rowspan="1" style="text-align: center;">10%</td>
                    </tr>
                    <tr>
                        <td colspan="1" rowspan="1">Total Savings</td>
                        <td colspan="1" rowspan="1" style="text-align: center;">$16,720.00</td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <hr style="height: 4px; color: rgb(15,135,200);">
    <table width="100%" style="background-color: rgb(237,237,237);">
        <tr>
            <td colspan="1" rowspan="1">
                <table width="40%" style="color: rgb(15,135,200); font-size: 9px; font-family: Arial; background-color: rgb(237,237,237);">
                    <tr>
                        <td colspan="1" rowspan="1" width="50%"><b>Grand Total</b></td>
                        <td colspan="1" rowspan="1" style="text-align: center;" width="50%"><b>$71,280.00</b></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

Issue:
Aspose.Words do not honour the inline styles of the hr tag, but it does honour the inline styles of the table tag.

Attached are the artefacts for your review. Please share your thoughts, and feel free to reach out if you need any clarification.

Input Template:
AsposeLinqTemplate.docx (15.2 KB)

Output Document:
MergedDocument.docx (23.8 KB)

Code:
DataMerger.zip (849 Bytes)

Thanks,
Hiren

@HirenT

It seems you’re experiencing an issue with the rendering of inline styles for the <hr> tag when using the Aspose LINQ Reporting Engine. Unfortunately, Aspose.Words does not seem to support inline styles for the <hr> tag, which can lead to unexpected results in your output document.

However, it does honor the inline styles for other HTML elements, such as <table>. To work around this limitation, you could consider using an alternative method for creating horizontal lines, such as using a styled <div> or a <table> with a single row and cell to mimic the appearance of a horizontal rule.

Here’s a simple example of how you could replace the <hr> tags with styled <div> elements:

<div style="height: 4px; background-color: rgb(36,69,116); width: 100%;"></div>

You can use this styled <div> in place of the <hr> tags in your HTML content. Adjust the styles as needed to achieve the desired look.

If you continue to face issues or have specific requirements that are not being met, I recommend reaching out on the Aspose support forums for more tailored assistance. They can provide guidance based on the latest features and updates of the LINQ Reporting Engine.

Feel free to ask if you have further questions or need more help!

Are there any plans in the current roadmap to enhance the HTML rendering logic in the Aspose.Words library to support inline styles for all basic HTML elements?

@HirenT You should note, Aspose.Words Document Object Model is designed to work with MS Word documents. HTML documents object model is quite different and it is not always possible to provide 100% fidelity after importing or exporting HTML document. Usually Aspose.Words mimics MS Word behavior when work with HTML documents.
If possible, could you please provide the expected output you would like to get?

Thanks, @Alexey Noskov for your response.

In my understanding, the <hr> tag is one of the fundamental HTML tags, similar to <div> and <table>. Just as the <table> tag allows for inline styles with basic font formatting, such as colour, font name, and size, shouldn’t we also have the same support for the <hr> tag?

I am attaching the expected output document for your reference.
ExpectedDocument.docx (15.2 KB)

Regards,
Hiren

@HirenT As I can see <hr> looks incorrect in browser too:


To make it look correct in the browser it should be changed to

<hr style="height: 4px; background-color: rgb(36,69,116);">

Though, Aspose.Words the same as MS Word does not preserve <hr> color after importing HTML.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-28367

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks for your findings. Let me check with the updated HTML.

1 Like