SelectPdf Html To Pdf

GRATUITO
Por Tom Williams | Atualizado 한 달 전 | Business
Popularidade

5.3 / 10

Latência

276ms

Nível de serviço

100%

Health Check

N/A

Voltar para todas as discussões

Api writing blank PDF file

Rapid account: Littulb
littulb
9년 전

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 9년 전

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”);
}
});

Junte-se à discussão - adicione o comentário abaixo:

Efetue login / inscreva-se para postar novos comentários