Welcome Guest Search | Active Topics | Sign In | Register

EO.pdf headers and footers Options
Mike
Posted: Wednesday, August 24, 2011 1:17:49 PM
Rank: Member
Groups: Member

Joined: 8/24/2011
Posts: 10
1) Is it possible to only assign the header to a single page, and not every page in the document?

2) I have large header and footer, and if we can get it to only appear on page one, how do I get the content to show between the 2? Right now, if I have a large HTML table for the header, the content meant for under the header is overlapping the header.

I am using HTML2PDF at the moment.

Thanks!

Mike
eo_support
Posted: Wednesday, August 24, 2011 2:20:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi Mike,

You can do large header on the first page very easily, footer will be a little bit more difficult.

To do large header on the first page, you would simply increase HtmlToPdfOptions.StartPosition. For example, if you set StartPosition to 2, then it will start 2 inches below the top line (excluding margins). You can then output your header in the reserved space.

To output header (or any additional content anywhere), you would let the HTML to PDF conversion to convert into a PdfDocument object first, then use the ACM interface (The PDF Creator interface). With ACM interface, you can output anything (text, image, shapes) anywhere on a PdfPage object.

Large footer would be a bit difficult because we currently do not have a parameter for you to specify "reserved space" after the first page. As a result, it works the best if you already know where to insert page break. For example, a lot of reports have a cover page, so where the page break should occur is already known. In that case, you can just use apply the manual paging CSS attribute to insert a page break after the first page so that it does not overlap:

http://doc.essentialobjects.com/library/4/htmltopdf/paging.aspx

If you do not know where to insert manual page break in advance, you can insert some JavaScript code in your page to dynamically figure out where. You would basically walk through all elements and see which element's top position has exceeded the "available height" you set for the first page. Once you found the first element, dynamically apply a "page-break-before:always" to it. We will run all your JavaScript code when we convert. You can also "tell us" that you are done with such adjustment so that we won't start before you are done:

http://doc.essentialobjects.com/library/4/htmltopdf/eo_js.aspx

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

Thanks!
Mike
Posted: Wednesday, August 24, 2011 3:54:39 PM
Rank: Member
Groups: Member

Joined: 8/24/2011
Posts: 10
The header on the page also fluctuates in size. On the page, both header and footer can vary in size, with the main chink of the data split between whatever space is left on page 1, and the remainder of the pages.

We have a couple of work arounds, but I figured having the top and bottom chunks being header and footer, and the rest can snap in as best it can. My javascript is not quite strong enough to know how to do what you suggested, or how that translates when the PDF is generated.

Mike
eo_support
Posted: Wednesday, August 24, 2011 4:07:15 PM
Rank: Administration
Groups: Administration

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

It's OK even if the header fluctuates in size. In that case you would just do two conversions in a row. The first conversion would be for the header. The second conversion would be for the rest of your document. Before the first and second conversion, you would call HtmlToPdfOptions.Follow(previous_result). This is the key to make the second conversion immediately follow the first conversion. The final code would be something like this:

Code: C#
//Create a new PdfDocument object
PdfDocument doc = new PdfDocument();

//This conversion outputs the header. You may need to adjust
//HtmlToPdf.Options.OutputArea to position the header
//correctly. The default OutputArea reserves a 1 inch margins
//on all sides
HtmlToPdfResult result = HtmlToPdf.ConvertHtml("your_header_html", doc);

//This is the key to let the second conversion continues from
//exactly where the first conversion ends. This call adjust
//HtmlToPdf.Options.StartPosition to point to where the previous
//conversion ends
HtmlToPdf.Options.Follow(result);

//Perform your second conversion. You can either use ConvertHtml
//or ConvertUrl. The output will follow the previous output. If you wish
//to reserve more space, increase HtmlToPdf.Options.StartPosition
HtmlToPdf.ConvertHtml("your_main_content_html", doc);

The footer would not be as easy if you are not familiar with JavaScript. So you may want to avoid the idea of having a huge footer only on the first page. If you can describe what your original scenario is, we may be able to come up a different workaround for you.

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.