Welcome Guest Search | Active Topics | Sign In | Register

Header do not repeats and the page break is not working Options
Stefan Prodan
Posted: Tuesday, January 17, 2012 8:23:14 AM
Rank: Newbie
Groups: Member

Joined: 8/24/2011
Posts: 6
Hello,

I created a demo and is available at:
http://www.indacoecon.ro/files/4.0/tmp/EOPdfTest.zip

In this demo I try to create a html page with one or more invoices.

The problem is that I have 2 headers per invoice.
First header has to be in the top of invoice and only once rendered.
The second header is on every page and includes the column names for the rows in the invoice.

The first header repeats all the time and the second only once.
How can I make the second header to repeat it self on every new page and the first header to be shown only once?

If I have more than one invoice, the first one will be rendered over the second invoice, even if I use "page-break-after:always;"

Small information about how an invoice has to look:
1) The invoice header has to be only once shown in the top of the first page.
2) The invoice products header has to be present on every page in the top.
3) The invoice has to be rendered on 100% of a page.
4) The invoice footer has to be rendered only once at the end of invoice (not on every page.)

If you look to my code you will see some commented areas with some ideas about how I considered to solve this situation.


Thank you for your help.
Predoni Traian
eo_support
Posted: Tuesday, January 17, 2012 10:12:35 AM
Rank: Administration
Groups: Administration

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

In order to repeat headers, you must use thead element. For example, if you wish to have a product header to repeat on every page, you HTML structure would look like this:

Code: HTML/ASPX
<body>
<table>
    <thead>
        <tr>
            <td>product header</td>
        </tr>
    <thead>
    <tr>
        <td>Everything else</td>
    </tr>
</table>
</body>


Here "everything else" can contain pretty much everything and can span over multiple pages. However the "product header" section will automatically being repeated at the top of every page because it's defined inside a thead section.

Also please download the latest build from our download page (DLL version 3.0.104.2). That version fixed a number of table header related issues.

Please feel free to let us know if you still have problems.

Thanks!
Stefan Prodan
Posted: Wednesday, January 18, 2012 7:34:09 AM
Rank: Newbie
Groups: Member

Joined: 8/24/2011
Posts: 6
Hello,

I have solved many errors, but I have some bugs and I do not know how to solve them.
I prepared a new test much more simple, and here it is:

www.indacoecon.ro/files/4.0/tmp/EOPdfTest_2.zip

The PDF and HTML result of this test, for 10 documents with 70 lines per document, is:

http://www.indacoecon.ro/files/4.0/tmp/EOPdfTest_2.pdf

http://www.indacoecon.ro/files/4.0/tmp/EOPdfTest_2.html

In all documents the row that suppose to fill the empty space do not fill it.
The footer is not on the bottom of the page.
And the list header is displayed on a new blank page after the document footer.

The html is very simple explained in "invoice_ro2.html":

Code: HTML/ASPX
<table width="100%" style="border:1px solid #000; page-break-after: avoid; page-break-before: always;">
	<tr>
		<td valign="top" height="100">
            First HEADER, this should be only once per document. (Document number: ##docnumber##)
		</td>
	</tr>
</table>

<table height="100%" width="100%" style="border:1px solid #000; page-break-before: avoid; page-break-after: always">
    <thead style="page-break-inside: avoid;">
        <tr>
		    <td valign="top" style="border:1px solid #000;">
                List HEADER, this should be on every top of the list. (Document number: ##docnumber##)
            </td>
        </tr>
    <thead>
    <tbody>
		##prod## --> here you insert the rows dynamic
    </tbody>
	<tr>
		<td valign="top" style="border:1px solid #000;">
		    <!-- Lista -->
			The document footer, this should be only at the end of the document not on every page as a page footer. (Document number: ##docnumber##)
			<!-- L -->
		</td>
	</tr>
</table>



Thank you for your help.
eo_support
Posted: Wednesday, January 18, 2012 2:09:11 PM
Rank: Administration
Groups: Administration

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

We have looked into your test code and the result PDF file. Everything appears to be working correctly. If you still believe something is wrong, please post a picture to demonstrate which part is wrong. Maybe we did not understand your question correctly.

Thanks!
Stefan Prodan
Posted: Thursday, January 19, 2012 6:52:17 AM
Rank: Newbie
Groups: Member

Joined: 8/24/2011
Posts: 6
Hi,

Here is the image I prepared to show you how I want an invoice to look.

http://www.indacoecon.ro/files/4.0/tmp/EOPdfTest_2_error.png

And here is the .pdf file with the error, in case you need to compare them.

http://www.indacoecon.ro/files/4.0/tmp/EOPdfTest_2.pdf

Thank you for your help.
eo_support
Posted: Thursday, January 19, 2012 9:55:54 AM
Rank: Administration
Groups: Administration

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

Thanks for the additional information.

In order to show a footer at the bottom of the page, you need to use page footer instead of table footer. In your case, the text "The document footer, this should be only at the end of the document...." should not be a table footer. If you implement it as a table footer, then it will be always at the bottom of the table. And there is no way for you to insert empty row before the footer to precisely "push it down" to the page bottom.

In order to implement page footer, You can either handle HtmlToPdf.Options.AfterRenderPage to generate page footer while the conversion is in progress (your handler would be called after each page is rendered), or create page footer after the primary conversion is done. It would be something like this:

Code: C#
PdfDocument doc = new PdfDocument();
HtmlToPdfResult result = HtmlToPdf.ConvertHtm(your_html, doc);

foreach (PdfPage page in doc.Pages)
{
    //add page footer here
}


You will most likely need to call the “PDF Creator” interface to generate the footer. You may need to find out the location of certain contents --- for example, to find out the first invoice table spans from page 2 to page 4, so that you would know that you need to create a footer on page 4. You would use the “result” object in the above code to do so. That object allows you to find out the location of each HTML element. So for example, if you named the first invoice table as “table1” when you generate the HTML, then you will be able to use the “result” object to find out the start/end location (page index and y position) of that table and generate your footer accordingly. You would then use that location information to generate your page footer.

The second problem shown in your screenshot (a new list header on a new empty page) is a bug that has already been fixed. That's why we asked you to download the latest build first. Your EOPdfTest_2.zip still uses the old version (3.0.94.2). Once you update to the new version (3.0.104.2), the problem should go away.

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.