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

Error exporting to PDF grid herarchy

3 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ricardo A. Atencio T.
Top achievements
Rank 1
Ricardo A. Atencio T. asked on 12 Dec 2009, 05:45 PM
Hello, I have a problem when exporting a radgrid to a PDF.
Queria 2 radgrid export PDF to a spreadsheet, reading the forum found a method where the 2 radgrid inserted in a third radgrid itemtemplate. One of those 2 is inserted radgrid hierarchy (detail).

The deal to export the third radgrid throws me the following error:

System.NullReferenceException: Object reference not set to an instance of an object.
  at Telerik.Web.Apoc.Render.Pdf.Fonts.Type2CIDSubsetFont.get_WArray()
  at Telerik.Web.Apoc.Pdf.PdfFontCreator.CreateCIDFont(String pdfFontID, Font font, CIDFont cidFont)
  at Telerik.Web.Apoc.Pdf.PdfFontCreator.MakeFont(String pdfFontID, Font font)
  at Telerik.Web.Apoc.Pdf.FontSetup.AddToResources(PdfFontCreator fontCreator, PdfResources resources)
  at Telerik.Web.Apoc.Render.Pdf.PdfRenderer.StopRenderer()
  at Telerik.Web.Apoc.StreamRenderer.StopRenderer()
  at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)


This error comes when I have the radgrid with hierarchy, but if not radgrid hierarchy (ie both simple radgrid) I exported to PDF without problems.

I hope can help me.

File .aspx :

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="LiquidaManD2.aspx.vb" Inherits="CuentasXCobrar_LiquidaManD2" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
    <style type="text/css"
 
         .style3 
         { 
             border-style: solid; 
             border-color: inherit; 
             border-width: 1px; 
             font: bold 12px verdana; 
             color: White; 
             background: #6787C0; 
             top: auto; 
             text-align: left; 
             height: 26px; 
             width: 400px; 
         } 
         .style4 
         { 
             border-style: solid; 
             border-color: inherit; 
             border-width: 1px; 
             font: bold 12px verdana; 
             color: White; 
             background: #DDDDDD; 
             top: auto; 
             text-align: left; 
             height: 38px; 
         } 
          
.bot_02  
    background: #D5E6FF;     
    font: bold 11px arial; 
    color: #445C7D; 
    text-decoration: none; 
    text-align:  center; 
        width: 56px; 
    } 
 
 
