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

PDF export: add logo header

7 Answers 361 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chanan Zass
Top achievements
Rank 1
Chanan Zass asked on 29 Oct 2011, 08:54 AM
Greetings,

I understand RadGrid does not offer the possibility of exporting to a PDF template.
We'd like to add a logo (image) and certain other elements (such as Title, Sub-Title, Page count, etc.) to the header of each PDF page.

Is there a way to create a sort of Header Template during export?

Any suggestion would be most apprecicated.

7 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 29 Oct 2011, 09:26 AM
Hello,

protected void RadGrid1_PdfExporting(object sender, GridPdfExportingArgs e)
    {
        string strHeader= "<div width=\"100%\" style=\"text-align:center;font-size:12px;font-family:Verdana;\">HEADER</div>";
        string strFooter= "<div width=\"100%\" style=\"text-align:center;font-size:12px;font-family:Verdana;\">Footer</div>";
        e.RawHTML = strHeader + e.RawHTML + strFooter;     
    }

for image :  "<div><img url=''></div>";

Thanks,
Jayesh Goyani
0
Chanan Zass
Top achievements
Rank 1
answered on 29 Oct 2011, 09:51 AM
Wow. That was fast.
Will try it immediately.

Thanks.
0
Chanan Zass
Top achievements
Rank 1
answered on 29 Oct 2011, 10:08 AM
Thanks much. That works for a single-page document.
What would I have to do to have the header on each page?

Hope this is possible.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 29 Oct 2011, 10:47 AM
Hello,

<ExportSettings>
                <Pdf PageTitle="pagetitle" Title="reporttitle" />
            </ExportSettings>


Thanks,
Jayesh Goyani
0
Chanan Zass
Top achievements
Rank 1
answered on 29 Oct 2011, 11:17 AM
Thanks.
I was aware of this PageTitle setting, but this would not allow me to include a logo (or any additional HTML element) on each page (any html tags inserted in PageTitle are ignored during rendering).

Guess we'll have to create PDF documents in a different way (ABCpdf probably).

Thanks.

0
Rohit
Top achievements
Rank 1
answered on 09 Jan 2014, 09:48 AM
You can use html codes in your page header text.

rgList.ExportSettings.Pdf.PageHeader.LeftCell.Text = "<img src='smiley.gif' alt='Smiley face' width='42'>";
rgList.ExportSettings.Pdf.PageHeader.MiddleCell.Text = " <h3> Heading </h3>";
rgList.ExportSettings.Pdf.PageHeader.MiddleCell.TextAlign = GridPdfPageHeaderFooterCell.CellTextAlign.Center;
rgList.ExportSettings.Pdf.PageHeader.RightCell.Text = "<a href='http://www.w3schools.com'>Visit W3Schools.com!</a>";
0
Chanan Zass
Top achievements
Rank 1
answered on 09 Jan 2014, 10:22 AM

Nice.

We'll remember this the next time we need to customize PDF export template.

Tags
Grid
Asked by
Chanan Zass
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Chanan Zass
Top achievements
Rank 1
Rohit
Top achievements
Rank 1
Share this question
or