title: Convert a Word Document into PDF in NodeJS
body: <p>I have a requirement to convert a complex word document into .pdf file with nodejs. I have tried multiple wrapper modules written upon unoconv and unoconv module directly but stumbled upon ENONET error even after trying all the fixes in respective repos.</p>
  
  <p>I have applied mammothjs and tried converting it to html and then to .pdf and some other libs which does the same in background but they don't recognize Indentations spaces table formats in the document they are read as plain text. </p>
  
  <p>I have also tried <a href="https://portal.reporting.cloud/Documentation/Reference/" rel="nofollow noreferrer">Reporting Cloud</a> web API but I'm looking for a solution which can be done within my application itself.</p>
  
  <p>I have seen some people suggesting to use libreOffice command but even that doesn't convert the word exactly. </p>
  
  <p>My unoconv implementation..</p>
  
  <pre><code>var outputTempFile = path.resolve(__dirname, '/companyDocuments/'+utils.getSystemTime()+'_output.docx');
  var outputFile = path.resolve(__dirname, '/companyDocuments/fac_'+organization.organizationId+'__manual.pdf');
  
  fs.writeFileSync(outputTempFile, buf);
  
  unoconv.convert(outputTempFile,'pdf',function(err,result){
     if(err){
       console.log(err);
     }
  fs.writeFile(outputFile, result);
  });
  </code></pre>
  
  <p>I have tried a npm module lib-unoconv which generates pdf but because the result object from the convert function is undefined so my pdf is getting corrupted/not readable.</p>