npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rw-print

v0.0.1

Published

print and customize document in primavera health

Downloads

3

Readme

RWPrint

RWPrint is a print library that decorate all templates of Primavera, you can customize footer, header and add custom styles providing a cdn(url) path or inline css.

Install

Yarn

yarn add @redwagon/rw-print

NPM

npm install -S @redwagon/rw-print

Usage

import { RwPrint } from '@redwagon/rw-print'

// some styles for the element (optional)

const rw = new RwPrint()

// you can use styles with css text or cdn 
const styles = {
    cssText:{
        header:{
            font-size: '10px';
        },
        table td: {
            boder: '1px solid gray' 
        }
    }
}

const styles = {
    cdn: 'https://cdn.primaverahealthcare.com/styles/css/print-patient.css'
}

const header = {
    title: 'Test for print header',
    logoUrl: 'https://cdn.primaverahealthcare.com/static/images/logo.svg'
}

const footer = {
    patientName: 'Nicolas Restrepo',
    printedBy: 'Rolian Ruiz',
    logoUrl: 'https://cdn.primaverahealthcare.com/static/images/logo.svg'
}

const config = {
    styles,
    header,
    footer
}
const template = document.getElementById('mytable'); //item in dom o template custom 

// opens the "print dialog" of your browser to print the element
rw.print(template, config )

API

Methods

constructor

The constructor supports an optional parent element (HTMLElement) where the printable element will be appended. Default value is window.document.body.

Example:

const rw = new RwPrint( document.getElementById('parent') )

Interfaces:

    interface IStyles {
        cssText?: string;
        cdn?: string;
    }

    interface IFooterData {
        printedBy: string;
        patientName?: string;
        logoUrl: string;
    }
    interface IHeaderData {
        title: string;
        logoUrl: string;
    }
    interface IConfig {
        styles?: IStyles;
        header?: IHeaderData;
        footer?: IFooterData;
    }

print

Function to print the current HTMLElement.

Params:

  • el: The HTMLElement to print.
  • config: Optional to configure styles, footer and header._
    • styles:
      • cssText: Optional CSS Text to add custom styles to the current element.
      • cdn: Optional CDN Styles in this cdn use css styles minified
    • header: Optional header config
      • title: Required title
      • logoUrl: Optional logoUrl from cdn
    • footer: Optional footer config
      • patientName: Optional patient name
      • printedBy: Required name of the user who printed document
      • logoUrl: Optional logoUrl from cdn
  • callback: Optional callback function. Inside the callback it's necessary to call launchPrint(win) to trigger the printing.
    • win: Window reference.
    • doc: Document reference.
    • node: HTMLElement reference.
    • launchPrint(win): Function to trigger the printing on demand.
  1. Basic example:
const rw = new RwPrint()

const styles = {
    cdn: 'https://cdn.primaverahealthcare.com/styles/css/print-patient.css'
}

const header = {
    title: 'Test for print header',
    logoUrl: 'https://cdn.primaverahealthcare.com/static/images/logo.svg'
}

const footer = {
    patientName: 'Nicolas Restrepo',
    printedBy: 'Rolian Ruiz',
    logoUrl: 'https://cdn.primaverahealthcare.com/static/images/logo.svg'
}

const config = {
    styles,
    header,
    footer
}
rw.print(document.getElementById('h1'), config)

getIFrame

Returns the current HTMLIFrameElement reference.

Events

const { contentWindow } = rw.getIFrame()

contentWindow.addEventListener('beforeprint', () => console.log('before print!'))
contentWindow.addEventListener('afterprint', () => console.log('after print!'))

License

MIT license