Help with PDFs (wkhtmltopdf + meteor + picker)


#1

I’m trying to get a report generated into a PDF. I’m using the combo of: meteorhacks:picker, classcraft:meteor-wkhtmltopdf, and meteorhacks:ssr.

I’m a massive noob at Node. So i’m pretty sure this is my lack of understanding but I just can’t find any information to help me with this particular idea. So please be easy on the critique, like I said I KNOW I DONT KNOW much here…

import wkhtmltopdf from 'wkhtmltopdf';
import fs from 'fs';
import Xvfb from 'xvfb';
const xvfb = new Xvfb();

Picker.route('/reports/all.posts/pdf/:_id', function (params, req, res, next) {
    // For testing I'm just hardcoding the postId
    let post = Postings.findOne({_id: 'WapgrumfH5ogkoztq'});

    // the possts are not denormalized well so I run one more query
    // to pull the business information associated with the post
    let business = Businesses.findOne(post.company);

    // honesty not sure why i have to do this, it just seemed to get me passed
    // wkhtmltopdf not finding X server
    xvfb.startSync();

    // Use ssr to create the subsPdf template
    SSR.compileTemplate('subsPdf',Assets.getText('reports/allSubmissions.html'));

    // Use ssr to render the template with some simple data
    let html = SSR.render('subsPdf', {title: post.title, business: business.name});

    // just one option for the pdf
    let options = { pageSize: 'letter' };

    // Not sure this is even how I get the PDF but it's what I have
    return wkhtmltopdf(html, options).pipe(fs.createWriteStream('report.pdf'));
});

The code has my notes in it. Here’s the error I get:

