Open boasbakker opened 1 year ago
@boasbakker
Please check out the sample code to convert PDF to DOCX without cloud storage. Hopefully, it will help you accomplish the task. Otherwise, please feel free to post your questions or concerns in our free forum.
// load the module
var GroupDocs = require('groupdocs-conversion-cloud');
var fs = require('fs');
// get your appSid and appKey at https://dashboard.groupdocs.cloud (free registration is required).
var appSid = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx";
var appKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const convertDocumentOnline = async () => {
// construct Api
const api = GroupDocs.ConvertApi.fromKeys(appSid, appKey);
//const convertOptions = new GroupDocs.DocxConvertOptions();
const file = fs.readFileSync('C:/Temp/tes.pdf');
const localPath = "C:/Temp/tes.docx";
let loadOptions = new GroupDocs.PdfLoadOptions();
loadOptions.format = 'pdf';
let convertOptions = new GroupDocs.ConvertOptions();
convertOptions.pageSize = GroupDocs.WordProcessingConvertOptions.PageSizeEnum.Custom;
try {
let request = new GroupDocs.ConvertDocumentDirectRequest("docx",file,undefined,undefined,loadOptions,convertOptions);
console.log(request);
let result = await api.convertDocumentDirect(request);
//console.log(result);
fs.writeFileSync(localPath, result);
} catch (err) {
throw err;
}
}
convertDocumentOnline()
.then(() => {
console.log("Document converted successfully");
})
.catch((err) => {
console.log("Error occurred while converting the document:", err);
})
What is the appSid and appKey variale? I only have the Client Id and Client Secret variables in my dashboard
I also get this error: [{ "resource": "", "owner": "typescript", "code": "2339", "severity": 8, "message": "Property 'pageSize' does not exist on type 'ConvertOptions'.", "source": "ts", "startLineNumber": 212, "startColumn": 16, "endLineNumber": 212, "endColumn": 24 }]
When removing the line: convertOptions.pageSize = GroupDocs.WordProcessingConvertOptions.PageSizeEnum.Custom; And using the clientID as appSid and the clientSecret as appKey, I get this error: Error occurred while converting the document: { message: 'Error while parse server error: SyntaxError: Unexpected token < in JSON at position 0' } On the GroupDocs Dashboard, the conversion shows up as successful though
@boasbakker Please share your credentials in a private message with us. We will investigate the issue and guide you.
@tilalahmad The link you sent for sending private messages is for the forums, not for GitHub
Hello, I am trying to convert large PDF files to DOCX or RTF using the GroupDocs Cloud API in Node.js. However, I keep running into issues. I want to upload a locally stored file, convert it to a docx or rtf file, and then download it to a local folder again. This is my current code:
When running this code, the program gets stuck and nothing happens After a very long time I get this response: { message: 'Error while parse server error: SyntaxError: Unexpected token < in JSON at position 0' } How can I fix this?