I'm generating a few html-based reports from my Meteor app. Everything works beautifully on my development machine, but when I push it up to the server, the pdf files that are returned are empty.
I've installed wkhtmltopdf 0.11 using the instructions in this post. I've also tried 0.9.9. When I go to print, I don't get any errors: just a pdf file without any content.
Any suggestions as to what I'm doing wrong would be appreciated!
Here's the code I'm using to generate the pdf:
Router.route('/reports/printHTML/:fileID?', {
name: 'reports.printHTML',
where: 'server',
action: function(){
var headers = {
'Content-type': 'application/pdf',
'Content-Disposition': "attachment; filename=space_report_" + this.params.fileID + ".pdf"
};
this.response.writeHead(200, headers);
var wk = Meteor.npmRequire('wkhtmltopdf');
var thisReport = PastReports.findOne({_id: this.params.fileID});
if(thisReport){
var html = thisReport.body + '<head><link rel="stylesheet" href="' + Meteor.absoluteUrl() + '/bootstrap.css"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.6/fullcalendar.min.css"></head>';
var r = wk(html, {pageSize:'letter', orientation:'Landscape', zoom:1, B:"5mm", L:"5mm", R:"5mm", T:"5mm",}).pipe(this.response);
} else {
console.log("No report to print: " + this.params.fileID);
}
} });