Completed
Last Updated: 08 Jul 2025 11:27 by Nate
Nate
Created on: 02 Jan 2025 12:46
Category: Grid
Type: Feature Request
2
Incorporate new code which will treat hyphens as if it were a space upon ExportToPdf()

Business Need - User Story Terminology:

As a Telerik Support Specialist, I would like our programmers to incorporate new code which will treat hyphens as if it were a space upon ExportToPdf() so that we gracefully handle for scenarios where a very long word with a hyphen will wrap to the next line instead of overlapping other content.

 

RadGrid.MasterTableView.ExportToPdf() - we would like telerik to update logic to do a normal word wrap when a hyphen exists rather than not wrapping when there's not enough room in the grid cell | View Ticket | Your Account

3 comments
Nate
Posted on: 08 Jul 2025 11:27

you have ada compliance issues with overlapping data in really long words for exporttopdf hyphens are an issue because it makes for an even longer realistic word.  but this is an issue overall and would appreciate a mid-word break whenever a long word extends into the next cell.  otherwise the words overlap and they become unreadable by an end user.  We continue to have to put in custom code to address certain columns where we know users have longer words than the length of the cell.  But this is not an elegant fix and we continue to have to resolve these problems one by one throughout our site.  

We cannot just assume any hyphenated word is an issue and replace with a space as you suggest it's not quite logical.

ADMIN
Attila Antal
Posted on: 04 Jul 2025 09:40

Hi Nate,

Thank you for submitting this feature request. After thorough investigation we concluded that the implementation of this feature would not work consistently and intuitively and thus will not be suitable for all use cases.

If one would like such feature, they can handle that in the PdfExporting event of the Grid where they can replace the Hyphens with whitespaces respectively.

Example

protected void RadGrid1_PdfExporting(object sender, GridPdfExportingArgs e)
{
    // Replace hyphens only inside <td>...</td> elements, preserving attributes in <td>
    string pattern = @"(<td\b[^>]*>)(.*?)(</td>)";
    e.RawHTML = System.Text.RegularExpressions.Regex.Replace(
        e.RawHTML,
        pattern,
        match =>
        {
            string openTag = match.Groups[1].Value;
            string innerText = match.Groups[2].Value.Replace("-", "- ");
            string closeTag = match.Groups[3].Value;
            return openTag + innerText + closeTag;
        },
        System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Singleline
    );
}

Note: This will replace the hyphens in all cells, so words such as "e-mail", "check-in", "clean-cut", "follow-up", etc.. will also be affected. If you need to break specific words, use additional context (e.g. Replace("SomeKeyWord-", "- ");) to target them specifically.

Thank you for your understanding.

Regards,
Attila Antal
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Nate
Posted on: 30 Jun 2025 16:55
This one continues to be problematic for our team and application.  Rather than just handling for the hyphen we would prefer if Telerik would enforce a mid-word wrap for any word that is longer than the width of the column so we don't have to continue to resolve this issue at the application code end.