-import {Component, OnInit, TemplateRef} from '@angular/core';
+import {Component, OnInit, TemplateRef, ElementRef} from '@angular/core';
import {EgPrintService, EgPrintRequest} from './print.service';
@Component({
template: TemplateRef<any>;
context: any;
- constructor(private print: EgPrintService) {}
+ constructor(
+ private elm: ElementRef,
+ private printer: EgPrintService
+ ) {}
ngOnInit() {
- this.print.onPrintRequest$.subscribe(
+ this.printer.onPrintRequest$.subscribe(
printReq => this.handlePrintRequest(printReq));
}
handlePrintRequest(printReq: EgPrintRequest) {
this.template = printReq.template;
- this.context = printReq.context;
+ this.context = printReq.contextData;
- // TODO: hatch
- setTimeout(() => window.print());
+ // Give the template a chance to render inline before printing
+ setTimeout(() => this.dispatchPrint(printReq));
}
+
+ dispatchPrint(printReq) {
+ /*
+ if (this.hatch.useHatchForPrinting) {
+ this.printViaHatch();
+ } else {
+ */
+ window.print();
+ //}
+ }
+
+ /*
+ printViaHatch(printReq) {
+ this.hatch.print({
+ printContext: printReq.printContext,
+ content: this.elm.nativeElement.innerHTML
+ });
+ }
+ */
+
}
border-left: 8px solid #FA787E;
}
+
+
+/**
+ * Only display the print container when printing
+ */
#eg-print-container {
display: none;
}
-
@media print {
- head { display: none; } /* just to be safe */
- body div:not([id="eg-print-container"]) { display:none }
- div { display: none }
- #eg-print-container { display: block }
- #eg-print-container div { display: block }
- #eg-print-container pre { border: none }
+ head {display: none} /* just to be safe */
+ body div:not([id="eg-print-container"]) {display: none}
+ div {display: none}
+ #eg-print-container {display: block}
+ #eg-print-container div {display: block}
+ #eg-print-container pre {border: none}
}