Giter VIP home page Giter VIP logo

Comments (5)

cognitom avatar cognitom commented on June 5, 2024 14

We can also write them together in <style> tag. This could be more manageable if you use the paper size in only one document.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>receipt</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
  <link rel="stylesheet" href="../paper.css">
  <style>
    @page { size: 58mm 100mm } /* output size */
    body.receipt .sheet { width: 58mm; height: 100mm } /* sheet size */
    @media print { body.receipt { width: 58mm } } /* fix for Chrome */
  </style>
</head>

<body class="receipt">
  <section class="sheet padding-10mm">
    ...
  </section>
</body>
</html>

from paper-css.

cognitom avatar cognitom commented on June 5, 2024 10

Hi @chenweiyj,
The paper sizes are defined here and here.

You can add any paper size like this in your css file:

body.receipt .sheet { width: 58mm; height: 100mm } /* change height as you like */
@media print { body.receipt { width: 58mm } } /* this line is needed for fixing Chrome's bug */

Then HTML file could be like this:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>receipt</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
  <link rel="stylesheet" href="../paper.css">
  <style>@page { size: 58mm 100mm }</style>
</head>

<body class="receipt">
  <section class="sheet padding-10mm">
    ...
  </section>
</body>
</html>

The point is that we need to set the size value in @page section, too. Have a fun!
See also: https://developer.mozilla.org/en-US/docs/Web/CSS/@page/size

from paper-css.

abinkuruvilla avatar abinkuruvilla commented on June 5, 2024

really helpful for silent printing. thanks.

from paper-css.

benjir01 avatar benjir01 commented on June 5, 2024

Any video Tutorial

from paper-css.

tunakode avatar tunakode commented on June 5, 2024

Hi @chenweiyj,
The paper sizes are defined here and here.

You can add any paper size like this in your css file:

body.receipt .sheet { width: 58mm; height: 100mm } /* change height as you like */
@media print { body.receipt { width: 58mm } } /* this line is needed for fixing Chrome's bug */

Then HTML file could be like this:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>receipt</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
  <link rel="stylesheet" href="../paper.css">
  <style>@page { size: 58mm 100mm }</style>
</head>

<body class="receipt">
  <section class="sheet padding-10mm">
    ...
  </section>
</body>
</html>

The point is that we need to set the size value in @page section, too. Have a fun!
See also: https://developer.mozilla.org/en-US/docs/Web/CSS/@page/size

If continuous paper printing, should I set height to auto or just not defined height??

from paper-css.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.