Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a Blank Page along with the component to be printed #26

Closed
shyam2794 opened this issue Jun 24, 2018 · 20 comments
Closed

Getting a Blank Page along with the component to be printed #26

shyam2794 opened this issue Jun 24, 2018 · 20 comments
Labels

Comments

@shyam2794
Copy link

Hi ,

I am trying to print the bill . And am facing some issues in handling it . I am able to get the bill component to be printed but am getting another blank page .

screenshot from 2018-06-24 17-13-19

By Default it takes two pages . Am not sure how to resolve this .

@gregnb gregnb added the bug label Jul 6, 2018
@gregnb
Copy link
Collaborator

gregnb commented Jul 10, 2018

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

@gregnb
Copy link
Collaborator

gregnb commented Jul 25, 2018

There has been a rewrite pivoting away from popup windows.

npm install [email protected] --save

@gregnb gregnb closed this as completed Jul 25, 2018
@dsdavis4
Copy link

dsdavis4 commented Aug 6, 2018

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

@LucasBSC
Copy link

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

@MatthewHerbst
Copy link
Owner

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

@zainpros
Copy link

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

@MatthewHerbst
Copy link
Owner

@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.

@srj-github
Copy link

srj-github commented Feb 14, 2022

If anyone lands here, perhaps this will help:

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

@JavierVescio
Copy link

JavierVescio commented Jun 8, 2022

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.

@ashabhussan
Copy link

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.

@shlaskt
Copy link

shlaskt commented Sep 6, 2022

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;
  }
}

@mateusdegobi
Copy link

mateusdegobi commented Dec 7, 2022

@srj-github

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

It works for me!!
Thanks, friend.

MatthewHerbst added a commit that referenced this issue Jan 3, 2023
MatthewHerbst added a commit that referenced this issue Jan 3, 2023
* Add README FAQ note about #26

* Add `break-*` doc links to the README

* Remove unused TravisCI config

* Update LICENSE for 2022

* Improve default `pageStyle` and add page `size` FAQ entry

* Add FAQ entry about setting `removeAfterPrint` to `false` sometimes

* Add example of setting state in `onBeforeGetContent` to the README

* Upgrade `devDependencies`

* Add a `textarea` to the example component

* Add note about an internal `handleRemoveIframe` call

* Ensure we wait for `fonts` to load

We currently load `fonts` but don't actually check to see if they
have completed loading before printing. This fixes that.

* Fix too strict error type for font load failure

* Simplify loading logic, add more error information

* Guard against handling a resource twice

* Add gaurd to continue printing with custom `fonts` even if `FontFace` API is not supported
@abhijitkumarIN
Copy link

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 ?

@yasinbhojani
Copy link

Thanks, this works @srj-github

@darkengine
Copy link

darkengine commented Nov 6, 2023

@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.

@Preetam7064
Copy link

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

Not working

@GourabPaul007
Copy link

It does not work in my case, The styles on 2nd page onwards gets weird.

This is what its supposed to print
image

But in the print window, it shows
image

I have tried all solutions in this thread. Is there any reason why it is behaving like this?

@MatthewHerbst
Copy link
Owner

I have tried all solutions in this thread. Is there any reason why it is behaving like this?

Please share your code, ideally in a working Codesandbox or similar. Can't debug from pictures.

@GourabPaul007
Copy link

Here is a codesandbox https://codesandbox.io/p/sandbox/quiet-pine-8behs
I think the problem lies with absolute positioning of the smaller blocks/components. referring to this
image
This project requires absolute positioning. Help me know if there is any other way to fix this problem.

@MatthewHerbst
Copy link
Owner

Here is a codesandbox https://codesandbox.io/p/sandbox/quiet-pine-8behs

For me this prints without issue, though it's hard to tell because the formatting is hard to understand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests