mycurelabs / vue-html-to-paper

Vue mixin for paper printing html elements.
MIT License
298 stars 101 forks source link

css does not work when internet connection is slow #54

Closed nnnayeem closed 3 years ago

nnnayeem commented 4 years ago

Hello,

I am trying to pring using vue-html-to-paper. On my local server everything works fine. When I upload to live server the css seems to does not work even though the css link is correct (I can see the loaded css link using chrome dev tool).

So I tried to find out the root cause. In the option I changed name:'_blank' to name:'_self and and make the internet to 2G using chrome dev tool and I successfully has recreate the problem in local server. It seems browser start printing event before loading the css. In my config file:

const options = {
     name: '_self',
     specs: [
          'fullscreen=yes',
          'titlebar=yes',
          'scrollbars=yes'
     ],
     styles: [
          "/css/style.css",
     ]
}

and priting using this.$htmlToPaper('printInvoice') .

Is there any mistake that I am doing. I would really happy if you could point my mistake or any workaround.

Thanks in advance

mohdabbas commented 4 years ago

I am also facing the exact same issue :-(...

varna9000 commented 4 years ago

Same problem here. BTW different browsers show different results in terms of timing. Firefox and safari manage to get the css, but Chrome doesn't. I think it's a setTimeout issue.

mohdabbas commented 4 years ago

Yes, fixed by increasing the setTimeout Value!

varna9000 commented 4 years ago

@mohdabbas yes, but it's more of a workaround. It's best if the print() function could wait for the css to load in full, I suppose.

dmcbrn commented 3 years ago

Can someone please review this, accept PR if all good, and create new revision?

I didn't put too much effort in it tbh, just updated code as you said the timeout limit can fix this.

jofftiquez commented 3 years ago

Hello @dmcbrn I apologize, the team has been very busy with work lately. I will check your PR. Thank you for your help.

jofftiquez commented 3 years ago

Hi I recently deployed v1.4.1 thanks.