Comments (5)
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.
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.
really helpful for silent printing. thanks.
from paper-css.
Any video Tutorial
from paper-css.
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)
- Page sizes off by one mm? HOT 4
- Firefox adds a blank page on printing - even with single empty page HOT 9
- detect the size of paper
- Firefox adds a blank page on printing-only for Firefox HOT 1
- Lengthy html elements are getting cut off HOT 2
- Bottom shadow doesn't display right on iOS
- Can we generate the page number dynamically? HOT 2
- Any one know why this not work in iPad?
- How to add F4 paper size? HOT 8
- Print size problem HOT 4
- How to include a footer respecting left and right padding? HOT 1
- Do i need to credit the author in my work? HOT 1
- How to print two A4 paper in A3 Landscape? HOT 1
- How to add page numbers
- Is this abandoned? HOT 1
- Are these lines still needed?
- When printing. It always adds an extra page. HOT 4
- Use css class instead apply to body element directly
- Accounting for different DPI (ie 72 vs 96)
- Request: Multiple pages with different sizes and orientations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paper-css.