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

Export To PDF gives blank pdf

7 Answers 372 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anumeha
Top achievements
Rank 1
Anumeha asked on 31 Aug 2010, 10:40 PM
I have a grid with grouping and scrolling enabled.
When I do an export it gives me a blank pdf file.

Below is my grid declaration.
Please let me know what I am missing.
<telerik:RadGrid ID="RadGridCalendar" runat="server" GridLines="None" AllowPaging="true" 
                           PageSize="20" AllowFilteringByColumn="true" Width="980px" ShowHeader="true" OnColumnCreated="RadGridCalendar_ColumnCreated"
                           OnItemCreated="RadGridCalendar_ItemCreated" OnItemDataBound="RadGridCalendar_ItemDataBound"
                           OnPreRender="RadGridCalendar_PreRender" AutoGenerateColumns="False" EnableLinqExpressions="false"
                           ShowGroupPanel="false" OnItemCommand="RadGridCalendar_ItemCommand" AllowSorting="false"
                           AllowCustomPaging="false" OnNeedDataSource="RadGridCalendar_NeedDataSource">
                           <ClientSettings Resizing-AllowColumnResize="true" >
                               <ClientEvents OnGridCreated="GridCreated" />
                               <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="450px" />
                           </ClientSettings>
                           <ExportSettings IgnorePaging="false"  OpenInNewWindow="true" ExportOnlyData="false"
                               FileName="CalendarExport">
                               <Pdf AllowAdd="false" AllowCopy="true" AllowModify="true" AllowPrinting="true" Author="Anonymous"
                                   Keywords="None" PageBottomMargin="1in" PageLeftMargin="1in" PageRightMargin="1in"
                                   PageWidth="297mm" PageHeight="210mm" PageTopMargin="1in" PageTitle="Calendar"
                                   Subject="Calendar Export" Title="Calendar" />
                           </ExportSettings>
                           <MasterTableView TableLayout="Fixed" HierarchyDefaultExpanded="true" ClientDataKeyNames="ActivityID" UseAllDataFields="true"
                               Width="100%" CommandItemDisplay="Top" DataKeyNames="ActivityID">
                               <GroupByExpressions>
                                   <telerik:GridGroupByExpression>
                                       <SelectFields>
                                           <telerik:GridGroupByField FieldName="ToDoType" HeaderText=" " HeaderValueSeparator=""
                                               FormatString="{0}" SortOrder="Ascending"></telerik:GridGroupByField>
                                       </SelectFields>
                                       <GroupByFields>
                                           <telerik:GridGroupByField FieldName="ToDoType"></telerik:GridGroupByField>
                                       </GroupByFields>
                                   </telerik:GridGroupByExpression>
                                   <telerik:GridGroupByExpression>
                                       <SelectFields>
                                           <telerik:GridGroupByField FieldName="ActivityDate"></telerik:GridGroupByField>
                                       </SelectFields>
                                       <GroupByFields>
                                           <telerik:GridGroupByField FieldName="Date" FormatString="{0:d}" SortOrder="Descending">
                                           </telerik:GridGroupByField>
                                           <telerik:GridGroupByField FieldName="ActivityDate" FormatString="{0:D}" SortOrder="None">
                                           </telerik:GridGroupByField>
                                       </GroupByFields>
                                   </telerik:GridGroupByExpression>
                               </GroupByExpressions>
                               <Columns>
                                   <telerik:GridTemplateColumn UniqueName="DateColumn" HeaderText="Date">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="72px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="TimeColumn" HeaderText="Time">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="125px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div>
                                               <%# DataBinder.Eval(Container.DataItem, "StartTime") %>
                                               <asp:Label ID="Label1" runat="server" Visible='<%# !Convert.IsDBNull(Eval("EndTime")) %>'>-</asp:Label>
                                               <%# DataBinder.Eval(Container.DataItem, "EndTime") %>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Subject" HeaderText="Subject">
                                       <ItemStyle BorderStyle="None" HorizontalAlign="Left"></ItemStyle>
                                       <HeaderStyle Width="250px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div style="text-align:left ;">
                                               <asp:LinkButton ID="LinkButtonActivity" runat="server" ForeColor="#73abc9" Font-Size="9pt"
                                                   CommandName="ShowActivity" Font-Bold="true">
                                               <%# Eval("Subject")%></asp:LinkButton>
                                               <asp:Label ID="LabelSubject" runat="server" CssClass="label" Width="1px" Visible="false"><%# Eval("Subject")%></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Location" HeaderText="Location">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="125px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelLocation" runat="server" Text='<%# Eval("Location")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                     
                                   <telerik:GridTemplateColumn UniqueName="DueDate" HeaderText="Due Date"  Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelDueDate" runat="server" Text='<%# Eval("DueDate")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Contact" HeaderText="Contact">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="125px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div>
                                               <asp:Label ID="LabelContact" runat="server" Text='<%# Eval("Contact")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Description" HeaderText="Description">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="175px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelDescription" runat="server" Text='<%# Eval("Description")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="ActivityStatus" HeaderText="Status" Visible="false"
                                       DataField="ActivityStatus" AllowFiltering="true">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelStatus" runat="server" Text='<%# Eval("ActivityStatus")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="ActivityType" HeaderText="Type" Visible="false"
                                       AllowFiltering="true" DataField="ActivityType">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelType" runat="server" Text='<%# Eval("ActivityType")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="ActivitySubType" HeaderText="Sub-Type" Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelSubType" runat="server" Text='<%# Eval("ActivitySubType")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Keywords" HeaderText="Keywords" Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div>
                                               <asp:Label ID="LabelKeyword" runat="server" Text='<%# Eval("Keyword")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Priority" HeaderText="Priority" Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelPriority" runat="server" Text='<%# Eval("Priority")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Company" HeaderText="Company" Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelEmployer" runat="server" Text='<%# Eval("Employer")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Phone" HeaderText="Phone" Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelPhone" runat="server" Text='<%# Eval("Phone")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="Participants" HeaderText="Participants"  Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelParticipants" runat="server" Text='<%# Eval("Participants")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="TimeSpent" HeaderText="TimeSpent" Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelTimeSpent" runat="server" Text='<%# Eval("TimeSpent")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="PercentComplete" HeaderText="% Complete"
                                       Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div>
                                               <asp:Label ID="LabelPercentComplete" runat="server" Text='<%# Eval("PercentComplete")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridTemplateColumn UniqueName="SmartPadNote" HeaderText="Latest SmartPad Note"
                                       Visible="false">
                                       <ItemStyle BorderStyle="None"></ItemStyle>
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemTemplate>
                                           <div >
                                               <asp:Label ID="LabelSmartPadNote" runat="server" Text='<%# Eval("LatestSmartPadNote")%>'></asp:Label>
                                           </div>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                   <telerik:GridBoundColumn DataField="ActivityID" Visible="false" UniqueName="ActivityID">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridDateTimeColumn DataField="Date" AllowFiltering="true" Visible="false"
                                       DataFormatString="{0:MM/dd/yyyy}" UniqueName="Date">
                                   </telerik:GridDateTimeColumn>
                                   <%-- <telerik:GridBoundColumn DataField="ActivityStatus" AllowFiltering="true" Visible="false"
                                   UniqueName="Status">
                               </telerik:GridBoundColumn>--%>
                                   <telerik:GridBoundColumn DataField="ActivityParticipant" AllowFiltering="true" Visible="false"
                                       UniqueName="ActivityParticipant">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn DataField="ActivityParticipantPrimary" AllowFiltering="true"
                                       Visible="false" UniqueName="ActivityParticipantPrimary">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn DataField="PrimaryParticipant" Visible="false" UniqueName="PrimaryParticipant">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn DataField="ActivityParticipantCreatedBy" Visible="false"
                                       UniqueName="CreatedBy">
                                   </telerik:GridBoundColumn>
                               </Columns>
                               <HeaderStyle Width="100px" />
                               <CommandItemTemplate>                                
                                   <asp:ImageButton ID="ImageButtonAdd" runat="server" ImageUrl="~/App_Themes/MLightning/Layout/plus-icon.png"
                                       AlternateText="Add" PostBackUrl="~/Calendar/CalendarActivityAddSettings.aspx" /> 
                                   <asp:LinkButton ID="LinkButtonExportCalendar" runat="server" CommandName="ExportToPdf" CausesValidation="false" >
                                   <img style="border:0px;vertical-align:middle;" alt="" src="../App_Themes/MLightning/Layout/Reader.gif" />
                                   <span class="printTop" > Export</span>
                                   </asp:LinkButton>  
                               </CommandItemTemplate>
                                 
                               <PagerStyle Position="TopAndBottom" PrevPageText="Prev" NextPageText="Next" Mode="NextPrev" />
                           </MasterTableView>
                       </telerik:RadGrid>

