Skip to content
Snippets Groups Projects
Commit 0bbe1037 authored by Ramesh Kumar's avatar Ramesh Kumar
Browse files

TMSS-986: Scaling report image to page size and fetching multiple cycle report added.

parent ce1d3633
No related branches found
No related tags found
1 merge request!646Resolves TMSS-986
......@@ -57,7 +57,7 @@ class CycleReportIntro extends Component {
return(
<React.Fragment>
<>
<div className="report-div" id={`intro-report-div`}>
<div className="report-div1" id={`intro-report-div`}>
<div id={`intro-cycle-details`}>
<h2 style={{textAlign: "center", marginBottom:"25px"}}>Report statistics for Cycles </h2>
<div className="p-grid">
......
......@@ -145,17 +145,16 @@ class CycleReportMain extends Component {
// Get the div heights of each page of the report
let divHeights = _.map(reportDivs, 'clientHeight');
// Create a PDF document with landscape orientation, 1st report div width and the max height of all report divs in pixels
const pdf = new jsPDF('l', 'px', [ (reportDivs[0].clientWidth+50), (reportDivs[0].clientHeight+50)]);
const pdf = new jsPDF('l', 'px', [ (reportDivs[0].clientWidth+100), (reportDivs[0].clientHeight+100)]);
let pageIndex = 0;
// Draw each report in canvas and create image of the canvas before saving the pdf
for (const reportName of _.keys(REPORT_VARIABLE_MAP)) {
// Create page for each project
if (pageIndex > 0) {
const reportDiv = reportDivs[pageIndex+1];
pdf.addPage([reportDiv.clientWidth+50, reportDiv.clientHeight+50], pageIndex===5?'p':'l');
pdf.addPage([reportDivs[0].clientWidth+100, reportDivs[pageIndex].clientHeight+100], pageIndex===5?'p':'l');
}
const projectCanvas = await html2canvas(document.getElementById(`${reportName}`));
pdf.addImage(projectCanvas.toDataURL('image/jpeg'), 'JPEG', 50, 50);
pdf.addImage(projectCanvas.toDataURL('image/jpeg'), 'JPEG', 50, 50, reportDivs[pageIndex].clientWidth, reportDivs[pageIndex].clientHeight);
pageIndex++;
}
// To open the generated PDF in new window
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment