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

Problem with ExportToPDF

28 Answers 380 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 01 Mar 2009, 04:32 AM
I have a simple grid and trying to export to PDF with AllowPaging. Whenever I try to export, I get an error that says "System.InvalidCastException: Unable to cast object of type 'Telerik.Web.Apoc.Layout.BlockArea' to type 'Telerik.Web.Apoc.Layout.AreaContainer'."  I looked through the code and whenever I set IgnorePaging to true, I get this error. If I set it to false, it works fine but, I don't get full data.  I use ObjectDataSource for connection to the grid.

28 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2009, 06:27 AM
Hi Paul,

I am not exactly sure about this issue. But can you check whether you have set the Width/Height of the Grid anywhere in percentage? If so try setting the widtth/height in pixels and see whether the error is getting removed.

Shinu
0
Paul
Top achievements
Rank 1
answered on 06 Mar 2009, 08:42 PM
I use ObjectDataSource and it turns out that the grid won't pull any data when I set it ignorePaging. Since it was returning 0 records, it was causing that error when exporting to PDF. It is a bit odd that it fails when there is no record to export instead of exporting with 0 records.
0
Sebastian
Telerik team
answered on 07 Mar 2009, 07:54 AM

Hello Paul,

Is it possible that you enabled custom paging for your grid when using ObjectDataSource item generator as shown in this demo? If so, verify that you set the page size of the grid to match its VirtualItemCount value as explained in the bottom section of the following help topic:

http://www.telerik.com/help/aspnet-ajax/grdexport.html

Kind regards,

Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Le
Top achievements
Rank 1
answered on 15 May 2009, 07:08 AM
Hi,
I got the same error, when i export to pdf with no record in RadGrid.
Plz, Help me!!

Best regards,
Le
0
Sebastian
Telerik team
answered on 15 May 2009, 07:50 AM
Hello Le,

Can you please verify that you are using the latest version 2009.1.402 of RadControls for ASP.NET AJAX in your project? Similar issue has been reported before and it should be addressed in the latest release of the suite. Upgrade instructions can be found here.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
LiZ0r
Top achievements
Rank 1
answered on 17 May 2009, 11:52 PM
Hi Sebastian,

I am using the latest version 2009.1.402 and my Radgrid is set into pixels and and not percentages and I am still receiving the error.
I've taken a look at this thread:
http://www.telerik.com/community/forums/aspnet-ajax/grid/working-with-exporttopdf.aspx

But I don't really understand it, if anyone can, can they explain it to me, might be because the decription is in VB and I am working with C#
Any help would be appreciated!

Regards,
Lily
0
Sebastian
Telerik team
answered on 18 May 2009, 08:49 AM
Hello LiZ0r,

In order to provide up-to-the-point answer for your case, I will request that you assemble a stripped working version of your project, exhibiting the erroneous behavior, and send it enclosed to a regular support ticket. We will test/debug it locally and will get around to you with your findings.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
carrie
Top achievements
Rank 1
answered on 25 Jun 2009, 02:24 PM

After receiving this error intermittantly, I reviewed the html being exported from the grid and found that if I had a <DIV> tag with the width style set:

<div id="ctl00_ContentPlaceHolder1_panelAccidentListing" style="width: 100%">  

I would receive the error:

System.InvalidCastException: Unable to cast object of type 'Telerik.Apoc.Layout.BlockArea' to type 'Telerik.Apoc.Layout.AreaContainer'.
  at Telerik.Apoc.Fo.Flow.BlockContainer.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
  at Telerik.Apoc.Fo.Flow.Flow.Layout(Area area)
  at Telerik.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
  at Telerik.Apoc.StreamRenderer.Render(PageSequence pageSequence)
  at Telerik.Apoc.Fo.FOTreeBuilder.EndElement()
  at Telerik.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Removing width solved our problem.

0
cute gal
Top achievements
Rank 1
answered on 30 Mar 2010, 09:47 AM
hi all.... evn m getting errors exporting gridcontents to pdf
System.InvalidCastException: Unable to cast object of type 'Telerik.Web.Apoc.Layout.BlockArea' to type 'Telerik.Web.Apoc.Layout.AreaContainer'. 
  at Telerik.Web.Apoc.Fo.Flow.BlockContainer.Layout(Area area) 
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area) 
  at Telerik.Web.Apoc.Fo.Flow.TableCell.Layout(Area area) 
  at Telerik.Web.Apoc.Fo.Flow.TableRow.Layout(Area area) 
  at Telerik.Web.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area) 
  at Telerik.Web.Apoc.Fo.Flow.Table.Layout(Area area) 
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area) 
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region) 
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area) 
  at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree) 
  at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence) 
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement() 
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)  
 

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> 
    <telerik:RadGrid ID="RadGrid1" ShowGroupPanel="true" DataSourceID="source1" AllowPaging="True" 
        runat="server" AllowSorting="True" ShowHeader ="false"  AllowFilteringByColumn="true"
        <ExportSettings IgnorePaging="true" OpenInNewWindow="true"
            <Pdf PageHeight="300mm" PageWidth="300mm" PageTitle="Catalogue" /> 
        </ExportSettings> 
        <PagerStyle Mode="NextPrevAndNumeric" /> 
        <MasterTableView CommandItemDisplay="Top" DataKeyNames="ProductId"
            <CommandItemTemplate> 
                <asp:Button ID="DownloadPDF" Visible="true" runat="server" Width="100%" CommandName="ExportToPdf" /> 
            </CommandItemTemplate> 
            <ItemTemplate> 
                <table> 
                    <tr> 
                        <td> 
                            <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" AutoAdjustImageControlSize="false" 
                                DataValue='<%#Eval("PictureBinary") %>' Height="200px" Width="170px" /> 
                        </td> 
                        <td> 
                            <div> 
                                <span style="font-weight: bold; font-family: Arial Black;">Name:</span> 
                                <%#Eval("ProductName")%> 
                                <br /> 
                                <br /> 
                                <span style="font-weight: bold; font-family: Arial Black;">Price:</span> 
                                <%#Eval("Cost", "{0:C2}")%> 
                                <br /> 
                                <br /> 
                                <span style="font-weight: bold;">Quantity:</span> 
                                <%#Eval("Stock") & " available"%> 
                                <br /> 
                                <br /> 
                                <span style="font-weight: bold;">Rate:</span> 
                                <telerik:RadRating ID="RadRating1" runat="server" ItemCount="5" Value='<%#Eval("RatingSum")%>' 
                                    Skin="Hay" ReadOnly="true" /> 
                                <br /> 
                                <br /> 
                                <span style="font-weight: bold;">Description:</span> 
                                <%#Eval("ShortDesc")%> 
                            </div> 
                        </td> 
                    </tr> 
                </table> 
            </ItemTemplate> 
        </MasterTableView> 
        <ClientSettings AllowDragToGroup="true"
            <Scrolling AllowScroll="true" UseStaticHeaders="true" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
    <asp:SqlDataSource ID="source1" runat="server" SelectCommand="select Product.*, Picture.* 
                        from Product, Category, SubCategory, Product_Category_Mapping, Picture 
                        where ProductProduct_Category_Mapping.ProductId=Product.ProductId and Product_Category_Mapping.CategoryId=Category.CategoryId and Product_Category_Mapping.SubCategoryId=SubCategory.SubCategoryId and Picture.PictureId in (select top 1 PictureId from Picture as pp where pp.ProductId=Product.ProductId )" 
        ConnectionString="<%$ ConnectionStrings:sshopConnectionString %>"></asp:SqlDataSource> 
</asp:Content> 
 





0
Sebastian
Telerik team
answered on 30 Mar 2010, 01:35 PM
Hello cute gal,

Please examine the information from the relevant bullet  in the 'Exceptions' paragraph of this documentation article.

Best regards,
Sebastian
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
paul
Top achievements
Rank 1
answered on 18 Sep 2011, 09:26 AM
Hi Sebastian,
I am not sure if this thread is closed but i got the same error as cute gal when i tried to export a radgrid to PDF.
I am using template grid as shown in her example with no nested div's. My table is setting inline widths but i tried removing them and exporting and still no difference.
Most forums suggest to remove the widths of the div's to get it to work but that does not seem to help.
Also it makes little sense to change the style of my grid to get this functionality working.

