This is my current problem.
I want to generate a HTML page, which contains about 40 coupons. Each coupon must be with one A4 sized section.
So, if I were to print the HTML document, I would like each printed page to contain 1 coupon.
Ideas on how I could accomplish this ?
However, with no width value provided for the HTML element, setting the width of the body element to 100% results in full page width. This can be counterintuitive and confusing. For a responsive full page height, set the body element min-height to 100vh.
The following CSS should achieve what you need, subistitute the class name for whatever is appropriate for your DOM structure
@media print {
.coupon-class
{
page-break-after:always;
}
}
This will always insert a page break after the element you can also use page-break-before
to achieve a page break before an element.
You'll never get a very precise solution using HTML, as every browser decides its way of printing HTML is best and adds all sorts of headers and footers that change the page dimensions and how the clients printer actually prints it.
You would be better off generating a PDF of your coupons which you can easily do with PHP extensions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With