mycurelabs / vue-html-to-paper

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

_this.$htmlToPaper is not a function #83

Closed lialia-siterocket closed 3 years ago

lialia-siterocket commented 3 years ago

Hello! Installed last ver 1.4.1

app.js:

import Vue from 'vue'
window.Vue = Vue;
import VueHtmlToPaper from 'vue-html-to-paper';
const optionsForPrint = {
    name: '_blank',
    specs: [
        'fullscreen=yes',
        'titlebar=yes',
        'scrollbars=no'
    ],
    styles: [
        "/backend/css/app.css"
    ],
    timeout: 1000, // default timeout before the print window appears
    autoClose: true, // if false, the window will not close after printing
    windowTitle: window.document.title, // override the window title
}
Vue.use(VueHtmlToPaper, optionsForPrint);

Template: <a @click.prevent="printHtml()" class="btn small" href="">Print</a>

Methods:

 async printHtml(id = null) {
            id = id ? id : 'printMe';

            await this.$htmlToPaper(id);
        }

image

AminHadei commented 3 years ago

I had same issue last day. I solved this issue for myself by downgrade package. I hope it works for you too :)

lialia-siterocket commented 3 years ago

@AminHadei for me it works too, but the creator of the package promise to resolve another issue by this update (in ver 1.4.0+) 😄

jaredthirsk commented 3 years ago

How far do you have to downgrade to get this to work?

jaredthirsk commented 3 years ago

I got 1.3.1 working. Doesn't the author notice that 1.4.0 and 1.4.1 don't work at all? Or maybe there's more than one way to use it.

inane commented 3 years ago

What version are you using? tested with 1.3.1 and 1.3.0 and same behavior :-(

amacado commented 3 years ago

Had the same error, v1.3.1 worked for me. Thanks @jaredthirsk

onin-hub commented 3 years ago

yah i got version 1.3.1 its working now .

kupoback commented 3 years ago

I can't get version 1.3.1 to work without it triggering errors in Chrome about passing a boolean in window.open. Has anyone figured out a workaround for this? Can't use 1.4.0, which apparently has that fix, cuz of the issue outline here.

EDIT To get this to work without closing, I removed the name param.

sangib58 commented 3 years ago

I had the same issue and no luck with v1.3.1.

matvelius commented 3 years ago

same...

cobenash commented 3 years ago

no luck.

jofftiquez commented 3 years ago

Hello everyone, apologies for the super late response. I am extremely sorry for responding so late to your inquiries. I am super busy right now and I find it hard to include these issues in my time. I hope you understand. I will do what I can to help you with your issues. I will keep you posted here. Again, I am truly sorry. Please stay safe everyone.

jofftiquez commented 3 years ago

Hi @lialia-siterocket can you share how you installed the plugin? Thanks.

jofftiquez commented 3 years ago

Hi all I hope that v1.4.2 will fix this problem.

The problem was that the new script for building using webpack was upgraded to latest webpack version and it seems to have some bad effects causing the build output to have undefined on the installed method of the plugin, which means the plugin is never being installed properly but without error. Hence the $htmlToPaper method was never available in the first place.

This was entirely my mistake, I only tested the umd build implementation the one you see in the documentation.

Please let me know if there's any more problem. Thanks.