SelectPdf Html To Pdf

חינם
על ידי Tom Williams | מְעוּדכָּן a month ago | Business
פּוֹפּוּלָרִיוּת

5.4 / 10

חֶבִיוֹן

276ms

רמת שירות

100%

Health Check

N/A

חזרה לכל הדיונים

Api writing blank PDF file

Rapid account: Littulb
littulb
9 years ago

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 years ago

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

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות