🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
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
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

ngx-print-element

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

2.0.19-beta.2
unpublished
Source
npm
Version published
Weekly downloads
1K
-33.79%
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 there is an element you don't want to display you can add the class print-none

<table id="demo" class="table table-bordered">
  <tr>
    <th>No</th>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr class="print-none" style="background: greenyellow"><!-- No print -->
    <td>01</td>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>02</td>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
  <tr>
    <td>03</td>
    <td>AIS Playground</td>
    <td>Nakhon Pathom</td>
    <td>Thailand</td>
  </tr>
  <tr class="print-none" style="background: greenyellow"> <!-- No print -->
    <td>04</td>
    <td>FPT Software</td>
    <td>Cau Giay</td>
    <td>Vietnamese</td>
  </tr>
</table>

1# The first way doesn't need configuration

<button [print]="['demo']">Print</button>

2# The second way needs configuration

<button [print]="['demo', config]">Print</button>
import { Component } from '@angular/core';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  public config = {
    printMode: 'template-popup',
    popupProperties: 'toolbar=yes,scrollbars=yes,resizable=yes,top=0,left=0,fullscreen=yes',
    pageTitle: 'Hello World',
    templateString: '<header>I\'m part of the template header</header>{{printBody}}<footer>I\'m part of the template footer</footer>',
    stylesheets: [{ rel: 'stylesheet', href: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' }],
    styles: ['td { border: 1px solid black; color: green; }', 'table { border: 1px solid black; }', 'header, table, footer { margin: auto; text-align: center; }']
  }
}

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) {}

  onPrint(id: string) {
    this.print.print(id).subscribe(console.log);
  }
}
<p id="demo">Angular-Print</p>
<button (click)="onPrint('demo')">Print</button>

API Documentation

FieldDescriptionTypeDefault
htmlTypedomObj,textstring'domObj'
printModetemplate,template-popupstringtemplate
popupPropertiesOptions window.openstringblank
pageTitlePrint titlestringblank
templateStringhtmlstringblank
stylesheetsSet the external style sheet for printingobject or object[]null
stylesSet the internal style sheet for printingstring or string[]null

Support versions

Support versions
Angular 62.0.19

Author Information

Author Information
AuthorDaiDH
Phone+84845882882
CountryVietnam

If you want donate for me!

Bitcoin

Vietnam

MIT License. Copyright (c) 2022 DaiDH

Keywords

ng

FAQs

Package last updated on 21 May 2023

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