Downloaded pdf file and converted file is not openinig

image.png (24.6 KB)

@killerguy066

I am unable to notice while converting PDF to DOCX as following. Please share your sample code, we will look into the issue and guide you accordingly.

// load the module
var GroupDocs = require('groupdocs-conversion-cloud');
var fs = require('fs');

// get your ClientId and ClientSecret at https://dashboard.groupdocs.cloud (free registration is required).
var clientID = "xxxxxxxx-xxxxx-xxxxx-xxxxx-xxxxxxxxx";
var clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";


// construct Api
const api = GroupDocs.ConvertApi.fromKeys(clientID, clientSecret);
 
const file = fs.readFileSync('C:/Temp/02_pages.pdf');
const localPath = "C:/Temp/dummy_textstamp.docx";

const request = new GroupDocs.ConvertDocumentDirectRequest("docx",file,undefined,undefined);
console.log(request); 
 api.convertDocumentDirect(request)
                .then((result) => {    
    //console.log(result);    			    
fs.writeFileSync(localPath, result);
}).catch(function(err) {
    // Deal with an error
    console.log(err);
});

while downloading the file from dashboard the above error occur on opening file @tilal.ahmad

@killerguy066

As requested above, please share your sample code for investigation.

@tilal.ahmad
as i said earlier i am not downloading file with code but directly from dashboard section files.
image.png (19.8 KB)

@killerguy066

We are sorry for the confusion. It seems the output file stored in the cloud storage is not correct, so we are asking for the code used for the conversion. Or if you have some other different workflow, then please share the details.

var resourcesFolder = path.join(__dirname, `../${req.file.path}`);
    console.log(resourcesFolder, req.file);
    fs.readFile(resourcesFolder, (err, fileStream) => {
      if (err) {
        res.status(400).send(err);
      } else {
        // construct FileApi
        var fileApi = groupdocs_conversion_cloud.FileApi.fromConfig(
          configuration.config
        );
        // create upload file request
        var request = new groupdocs_conversion_cloud.UploadFileRequest(
          req.file.filename,
          fileStream,
          configuration.myStorage
        );
        // upload file
        fileApi.uploadFile(request);
        res.json({
          file_name: req.file.filename,
          original_name: req.file.originalname,
          message: "Uploaded Successfully!",
        });
      }
    });

code for uploading

let convertApi = groupdocs_conversion_cloud.ConvertApi.fromKeys(
  configuration.clientId,
  configuration.clientSecret
);

// define convert settings
let settings = new groupdocs_conversion_cloud.ConvertSettings();
settings.filePath = req.body.file_name; // input file path on the cloud
settings.format = "docx"; // output format
settings.outputPath = "output"; // output file folder on the cloud

// create convert document request
let request = new groupdocs_conversion_cloud.ConvertDocumentRequest(
  settings
);

// convert document
let result = await convertApi.convertDocument(request);
console.log("Document converted successfully: " + result[0].url);

code for conversion

@killerguy066

Thanks for sharing the details. So you are uploading a file(PDF) to cloud storage and then converting it to a DOCX file. I am unable to test your file uploading code due to missing references. After uploading your file to cloud storage, please download it using the dashboard and double check whether it is a valid document.