title: Unable to decrypt PDF in node using node-qpdf
body: <p>We need to decrypt the password protected PDF file using node.
  We are using the node-qpdf. Here is our scenario.</p>
  
  <p>1). We are getting the password protected PDF file as input.
  2). using the QPDF , with available password ,we are trying to decrypt it.
  3). At the end we are getting the corrupted PDF file.</p>
  
  <p>We are following the given link for reference : 
  a). <a href="https://www.npmjs.com/package/node-qpdf" rel="nofollow noreferrer">https://www.npmjs.com/package/node-qpdf</a></p>
  
  <p>Under decryption section, we can see the below code :</p>
  
  <pre><code>var qpdf = require('node-qpdf');
  qpdf.decrypt(localFilePath, 'YOUR_PASSWORD_TO_DECRYPT_PDF', outputFilePath);
  
  localFilePath = './myInputFile_WithPassword.pdf'
  YOUR_PASSWORD_TO_DECRYPT_PDF = 'test'
  outputFilePath = './myoutfileWith_NopasswordProtection.pdf'
  </code></pre>
  
  <p>After running the same we get the error as : </p>
  
  <pre><code>TypeError: callback is not a function
  at handleError (/home/runner/node_modules/node-qpdf/index.js:141:5)
  at Socket.&lt;anonymous&gt; (/home/runner/node_modules/node-qpdf/index.js:124:5)
  at Object.onceWrapper (events.js:286:20)
  at Socket.emit (events.js:198:13)
  at Socket.EventEmitter.emit (domain.js:448:20)
  at addChunk (_stream_readable.js:287:12)
  at readableAddChunk (_stream_readable.js:268:11)
  at Socket.Readable.push (_stream_readable.js:223:10)
  at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  </code></pre>
  
  <p>For callback issue we have also tried to change the code as  :</p>
  
  <pre><code>    qpdf.decrypt(localFilePath,'YOUR_PASSWORD_TO_DECRYPT_PDF', (res)=&gt;{
      console.log(res);
      fs.createWriteStream(outputFilePath)       
       });
  </code></pre>
  
  <p>But getting error as : </p>
  
  <pre><code>"**Error: spawn qpdf ENOENT**"
  </code></pre>
  
  <p>We have also tried the following code : </p>
  
  <p>============</p>
  
  <pre><code>var exec = require('child_process').exec;
  var pdfsourcepath = './myInputFile_WithPassword.pdf'; 
  var pdfdestinationpath = './myoutfileWith_NopasswordProtection.pdf'; 
  var password = "test";  
  
  var command = 'qpdf --decrypt --password='+password+' '+pdfsourcepath+' '+pdfdestinationpath+'';
  
  exec(command, function (error){
  if (error !== null){
  console.log('exec error: ' + error);
   } 
  else{
      console.log('Your pdf is decrypted successfully.');
      }
     }
   );
  </code></pre>
  
  <p>============</p>
  
  <p>And this code is working successfully.  </p>
  
  <p>Now We want to totally implement the same using node module [node-qpdf], but that is failing [as explained].</p>
  
  <p>Please share your idea on the issue.</p>
  
  <p>Also we implement the same on docker images, so if we will install the qpdf on main server, does the containers will able to get that binary ?
  I have checked the article  : <a href="https://hub.docker.com/r/mgodlewski/qpdf" rel="nofollow noreferrer">https://hub.docker.com/r/mgodlewski/qpdf</a> 
  But I get a little bit confused.</p>
  
  <p>So also share the resolution in terms of docker images for qpdf.</p>