I am attempting to turn a png image into a pdf using the nodejs library for the cloud service.
I am attempting to use the PutCreate and GetImageSaveAs functions to convert an image to pdf and then save it. I have also tried with GetDownload and did not find that helpful.
What is happening is I am receiving an jpg image back instead of a pdf and the image has a red x going from corner to corner. Here is the code I am using.
storageApi.PutCreate(fileName, null, null, file.path, function(response) {
if (response.code !== 200) {
console.log(‘Uploading Error’, response.body)
return deferred.reject(‘Unable to upload document.’)
}
imagingApi.GetImageSaveAs(fileName, ‘pdf’, pdfName, null, null, function(response) {
if (response.code !== 200) {
console.log(‘Converting Error’, response.body.toString(‘utf8’))
return deferred.reject(‘Unable to convert document.’)
}
console.log(response.body)
var writeStream = fs.createWriteStream(pdfPlace);
writeStream.write(response.body);
deferred.resolve(pdfName);
});
});