'Problem with PDF files on Node.js and Typescript (blank pages)
I'm trying to get PDF files from the internet and save them locally in a specific folder. It works well but the PDF files all have blank pages, I think it's an encoding problem but not sure. I'm stuck, can you help me?
await request({uri: file.url, headers: { 'Content-type' : 'application/pdf' }} , async (error, response, body) => {
if (!error && response.statusCode === 200) {
if(file.isDuplicates) {
await fs.writeFileSync(`${path}\\generic\\${file.name}`, body, {'encoding': 'utf8'});
} else {
await fs.writeFileSync(`${path}\\${file.productId}\\${file.name}`, body, {'encoding': 'utf8'});
}
}
});
Thank you ;)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
