Welcome Guest Search | Active Topics | Sign In | Register

Different Header dimensions Options
Ami Versteeg
Posted: Wednesday, March 27, 2013 9:35:22 AM
Rank: Newbie
Groups: Member

Joined: 3/27/2013
Posts: 3
Hi, I'm new to HtmltoPdf and am evaluating the product at the moment. So far it goes pretty well and I'm satisfied with my evaluation so far, especially with regard to other solutions. I'm only wondering if it is possible to use different Header heights for different pages.

The situation is the following. I receive a peace of plain Html from an other application which I cannot change. I convert this Html to pdf with HtmlToPdf. I want to present an image in the header of the first page and on the following pages a different image with different size.
eo_support
Posted: Wednesday, March 27, 2013 11:19:18 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Yes. You will need to do it like this:

1. Set HtmlToPdf.Options.StartPosition to positive number to reserve extra space on the top of the first page;
2. Call HtmlToPdf.ConvertHtml/ConvertUrl to convert the main contents WITHOUT using the built-in header/footer feature. So the output after this call does not have any header/footers;
3. Call HtmlToPdf.ConvertHtml again in a loop that loops through all pages to add your header/footer. The code will be something like this:

Code: C#
//Loop through all pages
foreach (PdfPage page in doc.Pages)
{
    //Setting output area to the header/footer area of the page    
    HtmlToPdf.Options.OutputArea = ....
  
    //Add header/footer to the page. Note the second argument is the page
    HtmlToPdf.ConvertHtml(header, page);
}


Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!
Ami Versteeg
Posted: Thursday, March 28, 2013 4:46:13 AM
Rank: Newbie
Groups: Member

Joined: 3/27/2013
Posts: 3
Hi, thanks for the quick response. This works fine. I only used a negative number for HtmlToPdf.Options.StartPosition, because the header of the first page should be smaller than the one on the other pages.
eo_support
Posted: Thursday, March 28, 2013 12:36:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Yes. That makes perfect sense. Please feel free to let us know if you have any other questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.