simply-print-vue

Easily print any HTML content you you want in Vue. Tt can be hidden content, certain elements, etc.
886
Install
npm install simply-print-vue
Latest Version:1.0.1
License:MIT
Last Updated:Jun 17, 2022
Links: GitHub  ·  npm
Maintainer: maxshuty

Vue Simple Print

A Vuejs3 Mixin that allows you to open a print window of the contents given in a certain id

This package has originated from vue-html-to-paper

Demo

Installation

Run the following command npm install vue-simple-print

Usage inside main.js

import { createApp } from 'vue'
import HtmlToPrint from "vue-html-to-print";

const app = createApp(App)

app.use(HtmlToPrint).mount('#app')

When imported inside of your main.js file, the mixin is callable from your component

<template>
  <div>
    <div>
      <h1>This is a default page</h1>
    </div>
    <!-- The div with the desired contents -->
    <div id="print">
      <h1>I'd like to print this</h1>
    </div>
    <button @click="print"></button>
  </div>
<template>

<script>
  export default {
    methods: {
      async print () {
        // Pass the element id here
        await this.$htmlToPrint('print');
      }
    }
  }
</script>

Optionally you can apply different options with each call by defining other options

this.$htmlToPrint('print');

Related Packages

vue-html-to-paper

Vue mixin for printing html elements to paper.

350,733 13
paperizer

Vue composable to easily print components.

26,341 18
html-to-a4-template

Convert html to A4 template, which helps to preview and ensure the print styles

2,475 12
ink-html

Prints a specific area/element of your html page

3,846 16
vue-resize-sensor

detect container resizing

1,419,113 74

Version History

Version Released License
1.0.1 MIT
1.0.0 MIT