node html-pdf creates pdf with no/blank content

298
May 31, 2017, at 10:06 AM

I am having trouble creating a pdf that has content. I am running node/express with html-pdf to take a react Dom node converted to a string, then piped back to the client-side to save the Blob as a pdf. That pdf is blank, but has multiple pages, indicating that the content is taking up space.

The Request going in:

{"html":"<html><meta charset=\"utf8\"><title>Report</title>
<body><div>Text test</div></body></html>","filename":"report"}

The PDF creation:

    pdf.create(req.body.html, {
            format: 'letter'
        , border: { top: '0.6in', right: '0.6in', bottom: '0.6in', left: '0.6in'}
        , phantomArgs: ["--ignore-ssl-errors=yes"]
    }).toStream(function(err, stream){
        if(err){
            utils.standardError(res, err)
        }
        else{
            res.setHeader('Last-Modified', utilities.httpDateString(new Date()))
            res.setHeader('Content-disposition', 'attachment; filename='+req.body.filename)
            res.setHeader('Content-Type', 'application/pdf')
            // res.setHeader('Response-type', "arrayBuffer")
            // res.setHeader('Content-length', buffer.length)
            res.status(200)
            // res.send(buffer)
            stream.pipe(res)
        }
    })

I am then saving the Blob as such:

saveAs(
    new Blob([response], {type: "application/pdf;charset=utf-8"}),
        'report.pdf'
)

When i run the saved pdf through a validator I get all kinds of errors pertaining to its formatting. What am i doing wrong?

READ ALSO
Calling node controller from node controller, how to send the data?

Calling node controller from node controller, how to send the data?

I have a priceController node which is a lot of code called by angular in many places

202
Get certain part of string in javascript

Get certain part of string in javascript

I am making a Discord bot, and it has a method called addCmd, which allows me to make it modularThe problem lies where I attempt to detect the command, and see if it is valid

323
How to use the result of child_process spawn in a request (getting ENOENT)

How to use the result of child_process spawn in a request (getting ENOENT)

I get an ENOENT when executing the js file containing the exact code belowAnd I don't know how to fix this

296