SelectPdf Html To Pdf

FREE
By Tom Williams | Updated vor einem Monat | Business
Popularity

6.8 / 10

Latency

643ms

Service Level

100%

Health Check

N/A

Back to All Discussions

Api writing blank PDF file

Rapid account: Littulb
littulb
vor 9 Jahren

The api is writing a blank pdf file. This is my code using Node.js

unirest.get(“https://selectpdf-selectpdf-html-to-pdf-v1.p.mashape.com/?key=0d423b5d-cdd6-47bc-bab4-112be88d80a0&html=”+html)
.header(“X-Mashape-Key”, “9oYSCDWU3SmshO6IWVZYpgFxzTC9p1zE7mCjsnsrNSyO9dZIKE”)
.end(function (result) {
console.log(result.status, result.headers);
fs.writeFileSync(“public/Sample.pdf”, result.body);
res.redirect("/");
});

Rapid account: Selectpdf
selectpdf Commented vor 9 Jahren

The response body should be binary data. The code should look like this:

unirest.get(“https://selectpdf-selectpdf-html-to-pdf-v1.p.mashape.com/?key=0d423b5d-cdd6-47bc-bab4-112be88d80a0&html=”+html)
.encoding(“binary”)
.header(“X-Mashape-Key”, “9oYSCDWU3SmshO6IWVZYpgFxzTC9p1zE7mCjsnsrNSyO9dZIKE”)
.end(function (result) {
console.log(result.status, result.headers);
if (result.statusCode == 200) {
fs.writeFileSync(“Sample.pdf”, result.body, “binary”);
}
});

Join in the discussion - add comment below:

Login / Signup to post new comments