Skip to content

Commit

Permalink
Dev: some more changes and testing with pdfjs
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Nov 24, 2016
1 parent 810b28f commit edad22d
Show file tree
Hide file tree
Showing 4 changed files with 3,396 additions and 4 deletions.
9 changes: 9 additions & 0 deletions application/config/third_party.php
Expand Up @@ -313,13 +313,22 @@
)
),

'es6promise' => array(
'basePath' => 'third_party.es6promise',
'js' => array(
'es6-promise.auto.min.js'
)
),

'jspdf' => array(
'basePath' => 'third_party.jspdf',
'js' => array(
'html2canvas.js',
'jspdf.debug.js'
// 'jspdf.min.js'
),
'depends' => array(
'es6promise',
'jquery',
'bootstrap'
)
Expand Down
15 changes: 11 additions & 4 deletions scripts/admin/statistics.js
Expand Up @@ -757,14 +757,21 @@ $(document).ready(function(){
$(openWindow.document).trigger('triggerReady');
console.log($('head'));
});

$('body').on('click','#action_js_export_to_pdf', function(){
var doc = new jsPDF();
var sizes = {};
var j = 0;
console.log("Getting the pdf");
$('#statisticsview').find('.statisticstable').each(function(i, table){
doc.addPage();
doc.fromHTML(table, 210, 297, {width: 590, elementHandlers: elementHandlers});

sizes[i] = {h: $(table).height(),w: $(table).width()}
html2canvas(table).then(function(canvas) {
doc.addPage();
var imgData = canvas.toDataURL("image/png");
doc.addImage(imgData, 'PNG', sizes[j].w, sizes[j].h, 210, 297);
var dataurl = doc.output('dataurlnewwindow');
j++;
});
});
var dataurl = doc.output('dataurlnewwindow');
});
});
1 change: 1 addition & 0 deletions third_party/es6promise/es6-promise.auto.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit edad22d

Please sign in to comment.