Giter VIP home page Giter VIP logo

Comments (5)

MatthewHerbst avatar MatthewHerbst commented on August 24, 2024 1

Hello, thanks for writing this up.

https://codesandbox.io/p/devbox/print-container-not-showing-headers-footers-checkbox-8cj65z?file=%2Fsrc%2Fcomponents%2FPrintContainer.tsx%3A16%2C13

I'm unable to access this link, is it correct/do you need to make it public?

This is really interesting though. I was able to replicate the issue locally using the examples. Commenting out these lines resolved the issue. However, while having those lines commented out I toggled the show headers/footers once, and now, even with those lines running, I cannot replicate the issue. Very strange.

This seems more like an upstream bug in Chrome than a bug with MUI or anything else. Safari does not appear to have this issue. Firefox also seems to not have this issue, and instead forces headers and footers on even with the lines above (which also feels like an upstream bug in Firefox).

Will investigate this more, thank you. My guess is that we have limited ability to fix this in a generic way though 😢

from react-to-print.

reisblucas avatar reisblucas commented on August 24, 2024 1

@MatthewHerbst lol I forgot to make it public. Now, it's edited with new link, everyone can fork and follow those steps.

from react-to-print.

MatthewHerbst avatar MatthewHerbst commented on August 24, 2024 1

@sensasi-delight thanks for the report. Based on your fix, it's possible MUI added some code that also uses @media print so you need your specifier to be more specific to override theirs. Just a guess though, I haven't looked at their code

from react-to-print.

reisblucas avatar reisblucas commented on August 24, 2024

@MatthewHerbst Maybe, after you enabling and commenting again, continue to appear the option because the rule was set on this chrome tab, so you need to force refresh the page(F5/cmd+R) to reproduce again.

On my attempt to reproduce on sandbox by the first time, nextjs v14 with App Router was installed instead of v13 with pages router. So I just simulated there, on v14, without MUI theme provider and etc.

It showed options and header as normal, thats why I think about MUI could be part of the problem.

from react-to-print.

sensasi-delight avatar sensasi-delight commented on August 24, 2024

I recently encountered a similar issue where the page margins suddenly disappeared when printing, even though I hadn't changed my code for the past four weeks. Strangely, this printing issue just appeared today. I tried to find which PR from MUI caused this, but there were too many to sift through, making it difficult to pinpoint the exact one. I just wanted to share a solution that I implemented, which is different from what the author suggested. I used the pageStyle property in the ReactToPrint component:

<ReactToPrint
  {...props}
  - pageStyle="@page { margin: auto; }" // this line is working fine for the past four weeks
  + pageStyle="@media print { margin: auto; }"
 />

I hope this helps someone experiencing the same problem.

from react-to-print.

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.