radgrid pdf export header

4 posts, 0 answers
  1. MBEN
    MBEN avatar
    203 posts
    Member since:
    Nov 2011

    Posted 07 May 2018 Link to this post

    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);

     

  2. Attila Antal
    Admin
    Attila Antal avatar
    347 posts

    Posted 08 May 2018 Link to this post

    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.
  3. MBEN
    MBEN avatar
    203 posts
    Member since:
    Nov 2011

    Posted 08 May 2018 in reply to Attila Antal Link to this post

    My grid declaration already uses the CommandItemSettings:

    <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" ShowExportToExcelButton="true"
    ExportToExcelText="" ExportToPdfText="" ShowExportToPdfButton="true" ShowExportToCsvButton="true" ExportToCsvText="" />
  4. Attila Antal
    Admin
    Attila Antal avatar
    347 posts

    Posted 11 May 2018 Link to this post

    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.
Back to Top