.fila_Page_Inter { 
    border-style: solid; 
    border-color: inherit; 
    border-width: 1px; 
    font: bold 12px verdana; 
    color: White; 
        background: #609FC9; 
        top: auto;   
    text-align:left; 
 
.texto03 
   background-color: #DDDDDD; 
    color: #6787C0; 
    font: bolder 11px tahoma; 
    text-align: right; 
    padding: 5px; 
    border: 0px; 
         .style1 
         { 
             background-color: #DDDDDD; 
             font: bold 10px verdana; 
             color: #6787C0; 
             text-align: right; 
             margin-bottom: 1px; 
             height: 22px; 
             margin-top: 0px; 
         } 
         .style2 
         { 
             height: 22px; 
         } 
             
 .style2 
        { 
            height: 0px; 
            vertical-align:bottom; 
        } 
         .style5 
         { 
             width: 99px; 
         } 
         .style6 
         { 
             width: 181px; 
         } 
         .style7 
         { 
             width: 118px; 
         } 
         .style8 
         { 
             width: 235px; 
         } 
         .style9 
         { 
             width: 126px; 
         } 
     
.fila_Page_Button { 
    font: bold 12px verdana; 
    color: White; 
    background: #DDDDDD; 
    top: auto;   
    text-align:left; 
    border: solid 1px; /*solid, outset*/ 
 
 
    </style> 
</head> 
<body> 
 
    <form id="form2" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server"
     
     
    </asp:ScriptManager>       
<table width="770" cellspacing="0" cellpadding="0" border="0"
<tr> 
<td> 
<table cellspacing="0" cellpadding="0" border="0"  
        width="100%"
        <tr> 
            <td class = "style3"
                Cuentas por Cobrar</td> 
        </tr> 
        <tr> 
        <td class = "style4" > 
            <asp:Button ID="btnSearch" runat="server" CssClass="bot_02" Text="Buscar"  
                Height="22px" /> 
            <asp:Button ID="btnGrabar" runat="server" CssClass="bot_02" Text="Grabar" /> 
            <asp:Button ID="btnEliminar" runat="server" CssClass="bot_02" Text="Eliminar"  
                Width="56px" /> 
            <asp:Button ID="btnImprimir" runat="server" CssClass="bot_02" Text="Imprimir" /> 
            <asp:Button ID="btnCerrar" runat="server" CssClass="bot_02" Text="Cerrar" /> 
             
        </td> 
        </tr> 
    </table> 
    <table cellspacing="0" cellpadding="0" border="0" width="100%"
    <tr> 
    <td class="fila_Page_Inter"
    
    </td> 
    </tr> 
    </table> 
     
    <table cellspacing="0" cellpadding="0" border="0" width="100%"
    <tr> 
    <td width="50%"
    <table cellpadding="0" cellspacing="0" border="0" width="100%"
    <tr> 
    <td width="20%" class="texto03"
        Edificio: 
    </td> 
    <td width="80%"
     
        &nbsp;</td> 
    </tr> 
     
    <tr> 
    <td width="20%" class="style1"
        Año: 
    </td> 
    <td width="80%" class="style2"
     
        &nbsp;</td> 
    </tr> 
     
    <tr> 
    <td width="20%" class="texto03"
        Mes: 
    </td> 
    <td width="80%"
     
        &nbsp;</td> 
    </tr> 
    </table> 
    </td> 
    <td width="50%"
     
    <table cellpadding="0" cellspacing="0" border="0" width="100%"
    <tr> 
    <td width="20%"
        <asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label> 
        </td> 
    <td width="80%"
     
        &nbsp;</td> 
    </tr> 
     
    <tr> 
    <td width="20%"
        </td> 
    <td width="80%"
     
        </td> 
    </tr> 
    </table> 
     
    </td> 
    </tr> 
    </table> 
     
    <table cellspacing="0" cellpadding="0" width="100%" border="0"
        <tr> 
            <td class="fila_Page_Inter" style="height:20px" colspan="6">Documentos requeridos para el Calculo</td> 
        </tr> 
                 
        <tr><td class="style5">         
            &nbsp;</td> 
            <td class="style6">         
                &nbsp;</td> 
            <td class="style7">         
                &nbsp;</td> 
            <td class="style8">         
                &nbsp;</td> 
            <td class="style9">         
                &nbsp;</td> 
            <td>         
                <telerik:RadNumericTextBox ID="RadNumericTextBox1" Runat="server" BackColor="#C3D5FD"  
                BorderColor="#FF3300" BorderStyle="Solid" ForeColor="#003366" Width="110px"
                <DisabledStyle Font-Bold="True" Font-Size="13pt" HorizontalAlign="Right" /> 
                </telerik:RadNumericTextBox> 
            </td> 
        </tr> 
        <tr> 
        <td align="right" class="fila_Page_Button" style="padding-left:5px;" colspan="6"
            <asp:Button ID="btnLiquidar" runat="server" CssClass="bot_02" Text="Liquidar" /> 
            </td> 
        </tr> 
        <tr> 
        <td class="fila_Page_Inter" style="height:20px;" colspan="6"
        Calculo por Oficina: 
        </td> 
        </tr> 
        <tr> 
         
        <td colspan="6"
     
            &nbsp;</td> 
        </tr> 
    </table> 
 
</td> 
</tr> 
</table> 
     
   <%-- <table cellspacing="0" cellpadding="0" border="0" width="100%"
    <tr> 
    <td class="fila_Page_Inter" style="height:25px"
        Documentos pendientes a Liquidar 
    </td> 
    </tr> 
    <tr> 
    <td class="fila_Page_Button"
         
        <asp:Button ID="btnBuscarDP" runat="server" CssClass="bot_02"  
            Text="Buscar" /> 
        <asp:Button ID="btnSeleccionar" runat="server" CssClass="bot_02"  
            Text="Seleccionar" Width="77px" /> 
        <asp:Button ID="btnCerrarV" runat="server" CssClass="bot_02"  
            Text="Cerrar" /> 
         
    </td> 
    </tr> 
    <tr> 
    <td> 
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"  
            GridLines="None" Skin="WebBlue"
            <MasterTableView> 
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridTemplateColumn UniqueName="TemplateColumn"
                    </telerik:GridTemplateColumn> 
                    <telerik:GridBoundColumn UniqueName="column"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn UniqueName="column1"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn UniqueName="column2"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn UniqueName="column3"
                    </telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
     
    </td> 
    </tr> 
    </table>--%> 
 
<script type="text/javascript"
    function OpenWindow() { 
        var wnd = window.radopen("Default.aspx", null); 
        wnd.setSize(400, 400); 
        wnd.open(); 
    } 
    function OnClientClose(radWindow) 
    { 
        radWindow.Close();  
        //window.location.href = "News.aspx";            
    } 
    function OpenConfirm() { 
        radconfirm('<h3 style=\'color: #333399;\'>Are you sure?</h3>', confirmCallBackFn, 330, 100, null, 'RadConfirm custom title'); 
        return false; 
    } 
    </script> 
    <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server"  
        Skin="Vista" /> 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Vista" > 
    </telerik:RadWindowManager> 
     
    <telerik:RadWindow ID="RadWindow1" runat="server" Top="20" Modal="true" Behavior="Close" 
    ReloadOnShow="true" BackColor="Gray" NavigateUrl="Default.aspx"
    </telerik:RadWindow> 
     
    <telerik:RadGrid ID="RadGrid5" runat="server" GridLines="None"
<MasterTableView> 
    <ItemTemplate> 
  
        <telerik:RadGrid ID="RadGrid6" runat="server"  
            onitemcreated="RadGrid6_ItemCreated" onneeddatasource="RadGrid6_NeedDataSource"
        </telerik:RadGrid> 
        <br /> 
        <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" Skin="WebBlue" onneeddatasource="RadGrid1_NeedDataSource" 
                AutoGenerateColumns="False" style="margin-right: 0px"  
            ondetailtabledatabind="RadGrid1_DetailTableDataBind1"  
            onitemcreated="RadGrid1_ItemCreated"
<MasterTableView AllowPaging="false" DataKeyNames="des_inmueble" ShowFooter="True"
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
    <DetailTables> 
        <telerik:GridTableView runat="server" Name="Detalle"
            <Columns> 
                <telerik:GridBoundColumn DataField="des_servicio" HeaderText="Servicio"  
                    UniqueName="column1"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="suministro" HeaderText="Suministro"  
                    UniqueName="column2"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="total_apagar" HeaderText="Monto Doc."  
                    UniqueName="column3"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="area_ocupada" HeaderText="Área Ocupada (m² )"  
                    UniqueName="column4"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Area_Suministro"  
                    HeaderText="Area Suministro (m² )" UniqueName="column5"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="indice" HeaderText="Indice"  
                    UniqueName="column6"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="monto" HeaderText="Monto Asignado"  
                    UniqueName="column"
                </telerik:GridBoundColumn> 
            </Columns> 
        </telerik:GridTableView> 
    </DetailTables> 
 
<ExpandCollapseColumn Visible="True"
</ExpandCollapseColumn> 
    <Columns> 
        <telerik:GridBoundColumn DataField="cod_inmueble" HeaderText="Cod Inmueble"  
            UniqueName="column1"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="des_inmueble" HeaderText="Inmueble"  
            UniqueName="column2"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="area_ocupada" HeaderText="Area Ocupada por Oficina (m² ) "  
            UniqueName="column3"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="gasto_total" HeaderText="Gasto Total"  
            UniqueName="column4" Aggregate="Sum"
            <FooterStyle BackColor="#C3D5FD" BorderColor="#FF3300" BorderStyle="Solid"  
                Font-Bold="True" Font-Size="12pt" ForeColor="#003366"  
                HorizontalAlign="Right" /> 
            <ItemStyle HorizontalAlign="Right" /> 
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="periodo" HeaderText="Periodo"  
            UniqueName="column" Visible="False"
        </telerik:GridBoundColumn> 
        <telerik:GridTemplateColumn HeaderText="Selec." UniqueName="TemplateColumn"
            <ItemTemplate> 
             
                <asp:CheckBox ID="chkSelec0" runat="server" /> 
                
            </ItemTemplate> 
        </telerik:GridTemplateColumn> 
    </Columns> 
</MasterTableView> 
            </telerik:RadGrid> 
             
    </ItemTemplate> 
</MasterTableView> 
    </telerik:RadGrid>     
    </form> 
    
 
</body> 
</html> 
 

File .aspx.vb :
Imports System 
Imports System.Data 
Imports Telerik.Web.UI 
Imports Inmuebles.InmueblesNegocio 
Imports Inmuebles 
Imports System.Configuration 
Imports System.Web 
Imports System.Web.Security 
Imports System.Web.UI 
Imports System.Web.UI.WebControls 
Imports System.Web.UI.WebControls.WebParts 
Imports System.Web.UI.HtmlControls 
 
Partial Class CuentasXCobrar_LiquidaManD2 
    Inherits UIPageInmuebles 
 
    Protected Sub btnCerrar_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnCerrar.Click 
        Response.Redirect("LiquidaMan.aspx"
    End Sub 
 
    Protected Sub btnImprimir_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnImprimir.Click 
        For Each commandItem In Me.RadGrid5.MasterTableView.GetItems(GridItemType.CommandItem) 
            commandItem.Visible = False 
        Next 
        RadGrid5.ExportSettings.ExportOnlyData = True 
        RadGrid5.ExportSettings.IgnorePaging = False 
        RadGrid5.MasterTableView.HierarchyDefaultExpanded = True 
        RadGrid5.Rebind() 
        RadGrid5.MasterTableView.ExportToPdf() 
    End Sub 
  
    Public Sub RadGrid1_DetailTableDataBind(ByVal source As ObjectByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) 
        Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem) 
        Select Case e.DetailTableView.Name 
            Case "Detalle" 
                Dim oliquidacion As New Liquidacion 
                Dim dt1 As DataTable = oliquidacion.RA_MOSTRAR_LIQUIDACIONXOFICINA_DETALLE(dataItem.GetDataKeyValue("des_inmueble").ToString()) 
                e.DetailTableView.DataSource = dt1 
        End Select 
    End Sub 
 
    Protected Sub RadGrid1_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) 
        TryCast(source, RadGrid).DataSource = Session("Grilla1"
    End Sub 
 
    Protected Sub RadGrid6_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) 
        TryCast(source, RadGrid).DataSource = Session("rgServicios"
    End Sub 
 
    Protected Sub RadGrid5_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid5.NeedDataSource 
        Dim table As New DataTable 
        table.Columns.Add("Prueba??!!!"
        table.Rows.Add(""
        RadGrid5.DataSource = table 
    End Sub 
 
    Protected Sub RadGrid5_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid5.ItemCreated 
        If TypeOf e.Item Is GridDataItem OrElse TypeOf e.Item Is GridHeaderItem Then 
            e.Item.Style("color") = "black" 
            For Each cell As TableCell In e.Item.Cells 
                cell.Style("font-family") = "Calibri" 
                cell.Style("text-align") = "right" 
                cell.Style("vertical-align") = "middle" 
                cell.Style("font-size") = "9px" 
            Next 
        End If 
        Select Case e.Item.ItemType 
            Case GridItemType.Item 
                e.Item.Style("background-color") = "#FFFFFF" 
                Exit Select 
            Case GridItemType.AlternatingItem 
                e.Item.Style("background-color") = "#ECECD8" 
                Exit Select 
            Case GridItemType.Header 
                e.Item.Style("background-color") = "#718CA1" 
                e.Item.Style("color") = "white" 
                Exit Select 
            Case GridItemType.CommandItem 
                e.Item.Style("background-color") = "#ECECD8" 
                Exit Select 
        End Select 
        If TypeOf e.Item Is GridCommandItem Then 
            e.Item.PrepareItemStyle() 
        End If 
    End Sub 
 
    Protected Sub RadGrid6_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) 
        If TypeOf e.Item Is GridDataItem OrElse TypeOf e.Item Is GridHeaderItem Then 
            e.Item.Style("color") = "black" 
            For Each cell As TableCell In e.Item.Cells 
                cell.Style("font-family") = "Calibri" 
                cell.Style("text-align") = "right" 
                cell.Style("vertical-align") = "middle" 
                cell.Style("font-size") = "9px" 
            Next 
        End If 
        Select Case e.Item.ItemType 
            Case GridItemType.Item 
                e.Item.Style("background-color") = "#FFFFFF" 
                Exit Select 
            Case GridItemType.AlternatingItem 
                e.Item.Style("background-color") = "#ECECD8" 
                Exit Select 
            Case GridItemType.Header 
                e.Item.Style("background-color") = "#718CA1" 
                e.Item.Style("color") = "white" 
                Exit Select 
            Case GridItemType.CommandItem 
                e.Item.Style("background-color") = "#ECECD8" 
                Exit Select 
        End Select 
        If TypeOf e.Item Is GridCommandItem Then 
            e.Item.PrepareItemStyle() 
        End If 
    End Sub 
 
 
    Protected Sub RadGrid1_DetailTableDataBind1(ByVal source As ObjectByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) 
        Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem) 
        Select Case e.DetailTableView.Name 
            Case "Detalle" 
                Dim oliquidacion As New Liquidacion 
                Dim dt1 As DataTable = oliquidacion.RA_MOSTRAR_LIQUIDACIONXOFICINA_DETALLE(dataItem.GetDataKeyValue("des_inmueble").ToString()) 
                e.DetailTableView.DataSource = dt1 
        End Select 
    End Sub 
 
    Protected Sub RadGrid1_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) 
        If e.Item.OwnerTableView.Name <> "Detalle" Then 
 
            For Each dataItem As GridDataItem In e.Item.OwnerTableView.Items 
 
                For Each cell As TableCell In e.Item.Cells 
                    cell.Style("font-family") = "Calibri" 
                    cell.Style("text-align") = "right" 
                    cell.Style("vertical-align") = "middle" 
                    cell.Style("font-size") = "9px" 
                Next 
            Next 
        End If 
        If e.Item.OwnerTableView.Name = "Detalle" Then 
            If TypeOf e.Item Is GridDataItem Then 
                For Each cell As TableCell In e.Item.Cells 
                    cell.Style("font-family") = "Calibri" 
                    cell.Style("text-align") = "right" 
                    cell.Style("vertical-align") = "middle" 
                    cell.Style("font-size") = "9px" 
                Next 
            End If 
            If TypeOf e.Item Is GridHeaderItem Then 
                For Each cell As TableCell In e.Item.Cells 
                    cell.Style("font-family") = "Calibri" 
                    cell.Style("text-align") = "right" 
                    cell.Style("font-size") = "9px" 
                    cell.Style("height") = "35px" 
                Next 
            End If 
            If TypeOf e.Item Is GridCommandItem Then 
                e.Item.PrepareItemStyle() 
            End If 
        End If 
        
    End Sub 
End Class 






Thanks

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Dec 2009, 11:49 AM
Hello Ricardo.,

I'm unable to recreate this scenario. Could you please provide a runnable version of your project so I can reproduce the problem locally?

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Anil Nautiyal
Top achievements
Rank 1
answered on 22 Jun 2012, 07:13 AM
Hello
i want to export my radwindow to pdf .please provide some help
0
Daniel
Telerik team
answered on 27 Jun 2012, 07:03 AM
Hello Anil,

RadWindow does not support export to PDF. You could export RadGrid, RadTreeList, RadScheduler or RadEditor only.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Ricardo A. Atencio T.
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Anil Nautiyal
Top achievements
Rank 1
Share this question
or