1

I am using react-to-print with Nextjs.

Problem

enter image description here

This is the problem.

I don't want it to break and want it to continue and treat it as 1 page.

I have POS-80C thermal printer, and it cuts on every page.
It should only cut at the last when everything is printed.

Things I tried

- I tried to use page-break inside @media print .

@media print {
  @page {
    size: 80mm auto;
    margin: 7.56px;
  }

  .dontsplit {
    page-break-inside: avoid;
    // page-break-before: avoid;
    // page-break-after: avoid;
    page-break-after: always;
  }

  .table-to-print * {
    font-size: 0.9rem;
    margin: 0;
    padding: 0;
  }

  .no-print {
    display: none;
  }
}

- I tried scaling it down to fit on a single page, but the text becomes very tiny and unreadable.
resize-page-contents-to-fit-on-one-print-page

Questions
- Is it fixable with CSS only?
- Is it fixable with javascript before .print() is initialized?
- Is it the default behaviour of browsers and can't be fixed?

8
  • Seems that your @page size auto has been translated into 297mm (see screenshot). Can you use an explicit length like 1000cm? Commented Oct 13, 2024 at 15:54
  • @HeikoTheißen changing auto to 100 cm or 1000cm causes the text to shrink/scale down. Precisely, the margin becomes too much, and when I make the margin of left and right to 2mm same thing as the picture happens. Commented Oct 13, 2024 at 16:07
  • Does it help if you "Print > Save as PDF ..." first and then print the PDF instead of the HTML page? Commented Oct 13, 2024 at 16:36
  • @HeikoTheißen That makes it worse. I saved it in pdf as A4 (there is no option for 80mm). When I open the pdf, and print from the printer, the text are overflowing. Only the S.N. and order (left side of the bill) is seen on the paper. Commented Oct 13, 2024 at 16:43
  • 1
    Let us continue this discussion in chat. Commented Oct 13, 2024 at 17:01

0

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.