PDF export: add logo header

8 posts, 0 answers
  1. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 29 Oct 2011 Link to this post

    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.

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 29 Oct 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 29 Oct 2011 Link to this post

    Wow. That was fast.
    Will try it immediately.

    Thanks.
  5. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 29 Oct 2011 Link to this post

    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.
  6. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 29 Oct 2011 Link to this post

    Hello,

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


    Thanks,
    Jayesh Goyani
  7. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 29 Oct 2011 Link to this post

    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.

  8. Rohit
    Rohit avatar
    3 posts
    Member since:
    Sep 2013

    Posted 09 Jan 2014 Link to this post

    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>";
  9. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 09 Jan 2014 Link to this post

    Nice.

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

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017