spipu / html2pdf

OFFICIAL PROJECT | HTML to PDF converter written in PHP
http://html2pdf.fr/en/default
Open Software License 3.0
1.67k stars 748 forks source link

Is possible page_header only in first page and page_footer only in last page? [question] #202

Closed shawe closed 5 years ago

shawe commented 7 years ago

I'm trying to do that, but seems that I only can hide page_header or page_footer if I put the array of numbers in tag hideheader/hidefooter, but page_cu or page_nb are indeterminated at this point.

Is posible to anyway to use only page_header on first page, and use only page_footer on last page? I want to use the all extra size on body if I can remove them on unneeded pages because I with this change I can use less pages.

I don't want hide them, because I'm loosing anyway this space, I want only use it on each case.

spipu commented 7 years ago

then, it is not header and footers that you want :) you have jut to put what you want in first for the "header" and what you want at the end for the "footer" :)

shawe commented 7 years ago

But in this case, I need at least 3 pages, an itsn't the case I was describing.

Imagine that you have a list with 10 lines, and header+body+footer have enought space and is putt it all in one page.

But in case that for example you have 20 lines, the first page need the header and all possible lines. In the next page the header is not needed anymore, but the rest of lines and footer need to appear on the end page.

An in the case that are a lot of lines, only the first page have the header, only the last have the footer, and all pages always have lines on it.

Maybe is not typically as expected, but big business prefer this way because safe paper.

This is a sample using Google Docs: https://docs.google.com/document/d/1z7RrzKrInYdC-bTmGrRuwv9MLkskP5OrVe6rlcg7Av8/edit?usp=sharing

Looking that you can understand better because is not enought hide the header or the footer, because isn't the same. And also, is not the same than your solution.

shawe commented 7 years ago

@spipu you closed this issue with leave time to reply and complete this issue.

Can you reopen this issue? There are more people with same type of request looking for a solution on a lot of pages.

spipu commented 7 years ago

no, you do not need 3 pages, just the content of your header, then all your content, then the content of your footer, but without using page_header and page_footer.

because what you want is not page headers and page footers, it juste something to put at the beginning and at the end of your pdf document

shawe commented 7 years ago

First of all, thanks for reopen the issue.

Ok, the header part can be solve with this obvius way for only show it on first page. In this case, how can I put in the same position of the footer on last page? Only using bottom style for example? I must to try it.

And how is supposed to detect for each page his number? If possible I preffer to put different header/footers on pages that aren't the last page, similar to a resume for get some extra lines, without some details.

I found [[page_cu]] and [[page_nb]] for show a pagination, but I can't compare this values with PHP for check by myself and do one thing or another, maybe with JS?.

I create some designs for budgets, orders, delivery notes and invoice, but some people are requiring this features. For a lot of people, isn't important get always footer/header because only print 1 or 2 pages, but for other that are printing more than 10, can save pages, ink and money every day.

For me, HTML2PDF satisfy the primary requisites, is easier than using TCPDF directly, because I don't need to learn something new, is more slow in direct comparison generating the same document, but for now this is not a really problem in comparison of what we get in a lot less time with a lot of less effort.

My intention is to use HTML2PDF like a new easiest way to generate this types of docs, an maybe some others news docs on this project https://github.com/NeoRazorX/facturascripts_2015 that actually we are fully rewritten on https://github.com/NeoRazorX/facturascripts

shawe commented 7 years ago

I tested it now, and yes, without header/footer is a similar result, but without the correct place for the footer.

In my test case, footer appear in last page (without lines in this page, but this is not important, is expected because haven't got enought space), but is placed at top, and it must appear at footer zone, at least at bottom of the page, but maybe this isn't enought.

spipu commented 7 years ago

You can use the end_last_page tag.

Look at examples

shawe commented 7 years ago

@spipu thanks for point me to https://github.com/spipu/html2pdf/blob/master/examples/res/exemple05.php

I must try it, maybe this can solve it ;)

shawe commented 7 years ago

@spipu seems to be solved all my problems, I try to do one more thing, and link to my results for example.

shawe commented 7 years ago

@spipu thanks for your help, and for maintain this issue open.

Thanks to your help, I have this template with option for some customization by the user.

Demo result

Base font size, rounded borders, ratio rounded border, width border, border color, even row background color, table header background/text color, and some other options for hide/show some column info of the main table (reference, discount, number line, observation, EAN code/EAN barcode, previous document info).

sivanagak commented 6 years ago

I don't want to repeat page_header in my lastpage of pdf if it is morethen one page, is it possible?

shawe commented 6 years ago

@sivanagak yes it's possible, do you see my demo result? Thanks to spipu to reopen this thread I can generate the PDF like this.

This is another alternative based on same idea https://www.mifactura.eu/plugins/samples/plantillas_html2pdf/Plantillas_html2pdf_muestra.pdf

sivanagak commented 6 years ago

@shawe Checked your demo result. Can you please share html of demo pdf. I want excatly same format.

shawe commented 6 years ago

@sivanagak for this reason I talk to spipu to reopen this issue, for me was strange that nobody ask for the same "problem".

This is my code for the last template generated (it's not fully parametrized, only to generate this specific sample) https://pastebin.com/bSCKXRJ5 It is integrated in FacturaScripts to have a easy way to have customized templates for customers.

captura de pantalla de 2017-12-27 20-36-09 captura de pantalla de 2017-12-27 20-36-06

Louisonix commented 4 years ago

Anyway, it would be great if the html2pdf users could check for the current page or embedd special content on the first/last page header/footer.

That way, you can create a special header/footer for the first and last page, which is a common use case for print documents.

vespino commented 2 months ago

This comment lead me to "end_last_page" which enables me to show the page_footer only on the last page of my document, great! However I'm looking to only show the page_header on the first page of the document. Any idea how to go about this?