Print.js: connecting to vuejs

Created on 3 Jan 2018  Â·  2Comments  Â·  Source: crabbly/Print.js

how do i connect this to vuejs

Most helpful comment

@renjfk Hey Ren, there isn't anything special about using the library with Vue. If you define it as a global variable, you can use it anywhere. As Jesús mentioned, you can just call the printJS function inside any Vue method.

If you installed the library using npm, here is one way to import and use it:

import printJS from 'print-js';

Then inside your Vue instance (and/or components):

methods: {
    myMethod() {
      printJS('myPdfFileUrl.pdf');
    }
  }

All 2 comments

actually if you load printJS as global variable or injecting on js scope can use in this way

// Creating the vue object
var vuemethod = new Vue({
...
methods : {
    print_pdf : function(url){
      printJS({printable: url, type:'pdf', showModal:true});
    }
  }
});
// on html
<a v-on:click="print_pdf('/uri/to/pdf')" target="_blank">Ver PDF</a>

@renjfk Hey Ren, there isn't anything special about using the library with Vue. If you define it as a global variable, you can use it anywhere. As Jesús mentioned, you can just call the printJS function inside any Vue method.

If you installed the library using npm, here is one way to import and use it:

import printJS from 'print-js';

Then inside your Vue instance (and/or components):

methods: {
    myMethod() {
      printJS('myPdfFileUrl.pdf');
    }
  }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

SleepyFanjo picture SleepyFanjo  Â·  4Comments

deysudip picture deysudip  Â·  4Comments

GuoSirius picture GuoSirius  Â·  8Comments

Aloogy picture Aloogy  Â·  7Comments

Kreativschnittstelle picture Kreativschnittstelle  Â·  8Comments