web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Convert HTML to normal text

(0) ShareShare
ReportReport
Posted on by 4
Hi All,
 
Created one string field in parameter form. user will enter inputs in HTML format.
Need to display same field in SSRS report footer.
 
have followed below link (Written code in report DP class) and able to get text in SSRS report. but alignment is not proper. (Bold letter, Capital letter, next line are not coming properly)
 
Kindly help.
Thank you.
I have the same question (0)
  • Suggested answer
    Khan zain Profile Picture
    1 on at
    Convert HTML to normal text
    To ensure proper alignment and formatting when displaying HTML content from a string field in the SSRS report footer in Dynamics AX 2012, you can use a combination of methods to parse HTML and convert it into plain text. Here's a step-by-step approach to achieve this:
    1. **HTML to Plain Text Conversion**: Use X++ code in the report DP class to convert HTML content into plain text. You can utilize regular expressions or custom parsing logic to strip HTML tags and convert special characters.
    2. **Formatting Preservation**: Retain formatting such as bold letters, capital letters, and line breaks while converting HTML to plain text. Ensure that the conversion logic handles these elements appropriately.
    3. **Alignment**: Once the HTML content is converted to plain text, ensure proper alignment within the SSRS report footer. You may need to adjust the alignment settings in the SSRS report layout to accommodate the content correctly.
    Here's a sample code snippet demonstrating how you can achieve this in the report DP class:
    ```csharp
    public str convertHtmlToPlainText(str _html)
    {
        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("<[^>]+>|&nbsp;");
        str plainText = regex.Replace(_html, "");
        return plainText;
    }
    public void fetchReportData()
    {
        YourTable yourTable;
        str htmlContent;
        // Fetch HTML content from the table or data source
        select firstOnly yourTable;
        htmlContent = yourTable.HTMLField;
        // Convert HTML to plain text
        str plainText = convertHtmlToPlainText(htmlContent);
        // Set plain text content to the report footer field
        this.ReportFooterField = plainText;
    }
    ```
    Replace `"HTMLField"` and `"ReportFooterField"` with the appropriate field names in your context. This code snippet will convert HTML content stored in the `HTMLField` of your table to plain text and then assign it to the report footer field for proper alignment in the SSRS report.
    By following these steps, you can ensure that HTML content is correctly displayed in the SSRS report footer with proper alignment and formatting preservation. Adjust the code as needed to fit your specific requirements and data structures.
  • Martin Dráb Profile Picture
    235,876 Most Valuable Professional on at
    Convert HTML to normal text
    Plain text doesn't have formatting such as bold text; that's why it's called plain. You either want plain text or formatted text; it can't be both at the same time.
  • Community member Profile Picture
    4 on at
    Convert HTML to normal text
    Currently i am using D365 finance and operations.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 745 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 597 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 580 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans