Dear friends

i have developed a report using php/html/css. i have included @media print css style using div tag for page break because i want to print on different pages. each and everyting is working fine but only problem is delaying during printing..the printer print one page and sleep for few seconds and the next page and sleep for second and so on...

can anyone knows about the easy solution? please

Dani AI

Generated

Short summary and direction (for ): the pause you see happens during the client-side print/pagination step — not in PHP — and it’s commonly caused by how the browser paginates HTML with forced page breaks, or by the printer driver/spooler behavior when it receives complex, per-page data. was right to suspect something outside PHP; was also right that the problem appears after the page is rendered in the browser.

How to fix the CSS/pagination first

  • Browsers paginate at print time and older page-break properties are legacy; prefer the modern rules and be explicit about display so engines don’t treat the break element as a floated/inline box. (developer.mozilla.org)
  • If your layout uses floats, grids or tables, reset those rules in a print stylesheet — Chrome in particular can ignore breaks on floated elements unless you force block display. (stackoverflow.com)

Example (place in your @media print stylesheet):

@media print {
  .page-break {
    display: block !important;
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
  }

  /* undo screen layout that breaks printing */
  .row, .col, .float-left, .float-right { float: none !important; display: block !important; }
}

Printer/driver and spooler checks (quick)

  • Try a different driver type (PCL vs PostScript) or the HP Universal Print Driver for the P4015; driver choice affects how the job is rasterized and can change per-page pauses. ()
  • On Windows print queues test the spool setting: “Start printing immediately” vs “Start printing after last page is spooled” (or temporarily “Print directly to the printer”) to see if behavior changes — spooling behavior can create the per-page pauses you describe. (support.microsoft.com)

If CSS + driver tweaks don’t help

  • Create a single PDF first (client “Save as PDF” or generate server-side). Printing a pre-rendered PDF usually eliminates browser pagination overhead; tools that generate PDFs from HTML (wkhtmltopdf, headless Chromium/Puppeteer) are commonly used for faster, stable print output. (manpages.ubuntu.com)

Practical checklist

  1. Test same HTML in Chrome/Firefox/Edge and compare.
  2. Remove page-break CSS temporarily and print a multi-page sample.
  3. Try PDF-first printing (save as PDF, then print).
  4. Swap drivers (PCL <> PS) and toggle spool settings.

Those steps usually narrow down whether the delay is a browser pagination issue (fix with CSS or pre-rendered PDF) or a driver/spooler issue (fix with driver/spool settings).

Recommended Answers

All 4 Replies

Member Avatar for Member #949455

the printer print one page and sleep for few seconds and the next page and sleep for second and so on...

What does this have to do with PHP?

You can't blame a code for how a printer print things or how to speeds things up?

can anyone knows about the easy solution? please

There's no solution. It's either your printer/copier have a bad connection or you have some other code like a .bat command file interfering with your connection.

printer model HP p4015 which is best one for havey duty printing. other reports developed in php without @media print css (used for page break) code printing smoothly but where i used page break it delaying in printing....

Member Avatar for Member #949455

printer model HP p4015 which is best one for havey duty printing. other reports developed in php without @media print css (used for page break) code printing smoothly but where i used page break it delaying in printing....

There is some code interfering with your connection.

Member Avatar for Member #120589

This is not php. This is a CSS issue. Perhaps you'd get a more informed response over there. CSS is applied from the client, so after any PHP has run its course. You'd probably find that you'd get the same results if you had static html instead of php-created html and applied the same CSS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.