7 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 01 Sep 2010, 01:09 PM
Hello Anumeha,

As mentioned in the documentation, you should disable the Scrolling/StaticHeaders functionality before export.
PDF export

Regards,
Daniel
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
Anumeha
Top achievements
Rank 1
answered on 01 Sep 2010, 08:17 PM
I disabled the scrolling and static headers in my ItemCommand event but it still gives me a blank page.
Any ideas?
0
Daniel
Telerik team
answered on 02 Sep 2010, 09:59 PM
Hello Anumeha,

I can think of two cases where you could receive a blank PDF file:
1) if opening the file in Apple Preview
2) if the StaticHeaders/Scrolling are enabled

Please submit a runnable demo if the problem still persists.

Regards,
Daniel
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
Anumeha
Top achievements
Rank 1
answered on 08 Sep 2010, 09:38 PM
I submitted a support ticket with a runnable demo.
However, I was playing a little bit more with the grid and I noticed that when I set Ignorepaging="true" in the export settings I am able to get the data back.

However, I am not able to fit in all the columns on my grid in the pdf. My grid has about 20 columns and it just shows me the first 5-6 columns on the pdf.

How can i fit in all the columns.
0
Daniel
Telerik team
answered on 08 Sep 2010, 09:51 PM
Hello Anumeha,

There are different ways you could fit the columns:
  • switch the orientation to landscape
  • reduce the font size
  • use narrower fonts
  • decrease the page margins
  • increase the page size
PDF export

Best regards,
Daniel
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
Anumeha
Top achievements
Rank 1
answered on 08 Sep 2010, 10:10 PM
Thanks Daniel.
 
I changed the mode to landscape and it fits the columns now. Howevere, there are some columns which seem to be really wide for the data they contain. I want to decrease the width of those columns so that the other columns can fit in better and the pdf is more readable.

0
Daniel
Telerik team
answered on 10 Sep 2010, 09:25 PM
Hello Anumeha,

You can simply set the HeaderStyle-Width to the desired columns:
protected void Button1_Click(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.GetColumn("CategoryID").HeaderStyle.Width = Unit.Pixel(50);
    RadGrid1.MasterTableView.ExportToPdf();
}

Regards,
Daniel
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
Tags
Grid
Asked by
Anumeha
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Anumeha
Top achievements
Rank 1
Share this question
or