This is a migrated thread and some comments may be shown as answers.

Invalid characters in data breaks export to pdf

3 Answers 437 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ertan
Top achievements
Rank 1
Ertan asked on 14 Mar 2013, 04:45 PM
Hello,
We are using grid in our project and we are faced to an important issue. There are 3 options to export the data displayed on the grid such as Excel, Pdf, and Word. Excel and Word work just fine both there is a problem with exporting to pdf. When we search the log files we came across that there are invalid characters in the data. But these characters are Ok for office to omit them. I saw a similar question in the forum (this), that solution is not acceptable in our standards and will cause performance issues. The other point is that the solution is only focusing on just specific part of the program. In our case we know one parameter but there will be same or different character at the different part of the program. Here is the exception we caught;
Exception information:
Exception type: GridPdfExportException
Exception message: Invalid XHTML. RadGrid has to render correct XHTML in order to export to PDF.
Parse error:
' ', hexadecimal value 0x1A, is an invalid character. Line 883, position 199.

Do you have a solution for this kind of error?
Thanks,
Ertan

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 19 Mar 2013, 01:55 PM
Hi Ertan,

The most common cause for bad XHTML are symbols like <,>,& that need to be replaced by the correct XHTML entity: & l t ;, & g t ;, & a m p ; respectively.
Note that 0x1a is a restricted character in xml 1.1 and not allowed at all in xml 1.0. It has to be encoded (&#x1a;) to be allowed in a content tag in xml 1.1. You could replace it OnGridExporting event handler.
protected void RadGrid1_GridExporting(object sender, GridExportingArgs e)
    {
        e.ExportOutput = e.ExportOutput.Replace(((char)0x1A).ToString(), "");
    }

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
sln007
Top achievements
Rank 1
answered on 05 Sep 2014, 01:56 PM
Kostadin,

This works well for an export to EXCEL.  Event does not fire for export to PDF (or at least the export to PDF fails vor a bad XHTML character).

I am actively working on finding solution for this.
0
Kostadin
Telerik team
answered on 10 Sep 2014, 06:41 AM
Hello,

There is an additional event which is fired when exporting to PDF. The event is called OnPdfExporting. More information is available at the following help article.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Ertan
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
sln007
Top achievements
Rank 1
Share this question
or