W20161122-14:36:20.087(-5)? (STDERR) Initializing built-in extension Generic Event                                                                                       Extension
W20161122-14:36:20.090(-5)? (STDERR) Initializing built-in extension SHAPE
W20161122-14:36:20.092(-5)? (STDERR) Initializing built-in extension MIT-SHM
W20161122-14:36:20.094(-5)? (STDERR) Initializing built-in extension XInputExtensi                                                                                      on
W20161122-14:36:20.099(-5)? (STDERR) Initializing built-in extension XTEST
W20161122-14:36:20.101(-5)? (STDERR) Initializing built-in extension BIG-REQUESTS
W20161122-14:36:20.103(-5)? (STDERR) Initializing built-in extension SYNC
W20161122-14:36:20.106(-5)? (STDERR) Initializing built-in extension XKEYBOARD
W20161122-14:36:20.111(-5)? (STDERR) Initializing built-in extension XC-MISC
W20161122-14:36:20.112(-5)? (STDERR) Initializing built-in extension SECURITY
W20161122-14:36:20.113(-5)? (STDERR) Initializing built-in extension XINERAMA
W20161122-14:36:20.115(-5)? (STDERR) Initializing built-in extension XFIXES
W20161122-14:36:20.119(-5)? (STDERR) Initializing built-in extension RENDER
W20161122-14:36:20.120(-5)? (STDERR) Initializing built-in extension RANDR
W20161122-14:36:20.131(-5)? (STDERR) Initializing built-in extension COMPOSITE
W20161122-14:36:20.132(-5)? (STDERR) Initializing built-in extension DAMAGE
W20161122-14:36:20.133(-5)? (STDERR) Initializing built-in extension MIT-SCREEN-SA                                                                                      VER
W20161122-14:36:20.135(-5)? (STDERR) Initializing built-in extension DOUBLE-BUFFER
W20161122-14:36:20.136(-5)? (STDERR) Initializing built-in extension RECORD
W20161122-14:36:20.137(-5)? (STDERR) Initializing built-in extension DPMS
W20161122-14:36:20.139(-5)? (STDERR) Initializing built-in extension Present
W20161122-14:36:20.141(-5)? (STDERR) Initializing built-in extension DRI3
W20161122-14:36:20.149(-5)? (STDERR) Initializing built-in extension X-Resource
W20161122-14:36:20.151(-5)? (STDERR) Initializing built-in extension XVideo
W20161122-14:36:20.152(-5)? (STDERR) Initializing built-in extension XVideo-Motion                                                                                      Compensation
W20161122-14:36:20.153(-5)? (STDERR) Initializing built-in extension SELinux
W20161122-14:36:20.154(-5)? (STDERR) Initializing built-in extension GLX
W20161122-14:36:20.597(-5)? (STDERR) 6 XSELINUXs still allocated at reset
W20161122-14:36:20.598(-5)? (STDERR) SCREEN: 0 objects of 256 bytes = 0 total byte                                                                                      s 0 private allocs
W20161122-14:36:20.600(-5)? (STDERR) DEVICE: 0 objects of 96 bytes = 0 total bytes                                                                                       0 private allocs
W20161122-14:36:20.605(-5)? (STDERR) CLIENT: 0 objects of 136 bytes = 0 total byte                                                                                      s 0 private allocs
W20161122-14:36:20.606(-5)? (STDERR) WINDOW: 0 objects of 32 bytes = 0 total bytes                                                                                       0 private allocs
W20161122-14:36:20.607(-5)? (STDERR) PIXMAP: 1 objects of 16 bytes = 16 total byte                                                                                      s 0 private allocs
W20161122-14:36:20.608(-5)? (STDERR) GC: 4 objects of 16 bytes = 64 total bytes 0                                                                                       private allocs
W20161122-14:36:20.609(-5)? (STDERR) CURSOR: 1 objects of 8 bytes = 8 total bytes                                                                                       0 private allocs
W20161122-14:36:20.610(-5)? (STDERR) TOTAL: 6 objects, 88 bytes, 0 allocs
W20161122-14:36:20.612(-5)? (STDERR) 1 PIXMAPs still allocated at reset
W20161122-14:36:20.613(-5)? (STDERR) PIXMAP: 1 objects of 16 bytes = 16 total byte                                                                                      s 0 private allocs
W20161122-14:36:20.614(-5)? (STDERR) GC: 4 objects of 16 bytes = 64 total bytes 0                                                                                       private allocs
W20161122-14:36:20.615(-5)? (STDERR) CURSOR: 1 objects of 8 bytes = 8 total bytes                                                                                       0 private allocs
W20161122-14:36:20.616(-5)? (STDERR) TOTAL: 6 objects, 88 bytes, 0 allocs
W20161122-14:36:20.617(-5)? (STDERR) 4 GCs still allocated at reset
W20161122-14:36:20.618(-5)? (STDERR) GC: 4 objects of 16 bytes = 64 total bytes 0                                                                                       private allocs
W20161122-14:36:20.619(-5)? (STDERR) CURSOR: 1 objects of 8 bytes = 8 total bytes                                                                                       0 private allocs
W20161122-14:36:20.620(-5)? (STDERR) TOTAL: 5 objects, 72 bytes, 0 allocs
W20161122-14:36:20.622(-5)? (STDERR) 1 CURSORs still allocated at reset
W20161122-14:36:20.623(-5)? (STDERR) CURSOR: 1 objects of 8 bytes = 8 total bytes                                                                                       0 private allocs
W20161122-14:36:20.624(-5)? (STDERR) TOTAL: 1 objects, 8 bytes, 0 allocs
W20161122-14:36:20.625(-5)? (STDERR) 1 CURSOR_BITSs still allocated at reset
W20161122-14:36:20.643(-5)? (STDERR) TOTAL: 0 objects, 0 bytes, 0 allocs
W20161122-14:36:39.496(-5)? (STDERR) 6 XSELINUXs still allocated at reset
W20161122-14:36:39.501(-5)? (STDERR) SCREEN: 0 objects of 256 bytes = 0 total bytes 0 private allocs
W20161122-14:36:39.502(-5)? (STDERR) DEVICE: 0 objects of 96 bytes = 0 total bytes 0 private allocs
W20161122-14:36:39.503(-5)? (STDERR) CLIENT: 0 objects of 136 bytes = 0 total bytes 0 private allocs
W20161122-14:36:39.504(-5)? (STDERR) WINDOW: 0 objects of 32 bytes = 0 total bytes 0 private allocs
W20161122-14:36:39.506(-5)? (STDERR) PIXMAP: 1 objects of 16 bytes = 16 total bytes 0 private allocs
W20161122-14:36:39.507(-5)? (STDERR) GC: 4 objects of 16 bytes = 64 total bytes 0 private allocs
W20161122-14:36:39.508(-5)? (STDERR) CURSOR: 1 objects of 8 bytes = 8 total bytes 0 private allocs
W20161122-14:36:39.509(-5)? (STDERR) TOTAL: 6 objects, 88 bytes, 0 allocs
W20161122-14:36:39.511(-5)? (STDERR) 1 PIXMAPs still allocated at reset
W20161122-14:36:39.513(-5)? (STDERR) PIXMAP: 1 objects of 16 bytes = 16 total bytes 0 private allocs
W20161122-14:36:39.514(-5)? (STDERR) GC: 4 objects of 16 bytes = 64 total bytes 0 private allocs
W20161122-14:36:39.515(-5)? (STDERR) CURSOR: 1 objects of 8 bytes = 8 total bytes 0 private allocs
W20161122-14:36:39.517(-5)? (STDERR) TOTAL: 6 objects, 88 bytes, 0 allocs
W20161122-14:36:39.519(-5)? (STDERR) 4 GCs still allocated at reset
W20161122-14:36:39.520(-5)? (STDERR) GC: 4 objects of 16 bytes = 64 total bytes 0 private allocs
W20161122-14:36:39.521(-5)? (STDERR) CURSOR: 1 objects of 8 bytes = 8 total bytes 0 private allocs
W20161122-14:36:39.522(-5)? (STDERR) TOTAL: 5 objects, 72 bytes, 0 allocs
W20161122-14:36:39.523(-5)? (STDERR) 1 CURSORs still allocated at reset
W20161122-14:36:39.524(-5)? (STDERR) CURSOR: 1 objects of 8 bytes = 8 total bytes 0 private allocs
W20161122-14:36:39.525(-5)? (STDERR) TOTAL: 1 objects, 8 bytes, 0 allocs
W20161122-14:36:39.526(-5)? (STDERR) 1 CURSOR_BITSs still allocated at reset
W20161122-14:36:39.527(-5)? (STDERR) TOTAL: 0 objects, 0 bytes, 0 allocs

Not even sure why all that is being outputted. Any assistance here would be appreciated. I’m over my head but with a few tips I think I can swim.


#2

Is it working in spite of those errors?


#3

Maybe you can find something useful in here: https://medium.com/@tomsp/server-side-render-pdfs-with-blaze-and-phantomjs-in-meteor-34b8b63522c#.ltk3brynl