vue-html2canvas

0.0.4 • Public • Published

vue-html2canvas

Vue mixin for Html2Canvas

Install

npm install vue-html2canvas

Or

yarn add vue-html2canvas

Usage

main.js

import Vue from 'vue';
import VueHtml2Canvas from 'vue-html2canvas';
 
Vue.use(VueHtml2Canvas);

component

<template>
  <div>
    <!-- SOURCE -->
    <div ref="printMe">
      <h1>Print me!</h1>
    </div>
    <!-- OUTPUT -->
    <img :src="output">
  </div>
<template>
 
<script>
export default {
  data() {
    return {
      output: null
    }
  },
  methods: {
    print() {
      const el = this.$refs.printMe;
      // add option type to get the image version
      // if not provided the promise will return 
      // the canvas.
      const options = {
        type: 'dataURL'
      }
      this.output = await this.$html2canvas(el, options);
    }
  }
}
</script> 

Made with ❤️ by Jofferson Ramirez Tiquez

Package Sidebar

Install

npm i vue-html2canvas

Weekly Downloads

3,894

Version

0.0.4

License

MIT

Unpacked Size

342 kB

Total Files

9

Last publish

Collaborators

  • cent1pede