-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Sometimes a printable area is sent to print before styles have loaded. #7
Comments
Mike, your English is fine. I understand. It's weird that not all the styles are coming over considering that it's copying style sheets from a parent window that should have already downloaded them and been cached in the browser. Do you maybe have caching disabled? Could you walk me though the steps you take to trigger the bug? Is it consistent? |
Sure. I'll do it a little bit later. |
Sorry for the delay, a lot of work :) Yes, I have caching enabled and I do everything like in the documentation. On my localhost it works fine. But when I'm trying to print on server, I get this issue. I know, it's a little bit weird :) It could be fixed by increasing timeout. But I think it's better to wait all styles loading. |
Yeah it's still an odd issue I haven't had time myself to test this out more. I'll try to get around to it. It can't hurt to see an implementation with it being promisfied if you still want to complete that |
Sure! |
I think I have an easier way to solve this problem. In the latest version I added onload/onerror callbacks on copied stylesheets so once they're triggered we will know that they are loaded in the print window and only then do we trigger print. If that doesn't solve the issue I'll reopen this |
Hi, I have been using the library to try to generate some pdf. It's a great and easy way to use the library by only using html and css to style the invoice, and it works great on localhost. However, when i use it on production, the style always fails to load on the first attempt to print the file. The print window still pops up before the style loads, or rather the style does not load at all. If i close the window and try a second time the style will load properly after waiting for a while. (sometimes the print window does not even pops up after the style is loaded). |
@thamjieying could you share your environment details with us? OS, node version, etc |
I am using this library on the client side using react, and nodejs v8.7.0 as the server. I am developing using macOS. Does these affect the performance? |
No, just trying to understand what your environment is. Which browser are you using? If you try different browsers do you still have issues? |
I have tried on mac with chrome, firefox, Opera and safari, the browser on mac always fails on the first attempt to download, as i have described, |
I'm not seeing an issue @thamjieying look at this example here where I pull in a completely foreign CSS file from w3c schools: https://3vqww5xo0m.codesandbox.io/# Do you see the styling come over? |
@gregnb I tried yours and it worked fine. I don't know what's wrong with mine. maybe the style fine is too big? Thanks for the prompt reply. I might try another library if the problem still persist. |
@thamjieying Hey. Were you able to solve the issue. I am also facing the same issue. The styles are not loaded the first time print window opens. On subsequent opens, the styles get loaded. |
It happens when copyStyles set to true. I have an idea how to fix it. I'll try it when I have a free time and I'll make a merge request.
I think loading styles should be "promisified". When all styles is loaded, then
target.print()
should be called. Sorry for my English, I hope you understand what I mean :)The text was updated successfully, but these errors were encountered: