Problem with ExportToPDF

29 posts, 0 answers
  1. Paul
    Paul avatar
    15 posts
    Member since:
    Jan 2009

    Posted 28 Feb 2009 Link to this post

    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.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Mar 2009 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paul
    Paul avatar
    15 posts
    Member since:
    Jan 2009

    Posted 06 Mar 2009 Link to this post

    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.
  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 07 Mar 2009 Link to this post

    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.
  6. Le
    Le avatar
    15 posts
    Member since:
    Mar 2009

    Posted 15 May 2009 Link to this post

    Hi,
    I got the same error, when i export to pdf with no record in RadGrid.
    Plz, Help me!!

    Best regards,
    Le
  7. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 15 May 2009 Link to this post

    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.
  8. LiZ0r
    LiZ0r avatar
    30 posts
    Member since:
    Apr 2009

    Posted 17 May 2009 Link to this post

    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
  9. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 18 May 2009 Link to this post

    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.
  10. carrie
    carrie avatar
    1 posts
    Member since:
    Jun 2009

    Posted 25 Jun 2009 Link to this post

    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.

  11. cute gal
    cute gal avatar
    5 posts
    Member since:
    Mar 2010

    Posted 30 Mar 2010 Link to this post

    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> 
     





  12. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 30 Mar 2010 Link to this post

    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.
  13. paul
    paul avatar
    6 posts
    Member since:
    Aug 2012

    Posted 18 Sep 2011 Link to this post

    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
     
  14. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 19 Sep 2011 Link to this post

    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
  15. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 11 Oct 2011 Link to this post

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


  16. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 11 Oct 2011 Link to this post

    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?

  17. paul
    paul avatar
    6 posts
    Member since:
    Aug 2012

    Posted 12 Oct 2011 Link to this post

    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
  18. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 12 Oct 2011 Link to this post

    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
  19. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 12 Oct 2011 Link to this post

    ticket id 472715 submitted
  20. MIS
    MIS avatar
    6 posts
    Member since:
    Dec 2007

    Posted 06 Jan 2012 Link to this post

    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.
  21. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 11 Jan 2012 Link to this post

    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
  22. RvdGrint
    RvdGrint avatar
    112 posts
    Member since:
    May 2011

    Posted 03 Feb 2012 Link to this post

    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
  23. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Feb 2012 Link to this post

    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.
  24. RvdGrint
    RvdGrint avatar
    112 posts
    Member since:
    May 2011

    Posted 03 Feb 2012 Link to this post

    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.
  25. Eva
    Eva avatar
    19 posts
    Member since:
    May 2012

    Posted 26 Nov 2014 in reply to Shinu Link to this post

    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
  26. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 28 Nov 2014 Link to this post

    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.

     
  27. Eva
    Eva avatar
    19 posts
    Member since:
    May 2012

    Posted 28 Nov 2014 in reply to Kostadin Link to this post

    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>
  28. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 03 Dec 2014 Link to this post

    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.

     
  29. Eva
    Eva avatar
    19 posts
    Member since:
    May 2012

    Posted 03 Dec 2014 in reply to Kostadin Link to this post

    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
  30. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 08 Dec 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017