Is this a known issue with radgrid that has not been solved yet?

Any help would be greatly appreciated.
Kind Regards,
Paul
 
0
Sebastian
Telerik team
answered on 19 Sep 2011, 09:49 AM
Hello Paul,

Can you post your grid markup in this forum post to investigate this case further? I presume that you already took into account the info provided in the help topic. 

Also specify the version of our ASP.NET AJAX controls you are using (the most recent available is 2011.2.915).
 
Best regards,
Sebastian
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
0
Eric Krauska
Top achievements
Rank 1
answered on 11 Oct 2011, 04:11 PM
I would like to add to this thread that I have been fighting this error and finally discovered that if I have
AllowFilteringByColumn="true"

on my RadGrid that I will receive the error in this thread.  As soon as I set it to False I can receive a pdf export. 

I'm still searching on a way to fix this issue, but this could be the issue everyone else is experiencing...


0
Eric Krauska
Top achievements
Rank 1
answered on 11 Oct 2011, 04:20 PM

I have more to offer on this.  Ends up it was my GridDateTimeColumn causing the error.

<telerik:GridDateTimeColumn AllowFiltering="true" DataFormatString="{0: MM/dd/yyyy}" DataField="ExpirationDate" HeaderText="Expires Date" SortExpression="ExpirationDate" UniqueName="ExpirationDate"></telerik:GridDateTimeColumn>

With AllowFiltering="true", I get the error every time.  When I set it to "false", I can export to pdf.  So, it appears you can't have filtering on a datetimecolumn when you want to export to pdf.

Can telerik confirm this and let me know if this is by design or an issue?

0
paul
Top achievements
Rank 1
answered on 12 Oct 2011, 05:54 AM
Hi Eric,
It could be how you described it as even I had a GridDateTimeColumn that was allowed to be filtered. I did not go through finding a solution for this since time did not allow it and I had to  come up with a solution quickly. I used 'itextsharp' to create a custom pdf file as the clients wanted.

It would be great if someone from Telerik could confirm if this was the issue though.

Kind Regards
Paul
0
Sebastian
Telerik team
answered on 12 Oct 2011, 09:13 AM
Hello Eric/Paul,

I tried to reproduce the issue using GridDateTimeColumn and enabling filtering for the grid (with v2011.2.915 of our AJAX controls) but unfortunately to no avail.

If you can replicate the abnormality, please submit a stripped down working version of your project that illustrates it in a standard support ticket. Thus we will investigate the case further and provide an appropriate answer/fix.

Kind regards,
Sebastian
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
Eric Krauska
Top achievements
Rank 1
answered on 12 Oct 2011, 01:40 PM
ticket id 472715 submitted
0
MIS
Top achievements
Rank 1
answered on 06 Jan 2012, 09:13 PM
Is there any status update on this ticket?  I need to have AllowFiltering turned on for the gridDateTimeColumn that I am trying to export to pdf.
0
Daniel
Telerik team
answered on 11 Jan 2012, 08:40 AM
Hello Sid,

There are two ways to sidestep the problem:
- set ExportOnlyData to true
-
turn off filtering before exporting (in the export button handler or in the ItemCommand handler if using the built-in export buttons)

Note that both of the solutions are completely safe and won't affect your application as they will be applied to the exported file only.

Regards,
Daniel
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
RvdGrint
Top achievements
Rank 1
answered on 03 Feb 2012, 10:05 AM
Daniel,

In the ItemCommand I catch the EpxortToPDF command and set EpxortOnlyData to true and diabled filtering by setting AllowFilterByColumn on the grid to false. But still I receive the following error:

Server Error in '/' Application.
--------------------------------------------------------------------------------
 
System.InvalidCastException: Unable to cast object of type 'Telerik.Web.Apoc.Layout.BlockArea' to type 'Telerik.Web.Apoc.Layout.AreaContainer'.
  at Telerik.Web.Apoc.Fo.Flow.BlockContainer.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableCell.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.TableRow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.AbstractTableBody.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Table.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
  at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
  at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
  at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)

Regards,
  Jos
0
Shinu
Top achievements
Rank 2
answered on 03 Feb 2012, 10:26 AM
Hello,

This issue arises when you have DIV element with specified dimensions or absolute positioning. Check the following help documentation which explains more about this.
PDF export.

-Shinu.
0
RvdGrint
Top achievements
Rank 1
answered on 03 Feb 2012, 11:25 AM
Shinu,

I removed all height, width and positioning properties of the div's around the grid without any results.

The problem occured when I moved my CommandItems from the CommandItemTemplate to the PagerTemplate. Now I changed it and moved my PagerItems from the PagerTemplate to the CommandItemTemplate and now both, PDF export  and paging are working.

Regards,
  Jos.
0
Eva
Top achievements
Rank 1
answered on 26 Nov 2014, 08:54 AM
Dear Shinu,
i came accross the same problem because i am trying to export a custom Html Table under Radgrid. I used divs for this but then i got the error. do you have anything else in mind that could help me to export an Html Table under Radgrid.

Thanks in advance,
Eva Xanthou
‚Äč
0
Kostadin
Telerik team
answered on 28 Nov 2014, 11:40 AM
Hello Eva,

Could you please sent the custom html which you are trying to export? This way I will test it on my end and if I am able to replicate the issue I would provide you with a solution for your case.

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.

 
0
Eva
Top achievements
Rank 1
answered on 28 Nov 2014, 12:22 PM
something like the code below:


<div style='display: table; width:100%'>
    <div style= 'display: table-caption;text-align:center;font-weight: bold;font-size: larger;width:100%'>
        <p>This is a Table</p>
    </div>
    <div style='display: table-row;font-weight: bold;text-align: center; width:100%'>
        <div style='display: table-cell;width:35%'>
            <p>Heading 1</p>
        </div>
        <div style='display: table-cell;width:30%'>
            <p>Heading 2</p>
        </div>
        <div style='display: table-cell;width:35%'>
            <p>Heading 3</p>
        </div>
    </div>
    <div style='display: table-row;width:100%'>
        <div style='display: table-cell;width:35%'>
            <p>Row 1 Column 1</p>
        </div>
        <div style='display: table-cell;width:30%'>
            <p>Row 1 Column 2</p>
        </div>
        <div style='display: table-cell;width:35%'>
            <p>Row 1 Column 3</p>
        </div>
    </div>
    <div style='display: table-row;width:100%'>
        <div style='display: table-cell;width:35%'>
            <p>Row 2 Column 1</p>
        </div>
        <div style='display: table-cell;width:30%'>
            <p>Row 2 Column 2</p>
        </div>
        <div style='display: table-cell;width:35%'>
            <p>Row 2 Column 3</p>
        </div>
    </div>
</div>
0
Kostadin
Telerik team
answered on 03 Dec 2014, 09:12 AM
Hello Eva,

Note that you can not use a percentage to set the width of the table and the cells. You need to set width in pixels or another absolute units. Please examine the Exporting HTML tables from the following help article from more information.

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.

 
0
Eva
Top achievements
Rank 1
answered on 03 Dec 2014, 10:24 AM
Dear Kostadin,

Thanks for your response. it helped me a lot.

i have another problem. when i write something in a td with greek characters when i export this i get "######"
do you have any idea????

thanks in advance,
Eva
0
Kostadin
Telerik team
answered on 08 Dec 2014, 08:11 AM
Hi Eva,

Please try setting a Unicode font which supports international characters such as Arial Unicode MS. I would recommend you to examine the Fonts / Unicode support section of the following help article for more information.

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
Paul
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Paul
Top achievements
Rank 1
Sebastian
Telerik team
Le
Top achievements
Rank 1
LiZ0r
Top achievements
Rank 1
carrie
Top achievements
Rank 1
cute gal
Top achievements
Rank 1
paul
Top achievements
Rank 1
Eric Krauska
Top achievements
Rank 1
MIS
Top achievements
Rank 1
Daniel
Telerik team
RvdGrint
Top achievements
Rank 1
Eva
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or