|
|
|
|
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
import * as jspdf from 'jspdf'; |
|
|
|
|
|
import html2canvas from 'html2canvas'; |
|
|
|
|
|
|
|
|
|
|
|
export type Star = 0 | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 4.5 | 5; |
|
|
export type Star = 0 | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 4.5 | 5; |
|
|
export const STAR_CLASS_MAP = { |
|
|
export const STAR_CLASS_MAP = { |
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
ngOnInit(): void { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public captureScreen() { |
|
|
|
|
|
debugger; |
|
|
|
|
|
let data = document.getElementById('contentToConvert'); |
|
|
|
|
|
html2canvas(data).then(canvas => { |
|
|
|
|
|
// Few necessary setting options |
|
|
|
|
|
let imgWidth = 208; |
|
|
|
|
|
let pageHeight = 295; |
|
|
|
|
|
let imgHeight = canvas.height * imgWidth / canvas.width; |
|
|
|
|
|
let heightLeft = imgHeight; |
|
|
|
|
|
|
|
|
|
|
|
const contentDataURL = canvas.toDataURL('image/png') |
|
|
|
|
|
let pdf = new jspdf('p', 'mm', 'a4'); // A4 size page of PDF |
|
|
|
|
|
let position = 0; |
|
|
|
|
|
pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight) |
|
|
|
|
|
pdf.save('MYPdf.pdf'); // Generated PDF |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getStarClass(starCount: Star, starIndex: number) { |
|
|
getStarClass(starCount: Star, starIndex: number) { |
|
|
const starSizes: number[] = []; |
|
|
const starSizes: number[] = []; |