@eyelly/print
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Print

Print is a simple function for partial printing on the browser

Installation

NPM

npm i -S @eyelly/print

CDN

<script src='https://unpkg.com/@eyelly/print/dist'></script>

Usage & Example

In Module

import print from '@eyelly/print'

const fooDom = document.getElementById('xxx')
print({
  content:fooDom
})

In HTML

<!DOCTYPE html>
<html lang="en">

  <head>
    <script src='https://unpkg.com/@eyelly/print/dist'></script>
  </head>

  <body>
    <div id='content'> this is content to print </div>
    <div> this is normal content </div>
    <button id='button1'>normal print</button>
    <button id='button2'>new window print</button>
    <script>
      const content = document.getElementById('content')
      const button1 = document.getElementById('button1')
      const button2 = document.getElementById('button2')

      button1.addEventListener('click', () => {
        print({
          content
        })
      })

      button2.addEventListener('click', () => {
        print({
          content,
          newWindow: true,
          title: 'print example'
        })
      })
    </script>
  </body>

</html>

API

Property Description Type Default
content content to be printed HTMLElement -
newWindow open a new window to print boolean false
title the title of the newly opened window boolean -

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @eyelly/print

Weekly Downloads

12

Version

1.0.0

License

MIT

Unpacked Size

12.1 kB

Total Files

10

Last publish

Collaborators

  • eyelly