|
@@ -14,9 +14,6 @@ import 'echarts/lib/component/tooltip';
|
|
|
import jspdf from 'jspdf';
|
|
|
import html2canvas from 'html2canvas';
|
|
|
|
|
|
-window.html2canvas = html2canvas;
|
|
|
-window.jspdf = jspdf;
|
|
|
-
|
|
|
import './info.less';
|
|
|
|
|
|
const getDateValue = (val) => {
|
|
@@ -301,23 +298,15 @@ const evaluateInfo = React.createClass({
|
|
|
html2canvas(document.getElementsByClassName('report-pages'), {
|
|
|
background: '#fff',
|
|
|
onrendered: function (canvas) {
|
|
|
-
|
|
|
- var contentWidth = canvas.width;
|
|
|
- var contentHeight = canvas.height;
|
|
|
-
|
|
|
- var pageHeight = contentWidth / width * height;
|
|
|
-
|
|
|
- var leftHeight = contentHeight;
|
|
|
-
|
|
|
- var position = 0;
|
|
|
-
|
|
|
- var imgWidth = width;
|
|
|
- var imgHeight = width / contentWidth * contentHeight;
|
|
|
-
|
|
|
- var pageData = canvas.toDataURL('image/jpeg', 1.0);
|
|
|
-
|
|
|
- var pdf = new jspdf('', 'pt', [width, height]);
|
|
|
-
|
|
|
+ let contentWidth = canvas.width,
|
|
|
+ contentHeight = canvas.height,
|
|
|
+ pageHeight = contentWidth / width * height,
|
|
|
+ leftHeight = contentHeight,
|
|
|
+ position = 0,
|
|
|
+ imgWidth = width,
|
|
|
+ imgHeight = width / contentWidth * contentHeight,
|
|
|
+ pageData = canvas.toDataURL('image/jpeg', 1.0),
|
|
|
+ pdf = new jspdf('', 'pt', [width, height]);
|
|
|
while (leftHeight > 0) {
|
|
|
pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
|
|
|
leftHeight -= pageHeight;
|
|
@@ -326,7 +315,6 @@ const evaluateInfo = React.createClass({
|
|
|
pdf.addPage();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
pdf.save('EvaluationReport.pdf');
|
|
|
this.setState({
|
|
|
exporting: false
|