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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

119065 May 7,2015 01:49 PM May 12,2015 08:19 AM ASP.NET MVC (Classic) 5
loading
Tags: PDF
potato
Asked On May 7, 2015 01:49 PM

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.

Abirami Selvan [Syncfusion]
Replied On May 8, 2015 06:36 AM

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.

potato
Replied On May 8, 2015 02:24 PM

This is what I'm looking for. Thanks!

Abirami Selvan [Syncfusion]
Replied On May 11, 2015 12:52 AM

Hi Potato ,

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

Regards,
Abirami.

potato
Replied On May 11, 2015 01:59 PM

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.

Abirami Selvan [Syncfusion]
Replied On May 12, 2015 08:19 AM

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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;