Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ng-print

burasuk33GPL-3.01.0.1TypeScript support: included

Directive for print content of any HTML element

print, angular, library, ng-print, directive, angular-print

readme

NgPrint

Directive for printing any HTML element. For Angular 2+.

Usage

  1. Install

npm install ng-print

  1. Import into main module
import {NgxPrintModule} from 'ng-print';

@NgModule({

imports: [NgPrintModule]

})
export class AppModule {
}
  1. Add directive to template
<div #printThis> 
  <!--Element you want to print-->
</div>

<!-- 'printThis' is template reference -->
<button type="button" [elementToPrint]="printThis" ngPrint>Print table</button>

This directive create iframe on bottom of document and copy all html head into it, so the styles in your angular app are imported into iframe.

Printed element looks pretty much the same as in your app.

Created iframe is set to display:none.

After print or cancelation, it removes created iframe.

This library was generated with Angular CLI version 8.0.3.