2

I have an HTML with images:

<img id="1" .../>
<img id="2" .../>
<img id="3" .../>
<img id="4" .../>

While printing, I want every image to be on a separate page (according to the print size).

Now I get the images cut off in the middle.

Is there any way to fix it?

3
  • 1
    developer.mozilla.org/en-US/docs/Web/CSS/page-break-before Commented Apr 30, 2014 at 11:10
  • I tried, but it doesn't work. I have 81 images and I get 78 print pages (I see the pages cut in the middle). Commented Apr 30, 2014 at 13:58
  • I tried: <style> @media print { img {page-break-after:always;} } </style> Commented Apr 30, 2014 at 14:05

1 Answer 1

5

You can try the following..

<html>
    <head>
        <style type="text/css">
            @media print {
                p.pageBreak {page-break-after: always;}
            }
        </style>
    </head>
    <body>

    <p class="pageBreak">
        <img id="1" src="http://placehold.it/250x250">
    </p>
    <p class="pageBreak">
        <img id="2" src="http://placehold.it/250x250">
    </p>
    <p class="pageBreak">
        <img id="3" src="http://placehold.it/250x250">
    </p>
    <p class="">
        <img id="4" src="http://placehold.it/250x250">
    </p>
    </body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.