It had an application with angular and firebase as well but it was a PDV
printed the requests as follows had a class or template for each type of request in that class had two methods one to draw the html that was going to be printed and the other to call the print window:
// relatorioPrinter.model.ts
export class RelatorioPrinter {
public impressao: string;
constructor(dados: any) {
this.paint(dados);
}
public print(): void {
const params = [
'',
'_blank',
'height=ALTURA_DO PDF,width=LARGURA_DO_PDF'
]
const popup = window.open(...params);
popup.document.open();
popup.document.write(this.impressao);
popup.document.close();
}
public paint(dados: any): void {
this.impressao = `<!DOCTYPE html>
<html>
<head>
<style>
/* SEU ESTILO AQUI */
</style>
</head>
<body onload="window.print()">`;
this.impressao += `SEU HTML AQUI ${dados.SEUS_DADOS_AQUI}`;
this.impressao += '</body></html>';
}
}
To use was simple:
// exemplo.component.ts
import { Component } from '@angular/core';
import { RelatorioPrinter } from 'app/models/relatorioPrinter';
@Component({
selector: 'app-exemplo',
templateUrl: './exemplo.component.html'
})
export class ExemploComponent {
public printer: RelatorioPrinter;
public constructor() {
const seuDados = {};
this.printer = new RelatorioPrinter(seuDados);
}
}
Well then I needed a more robust solution to compress many reports etc. but at first it helped me a lot.
I hope I helped :D
@Luiz Accept this answer (by clicking on the "right" symbol) if it answers your question, so others know that your problem has been solved.
– Rosário Pereira Fernandes