Comments (21)
Complete shot in the dark here but try adding this CSS somewhere:
@media print { html, body { height: initial !important; overflow: initial !important; }}
from react-to-print.
Mixed @shawnco's and @zzq0324's solutions and it worked well for me:
@media print {
html, body {
height: initial !important;
overflow: initial !important;
-webkit-print-color-adjust: exact;
}
}
@page {
size: auto;
margin: 20mm;
}
from react-to-print.
I also struggled with styling/margins on multiple pages and found a workaround with viewport units:
<div className="container" style={{margin: "0", padding: "0"}}>
<div style={{height: "90vh", padding: 5vh}}>
page 1 content
</div>
<div style={{height: "90vh", padding: 5vh}}>
page 2 content
</div>
</div>
from react-to-print.
Hi, I've managed to print multiple pages but the cut is disgraceful, there is no bottom padding. I've played with page-break-inside
, it does not work as expected (it tries to avoid the page break but cut the paragraph in 2).
from react-to-print.
I also struggled with styling/margins on multiple pages and found a workaround with viewport units:
<div className="container" style={{margin: "0", padding: "0"}}> <div style={{height: "90vh", padding: 5vh}}> page 1 content </div> <div style={{height: "90vh", padding: 5vh}}> page 2 content </div> </div>
from react-to-print.
After playing for a while, the solution that worked for me was to treat page-break
(-inside
, etc.) more granularly than I had been.
I had been under the impression that my dynamically rendering react components' split would happen automatically as long as I didn't have overflow or display set incompatibly with print mode, but that wasn't what I observed.
Instead, my breaks appeared only once I both: added a .page-break
class to the dynamically-rendering components that I envisioned could auto-break, and then applied the following styles:
@media all {
.page-break {
display: none;
}
}
@media print {
.page-break {
display: block;
page-break-before: auto;
}
}
from react-to-print.
If anyone would like to add to the README FAQ with a generic solution to this I would be happy to accept that PR!
from react-to-print.
Hi, did you find any solution for print of multiple pages. I'm using Material-UI template and i have long tables to print. I'm having problems at the top of page 2.
Unfornately I can't figure out what the problem was, and I was forced to choose pdfmake...
@hrafaelveloso thank you.
from react-to-print.
The FAQ is clear Page Breaks 🍻
from react-to-print.
CSS property page-break-inside worked for me
@media print { div.qandA{ page-break-inside: avoid; } }
Here my div className is "qandA" and wrap all elements in one div which you want to show on one page
from react-to-print.
@kaydeniz Hi! Just stumbled upon this thread and decided to share my workaround. So my guess is that you were using the right structure for a table i.e. <TableHead />
but what happens is that the default behaviour of the html tag for the table head is repeating itself when printing in a new page and that somehow messes with the rest of the styles.
So I removed the table head and added the head row inside the body twitching the styles so it looks like the actual head. For now this is the best workaround I found until I figure out what in MUI is messing with the printing.
from react-to-print.
Is this a bug or is there functionality that needs to be added?
from react-to-print.
I face the same issue too, I have a long table and can only print 1 page at a time and when i scroll and try again there is an akward cut .
from react-to-print.
Hi all. Could anyone please share a codepen or fiddle with an example so that I can play around with it and try and work on a fix? Thanks
from react-to-print.
@MatthewHerbst
I use rc-print instead, code just like this:
<Print title="" insertHead={false} otherStyle="@page { size: auto; margin: 0mm; } @media print { body { -webkit-print-color-adjust: exact; } }"><div></div></Print>
I hope it can help you.
from react-to-print.
When the Component I want to print only takes 1 page, everything works great.
I'm using Material-UI and I have tables that use material-table and this works great when the result is a single page file.
However, when it goes to multiple pages I can't:
. Break where I want (using css page-break-before) ;
. Bottom margin is inexistent, even with padding and margin-bottom...
I really need that functionality, and I lost at least 2 days trying to figure it out without success...
from react-to-print.
@hrafaelveloso PRs are welcome if you have any ideas on how best to do this! I haven't had too much time to look at this issue over the other issues in the codebase
from react-to-print.
When the Component I want to print only takes 1 page, everything works great.
I'm using Material-UI and I have tables that use material-table and this works great when the result is a single page file.
However, when it goes to multiple pages I can't:
. Break where I want (using css page-break-before) ;
. Bottom margin is inexistent, even with padding and margin-bottom...I really need that functionality, and I lost at least 2 days trying to figure it out without success...
Hi, did you find any solution for print of multiple pages. I'm using Material-UI template and i have long tables to print. I'm having problems at the top of page 2.
from react-to-print.
Hi, did you find any solution for print of multiple pages. I'm using Material-UI template and i have long tables to print. I'm having problems at the top of page 2.
Unfornately I can't figure out what the problem was, and I was forced to choose pdfmake...
from react-to-print.
Going to close this as a CSS issue. Thanks everyone for the solutions, and please feel free to continue talking about it here.
from react-to-print.
After playing for a while, the solution that worked for me was to treat
page-break
(-inside
, etc.) more granularly than I had been.I had been under the impression that my dynamically rendering react components' split would happen automatically as long as I didn't have overflow or display set incompatibly with print mode, but that wasn't what I observed.
Instead, my breaks appeared only once I both: added a
.page-break
class to the dynamically-rendering components that I envisioned could auto-break, and then applied the following styles:@media all { .page-break { display: none; } } @media print { .page-break { display: block; page-break-before: auto; } }
Hi @hbrannan , may i ask you a fiddle or codepen by the example of this multiple printing page for me to play around, please?
from react-to-print.
Related Issues (20)
- Page break wide content HOT 3
- Superscripts <sup/> and subscripts <sub/> HOT 1
- react-to-print custom print html content dev vs prod discrepancy HOT 4
- [BUG] [TEMPORARY FIX] - Print container on Chrome + MUI is hiding `Header and Footers` option as default behavior HOT 5
- The FOOTER to only display at the LAST PAGE HOT 3
- codesandbox examples are not loading HOT 2
- onAfterPrint is called before print iframe appears HOT 1
- On mobile devices are not truncated accordingly ref HOT 1
- Add Border to every Page HOT 4
- Add dynamic colors to print function HOT 1
- How to check that the user click on Save in `onAfterPrint`? HOT 2
- getting Supplied Data is not a valid base64-String jsPDF.convertStringToImageData erorr while directly downloading image HOT 1
- Border top and bottom HOT 1
- Save as PDF hangs in print view HOT 1
- Blank PDF when trying to generate in production. HOT 2
- How should i handle large data to print? HOT 8
- Why does it render different content when in im browsing in mobile HOT 3
- Blank Page while printing after a certain period of time HOT 9
- How to add style using PageStyle prop, without it overriding component’s style HOT 5
- Warning: findDOMNode is deprecated outside StrictMode. HOT 10
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 react-to-print.