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

radgrid pdf export header

3 Answers 305 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MBEN
Top achievements
Rank 2
Veteran
MBEN asked on 07 May 2018, 09:09 PM

I want to add a custom header to each page of my pdf export.

My grid code has the following declaration.

1 - I have a left margin of 20px but my header does not align with the rest of the export. How can I add a padding to it.

2 - I also want to add a horizontal rule to each page just above the header. If I add it to the string below it just shows in the left cell and it also breaks my header into two separate pages.

string ExportTitle = "<b>ClientName</b><br />  " + " ReportName";
grid.ExportSettings.Pdf.PageHeader.LeftCell.Text = ExportTitle;
grid.ExportSettings.Pdf.PageHeader.LeftCell.TextAlign = GridPdfPageHeaderFooterCell.CellTextAlign.Left;                grid.ExportSettings.Pdf.PageLeftMargin = Unit.Pixel(20);
grid.ExportSettings.Pdf.PageRightMargin = Unit.Pixel(20);

 

3 Answers, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 08 May 2018, 11:42 AM
Hello,

The RadGrid Export to Pdf & Excel Image Header Code Library Sample seems to fully address the described requirement. Please take a look at the approach from the article and give it a try to see if that is suitable for your scenario and let us know how it goes.

I look forward to having your feedback.

Kind regards,
Attila Antal
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
MBEN
Top achievements
Rank 2
Veteran
answered on 08 May 2018, 09:02 PM

My grid declaration already uses the CommandItemSettings:

<CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" ShowExportToExcelButton="true"
ExportToExcelText="" ExportToPdfText="" ShowExportToPdfButton="true" ShowExportToCsvButton="true" ExportToCsvText="" />
0
Attila Antal
Telerik team
answered on 11 May 2018, 12:27 PM
Hi,

If the CommandItem is in use, you may build your own menu by creating buttons, styling them, etc. Let say, you can make the application show the buttons on the page, but hide them on the exported file. Instead, show the table that you would like to place as the document header.

Example:
<CommandItemTemplate>
    <telerik:RadButton ID="RadButton1" runat="server" Text="PDF" CommandName="ExportToPdf" Visible='<%# (!RadGrid1.IsExporting) %>'></telerik:RadButton>
    <asp:Panel ID="Panel1" runat="server" Visible='<%# (RadGrid1.IsExporting) %>'>
        <table style="width: 100%;" class="myTable">
            <colgroup>
                <col />
                <col />
            </colgroup>
            <tr>
                <th style="text-align:center;">ID</th>
                <th style="text-align:center;">Name</th>
            </tr>
            <tr>
                <td style="text-align:center;">1</td>
                <td style="text-align:center;">Joe Smith</td>
            </tr>
            <tr>
                <td style="text-align:center;">2</td>
                <td style="text-align:center;">John Doe</td>
            </tr>
        </table>
    </asp:Panel>
</CommandItemTemplate>

You can check the results of the above code attached to my response.

I hope this will help.

Kind regards,
Attila Antal
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
MBEN
Top achievements
Rank 2
Veteran
Answers by
Attila Antal
Telerik team
MBEN
Top achievements
Rank 2
Veteran
Share this question
or