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.
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.
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