🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

ngx-print-element

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-print-element

This library is built to provide a solution for printing on html elements.

2.0.10
Source
npm
Version published
Weekly downloads
1.5K
6.81%
Maintainers
1
Weekly downloads
 
Created
Source

ngx-print-element

This library is built to provide a solution for printing on html elements.
This is the stackblitz.

Logo

Installation

Install ngx-print-element from npm:

npm install ngx-print-element --save

Add wanted package to NgModule imports:

import { NgxPrintElementModule } from 'ngx-print-element';
@NgModule({
    imports: [
        NgxPrintElementModule,
    ]
})

Need to import css

@import '~ngx-print-element/styles.css';

Printing data sheet with id is up to you.
If somewhere you don't want to display you can use class print-none

1# The first way doesn't need configuration

<table id="demo">
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr class="print-none">
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
</table>

<ngx-print-element #element="element">
  <button (click)="element.print('demo')">Print</button>
</ngx-print-element>

2# The second way needs configuration

<table id="demo">
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr class="print-none">
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
</table>
<ngx-print-element #element="element">
  <button (click)="element.print('demo', {printMode: 'template', pageTitle: 'Hello World'})">Print</button>
</ngx-print-element>

Services

import { Component } from '@angular/core';
import { NgxPrintElementService } from 'ngx-print-element';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  constructor(public print: NgxPrintElementService) {}
}
<p id="demo">Angular-Print</p>
<button (click)="print.print('demo')">Print</button>

API Documentation

FieldDescriptionTypeDefault
htmlTypeSet element type domObj,textstring'domObj'
printModeWay of printingstring template,template-popup-
pageTitlePrint titlestring-
templateStringPrint template--
popupPropertiesSet the new window.open parametersstring-
stylesheetsSet the external style sheet for printing--
stylesSet the internal style sheet for printing--

Support versions

Versions
Angular 13
Angular 12
Angular 11
Angular 10
Angular 9
Angular 8


Author: DaiDH, Tel: 0845882882

License

MIT License. Copyright (c) 2021 DaiDH

Keywords

ngx

FAQs

Package last updated on 07 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts