Giter Site home page Giter Site logo

Comments (14)

gregnb avatar gregnb commented on June 25, 2024 2

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

from react-to-print.

gregnb avatar gregnb commented on June 25, 2024

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?

from react-to-print.

MikeSha avatar MikeSha commented on June 25, 2024

Sure. I'll do it a little bit later.

from react-to-print.

MikeSha avatar MikeSha commented on June 25, 2024

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.

from react-to-print.

gregnb avatar gregnb commented on June 25, 2024

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

from react-to-print.

MikeSha avatar MikeSha commented on June 25, 2024

Sure!

from react-to-print.

thamjieying avatar thamjieying commented on June 25, 2024

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

from react-to-print.

gregnb avatar gregnb commented on June 25, 2024

@thamjieying could you share your environment details with us? OS, node version, etc

from react-to-print.

thamjieying avatar thamjieying commented on June 25, 2024

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?

from react-to-print.

gregnb avatar gregnb commented on June 25, 2024

No, just trying to understand what your environment is. Which browser are you using? If you try different browsers do you still have issues?

from react-to-print.

thamjieying avatar thamjieying commented on June 25, 2024

I have tried on mac with chrome, firefox, Opera and safari,
and windows on chrome firefox, Opera and edge.

the browser on mac always fails on the first attempt to download, as i have described,
on pc, chrome has the same problem, firefox rendered correctly on screen but style is never transferred to the downloaded pdf. Only opera and edge works fine on windows.

from react-to-print.

gregnb avatar gregnb commented on June 25, 2024

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?

from react-to-print.

thamjieying avatar thamjieying commented on June 25, 2024

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

from react-to-print.

codeslayer1 avatar codeslayer1 commented on June 25, 2024

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

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.