Last Updated: 24 Feb 2021 10:04 by ADMIN
Release R1 2021 SP1
Created on: 03 Feb 2021 10:36
Type: Bug Report
In specific cases, the report PDF rendering may fail with an exception under .NET 5 in a Linux environment

The following error may be thrown when trying to render a report in PDF under .NET 5 in the Linux systems:

"SEH":"System.ArgumentOutOfRangeException: Index and length must refer to a location within the string. (Parameter 'length')
          at System.String.Substring(Int32 startIndex, Int32 length)
          at Telerik.Reporting.Paging.TextBox.MeasureText(String text, TextFormat format)
          at Telerik.Reporting.Paging.TextBox.CreateContent(InitializationContext initContext)

The same reports work correctly in Windows.

Posted on: 10 Feb 2021 13:22

Hello Fox,

Our developer who investigated the issue replied in detail in the support ticket you opened on the issue. I will summarize the findings also here for the benefit of the community.

The bug is reproduced only in .NET 5.0 applications. In .NET Core 2.1+ the report rendering works fine. The problem is related to the string measurement that returns different results per different .NET frameworks. We believe that the way the special characters in a string are handled is changed.

The issue occurs when the rendering engine tries to measure the text in a textBox value that consists of spaces and new line characters:

" \n \n\n \n"

When measured in a .NET Core 3.1 app, the routine that calculates how many characters can fit in the textbox bounds correctly returns 7. However, when we measure the same string in a .NET 5.0 app, the fitted characters are evaluated to 8, which is obviously wrong and results in an ArgumentOutOfRange exception. Actually, to calculate the fitted characters, we rely on the libgdiplus library which has some issues and doesn't behave the same way as the Windows' GDI+ library. However, this is the first time we experience varying results between different versions of .NET frameworks.

As a workaround, you may trim the whitespace, for example with the built-in Trim Text function.

Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

Posted on: 03 Feb 2021 22:40

Full project to test & provoke that bug.

1st link works, 2nd crashes