mycurelabs / vue-html-to-paper

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

Cannot read property 'write' of undefined #59

Closed Borderliner closed 3 years ago

Borderliner commented 4 years ago

On Nuxt.js + Electron setup, I get Cannot read property 'write' of undefined when using this package. It happens with all the elements, simple or complex. Here's my setup:

// plugins/vue-html-to-paper.js
import Vue from 'vue'
import VueHtmlToPaper from 'vue-html-to-paper'

const options = {
  name: 'table',
  specs: [
    'fullscreen=yes',
    'titlebar=yes',
    'scrollbars=yes'
  ],
  styles: [
    '../assets/bootstrap.min.css',
    '../assets/kidlat.css'
  ]
}

Vue.use(VueHtmlToPaper, options)
// nuxt.config.js
module.exports = {
  ...
  plugins: [
    { src: '@/plugins/icons.js', ssr: true },
    { src: '@/plugins/vue-html-to-paper.js' }
  ],
  ...
// my-component.vue
methods: {
  printWaybills () {
    this.$htmlToPaper('mytable')
  },
}

All I get is a blank screen with the title table, and in the main window I get Cannot read property 'write' of undefined. The exact error location is in this line:

return v.document.write("\n        <html>\n          <head>\n            <title>" + document.title + "</title>\n          </head>\n          <body>\n            " + y.innerHTML + "\n          </body>\n        </html>\n      ")
jofftiquez commented 3 years ago

Hi, please try v1.4.1. Thanks.