Giter VIP home page Giter VIP logo

Comments (16)

srj-github avatar srj-github commented on July 1, 2024 13

If anyone lands here, perhaps this will help:

@media print {
  html, body {
    height: 100vh;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
  }
}

from react-to-print.

JavierVescio avatar JavierVescio commented on July 1, 2024 5

The solution from @srj-github almost solved my problem (thank you btw). I had to make a little change.
Instead of
height: 100vh;
I had to write
height: auto;

In my case, I had a list which orginally had several rows but I wanted to print only the ones that were checked. If you write 100vh, the print won't take more than one page (it seems that it always prints one page), even when sometimes you actually need two or more pages to show all the rows. But if you write the value auto for the prop height, then it will automatically calculate the correct quantity of pages you need.

from react-to-print.

shlaskt avatar shlaskt commented on July 1, 2024 2

For whoever needs dynamic content that can be more than 1 page, and @JavierVescio's solution didn’t work for him. I managed to remove the extra page with this-

@media print {
  html, body {
    height: initial !important;
    overflow: initial !important;
  }
}

from react-to-print.

MatthewHerbst avatar MatthewHerbst commented on July 1, 2024 1

Hi @LucasBSC can you please create a new issue with more details if you are experiencing a problem? Thank you

from react-to-print.

ashabhussan avatar ashabhussan commented on July 1, 2024 1

If anyone lands here, perhaps this will help:

@media print {
  html, body {
    height: 100vh;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
  }
}

Thanks, @srj-github, It has worked for me.

from react-to-print.

mateusdegobi avatar mateusdegobi commented on July 1, 2024 1

@srj-github

    height: 100vh;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;

It works for me!!
Thanks, friend.

from react-to-print.

yasinbhojani avatar yasinbhojani commented on July 1, 2024 1

Thanks, this works @srj-github

from react-to-print.

Preetam7064 avatar Preetam7064 commented on July 1, 2024 1
 height: 100vh;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;

Not working

from react-to-print.

gregnb avatar gregnb commented on July 1, 2024

Hi @shyam2794 sorry for the delay. Try the new beta version which is going to rely on an iframe to solve the cross origin issues some people are experiencing.

npm install [email protected]

and let me know the feedback if this solves issues

from react-to-print.

gregnb avatar gregnb commented on July 1, 2024

There has been a rewrite pivoting away from popup windows.

npm install [email protected] --save

from react-to-print.

dsdavis4 avatar dsdavis4 commented on July 1, 2024

I am facing the same issue with firefox, and neither of those versions fix the issue. Also tried using pageStyle to set the overflow property with no success. Works great on chrome

from react-to-print.

LucasBSC avatar LucasBSC commented on July 1, 2024

Hello, is this problem already solved somehow? Having same issue here

from react-to-print.

zainpros avatar zainpros commented on July 1, 2024

I am using the latest version and no working for me; is there and other proposed solution please

from react-to-print.

MatthewHerbst avatar MatthewHerbst commented on July 1, 2024

@zainpros if you are having problems please create a new issue and describe your problem, as well as share the code you are using please, thank you.

from react-to-print.

abhijitkumarIN avatar abhijitkumarIN commented on July 1, 2024

ya it is working only for one page but let suppose it page can be 100 page or some time it can be 1 page
but when it is only one page still it is showing two page so on basis of page count we would be inject css ?

from react-to-print.

darkengine avatar darkengine commented on July 1, 2024

@srj-github

    height: 100vh;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;

It works for me!! Thanks, friend.

This works for me. It handles one page and multiple pages correctly. @srj-github 's solution will cut it to a dead one page.

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.