Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import { ReportingEngineService } from "../../reportingEngine.

service";
import { Component } from "@angular/core";
import html2canvas from "html2canvas";
import { BehaviorSubject } from "rxjs";
import { ReportTypes } from "src/interfaces";

@Component({
selector: "report-logbook",
templateUrl: "./reportLogbook.component.html",
styleUrls: ["./reportLogbook.component.scss"],
})
export class ReportLogbookComponent {

//#region Class properties

ReportTypes = ReportTypes;

isPrinting:boolean = false;

public base64UrlSrc$ = new BehaviorSubject<string>(null);

//#endregion

constructor(public reportEngine: ReportingEngineService) {}

printReport(element: HTMLElement) {

// Assuming this.reportEngine.map is your mapbox container


const mapContainer = document.getElementById('report-map');

html2canvas(mapContainer).then(canvas => {
// Convert canvas to base64 image
const img = canvas.toDataURL('image/png');
this.base64UrlSrc$.next(img);

setTimeout(() => {
this.isPrinting = true; // To be able to set printable font temporarily
this.reportEngine.printLocalContainerToPDFAsA4(element);
this.isPrinting = false;
}, 2000);
});

}
}

You might also like