Convert PDF Page to Image in Nodejs using Aspose.PDF REST API

Hi,

I’m trying the example you have here using node.js
Converting Document Pages to Image Format|Documentation

but the image is not created. Instead i’m getting this error:
{“Message”:“Error ‘The specified file does not exist.’, Bucket ‘afc-filestorage’, FilePath ‘9441/65994b98-088d-4aca-b51d-ba2c724ef04f/3.pdf’”}

I’ve seen another post related to this…but one of the last answers says it was fixed already?

Thanks!

The code i’m talking about is this one:

var fs = require(“fs”);
var AsposeCloud = require(“asposecloud”);
var aspose = new AsposeCloud({
appSID: “Get it from https://dashboard.aspose.cloud/”,
appKey: “Get it from https://dashboard.aspose.cloud/”,
baseURI: “http:[//api.aspose.cloud/v1.1/](https://api.aspose.cloud/v1.1/)”
});
var pdf = aspose.Pdf();

var file = “Document1.pdf”;
var page = 1;
var format = “png”;
var outputFile = “Page1.png”;

pdf.convertToImage(file, page, format, function(result) {
fs.writeFileSync(outputFile, result);
console.log(“File saved:”, outputFile);
});

Hi Alejandro,


Thanks for using our API’s.

Please share the input files causing this problem, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Hi,

thanks for getting back to me.

Actually, it happens with any pdf.

You can try it with this one:
http://ga.berkeley.edu/wp-content/uploads/2015/02/pdf-sample.pdf

I just gave it a try and i got the same error.

Thanks!

Hi,

You can guess from the error description that your input file is not present on Aspose for Cloud storage. You need to upload file to Aspose for Cloud storage to run this example. Please check file upload example to upload a file and then run this code.

Best Regards,

Great! thank you so much.

That wasn’t part of the original example and since i’m rather new to node.js, i didn’t think that was necessary.

The complete example would be like this, in case somebody need it.

Thanks again.

var fs = require(“fs”);

var AsposeCloud = require(“asposecloud”);

var aspose = new AsposeCloud({

appSID: ‘’,

appKey: ‘’,

baseURI: ‘[Aspose Cloud WEB API](http://api.aspose.cloud/v1.1/)’

});

var pdf = aspose.Pdf();

var storage = aspose.Storage();

var localFile = “sample.pdf”;

storage.uploadFile(localFile, “”, “”, function (result) {

console.log(result);

var page = 1;

var format = “png”;

var outputFile = “Page1.png”;

pdf.convertToImage(localFile, page, format, function (result) {

fs.writeFileSync(outputFile, result);

console.log(“File saved:”, outputFile);

});

});

Hi,

Good to know it is working for you and thanks for sharing your code and experience with us.

Best Regards,

@aleromer

We want to update you that, now you do not need to use Aspose.Storage Cloud API for storage related operations. Because, now latest version of Aspose.PDF Cloud API provides its own API methods to work with Files and Folders. Please check Aspose.PDF Cloud SDK for Node.js for sample unit tests.