1.3.3 • Published 4 years ago

electron-vue-printer v1.3.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Features

  • Silent print
  • Ultra small
  • Simple usage
  • No other dependencies

Hint

  • Version number: v3.1.13、 v7.3.2、 v8.5.0、 v9.2.1 perfectly usable.The corresponding minor version number should be the same.
  • Version number: v5.0.13、 v6.1.12 is available, but only the default printer can be used.The corresponding minor version number should be the same.
  • Version v4 has various problems, so support is dropped.

Installation

npm install electron-vue-printer -S
or
yarn add electron-vue-printer -S

Usage

index.vue -->
<template>
  <div class="index">
    <electron-vue-printer
      ref="electronVuePrinter"
      :silent="false"
      @webview-ready="webviewReady"
    ></electron-vue-printer>
  </div>
</template>

<script>
  import electronVuePrinter from 'electron-vue-printer'

  export default {
    name: "index",
    components: {
      electronVuePrinter
    },
    methods: {
      webviewReady() {
        this.$refs.electronVuePrinter.print('https://cdn.pixabay.com/photo/2017/06/10/07/29/printer-2389244_960_720.png');
      },
    },
  }
</script>
ConfigurationTypeDefaultDescription
optionsobjectoptions.offsetX: number. Left the offset,default 0.
options.offsetY: number. Top the offset,default 0.
options.imageWidth: number. Width of picture.
options.imageHeight: number. Height of picture.
rotateTypenumber0Image rotation direction. 0: normal;1: Clockwise;2: Counterclockwise;3: Upside down.
imgStylestringCustomize image styles.Width and height can override options.imageWidth and options.imageHeight.Transform will cause rotateType to become invalid.
showbooleanfalseWhether to display preview.For debugging.
silentbooleanfalseWhether to enable silent printing.
EventsDescription
dom-ready(webview)The webview for the user to render the printed content is ready,And return the dom of the webview.
get-printer-list(data: Array)Return printer list data.Maybe setPrinterName method can use it.
webview-render-beginPrint content starts to render.
webview-render-finishThe printed content is rendered.
start-printing(state: Boolean)Start printing, and return whether to start printing normally.

Methods

  • print([src,base64]:String) - Set print picture src(The absolute path of the local picture or the address of the online picture) or base64 to trigger print automatically.
  • setPrinterName(name:String, callBack(err)) - Set the printer device name.If you don't want to use the default printer, you can use it.If err in callBack is not empty, it means the setting failed.

License

MIT