We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Essential PDF - Is it possible to insert HTML into the header of a PDFDocument?

I followed this sample: http://help.syncfusion.com/ug/js/index.html#!Documents/creatingagrid.htm
and want to add an HTML header. Can this be done?

Thanks for looking.

5 Replies

AS Abirami Selvan Syncfusion Team May 8, 2015 10:36 AM UTC

Hi Potato ,

Thank you for using Syncfusion product.
Currently , We don’t have support for adding the html tag into PdfGrid header. So we have created the sample to draw the html tag in header using PdfLightTable and also to add the html tag into pdf document header.
Please refer sample in the below link :
http://www.syncfusion.com/downloads/support/forum/119065/MvcApplication11939157227.zip
Please let us know if you need any further assistance.

Thanks,
Abirami.


UN Unknown Syncfusion Team May 8, 2015 06:24 PM UTC

This is what I'm looking for. Thanks!


AS Abirami Selvan Syncfusion Team May 11, 2015 04:52 AM UTC

Hi Potato ,

Thank you for your update.
Please let us know if you need any further assistance.

Regards,
Abirami.


UN Unknown Syncfusion Team May 11, 2015 05:59 PM UTC

The help was pretty much spot on. The only issue I ran into is that the first page of my document grid overlapped my header. All the other pages were fine.

The solution for me was to move PdfPage page = document.Pages.Add(); so that it comes after setting document.Template.Top = header;.
This meant that I couldn't use page.Graphics.ClientSize.Width. So I changed PdfPageTemplateElement header = new PdfPageTemplateElement(new RectangleF(0, 0, page.Graphics.ClientSize.Width, 100)); to PdfPageTemplateElement header = new PdfPageTemplateElement(new RectangleF(0, 0, document.PageSettings.Width, 100));

If this isn't sound logic or if there is an easier way let me know :P. But hopefully this helps anyone else who has the same issue.


AS Abirami Selvan Syncfusion Team May 12, 2015 12:19 PM UTC

Hi Potato,

We have to draw the grid table according to the header height. We can achieve to draw the grid in bottom of header using paginatebounds in layoutformat.

Please refer the below code snippet :

PdfLayoutFormat format=new PdfLayoutFormat();

format.Layout=PdfLayoutType.Paginate;

format.PaginateBounds = new RectangleF(0, 110, document.PageSettings.Width, document.PageSettings.Height);



//Draw the table

table.Draw(page, new RectangleF(0, 110, document.PageSettings.Width, document.PageSettings.Height), format);


AddHeader(document);


// Save and close the document.
document.Save("Sample.pdf",HttpContext.ApplicationInstance.Response,HttpReadType.Save);

Also we have attached the sample for your reference in below link :
http://www.syncfusion.com/downloads/support/forum/119065/MvcApplication1-2100998301.zip

Please try this and let us know the result, if you still faces any issue please modify the attached sample to reproduce the issue and provide us. So that we can analyze in this to provide you the better solution.

Regards,
Abirami.


Loader.
Up arrow icon