1.0.1 • Published 5 years ago

ng-print v1.0.1

Weekly downloads
74
License
GPL-3.0
Repository
github
Last release
5 years ago

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.