Convert PDF document to DOCX and download DOCX in Node.js error

i am trying to convert a pdf to a docx without storing the file to the cloud but im getting as error saying PutConvertDocument is not a function.

here is my code:


try {

            // Invoke Aspose.Pdf Cloud SDK API to convert PDF to DOCX without cloud storage

            pdfApi.PutConvertDocument('docx', null, null, profile, function(responseMessage) {

                    assert.equal(responseMessage.status, 'OK');

                    // Save converted format file from response

                    var outfilename = "profile_out.docx"

                    res.send(JSON.stringify(response))

            });

        }

        catch (e)

        {

          console.log("exception in example");

          console.log(e);

        }

is there any other way to do the conversion?

@emil_chigu

I am afraid currently Aspose.PDF Cloud does not have a completely storage independent API for PDF to DOCX/DOC conversion. However, PutPdfInRequestToDoc API method converts PDF document form request body to storage.

PUT ​/pdf​/convert​/doc Converts PDF document (in request content) to DOC format and uploads resulting file to storage.

thank you very much. I can successfully upload the file and convert it, im now facing trouble when trying to download it. i Get an internal error with the code below.

const name = `Profile_${Math.floor(Math.random() * 1000)}.doc`;
		

		await pdfApi
			.putPdfInRequestToDoc(name, null, null, null, null, null, null, null, null, null, profile)
			.then((result) => {
				
			
			});

			try{
				pdfApi.getDocument(name, null, "").then((result) => {
				res.send(JSON.stringify(result.response));
			})
		}catch (e){
		console.log("exception in example");
		console.log(e);
			}

@emil_chigu

You need to use the DownloadFile API method to download files from storage. Please check the sample Node.js code for your reference.

 ...
 const resultName = "MergingResult.pdf";
 ....
 ....  

//Download file
const localPath = "C:/Temp/" + resultName;

pdfApi.downloadFile(resultName).then((result) => {    
    console.log(result.response.statusCode);    
    console.log(result.body.byteLength);    
	fs.writeFileSync(localPath, result.body);
    console.log("File Downloaded");    
}).catch(function(err) {
    // Deal with an error
    console.log(err);
});