node-pdftk icon indicating copy to clipboard operation
node-pdftk copied to clipboard

Bursting a PDF with owner password set and warnings ignored throws error

Open sean-schaefer opened this issue 6 years ago • 6 comments

Describe the bug When attempting to burst a PDF that has an owner password set, node-pdftk throws an error with the warning from pdftk even though ignoreWarnings is set to true and pdftk returns a 0 exit code from the same command.

To Reproduce Grab this PDF to use for input in the below code: http://www.orimi.com/pdf-test.pdf Code to reproduce:

const pdftk = require('node-pdftk')
pdftk.configure({ignoreWarnings: true})
pdftk.input('/tmp/pdf-test.pdf').burst().then(() => console.log('Success')).catch((err) => console.error(err))

Output:

Promise {
  <pending>,
  domain: 
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }
> WARNING: The creator of the input PDF:
   /tmp/pdf-test.pdf
   has set an owner password (which is not required to handle this PDF).
   You did not supply this password. Please respect any copyright.

Running pdftk /tmp/pdf-test.pdf burst outputs the warning but returns a 0 exit code.

Expected behavior An error shouldn't be thrown since I'm ignoring warnings.

sean-schaefer avatar Dec 20 '18 17:12 sean-schaefer

Found a bonehead mistake that was re-assigning the _ignoreWarnings property. This hopefully takes care of the problem. Let me know if it doesn't. I published the fix to npm as v2.0.2

jjwilly16 avatar Dec 26 '18 16:12 jjwilly16

Thanks @jjwilly16. I upgraded to 2.0.2 and I'm still seeing the issue. You should be able to reproduce using the code example in my original comment.

sean-schaefer avatar Jan 02 '19 18:01 sean-schaefer

I'm experiencing the same issue using version 2.1.1 of node-pdftk. Is there a solution?

pdftk.configure({ ignoreWarnings: true });

pdftk
    .input(sourcePDF)
    .fillForm(data)
    .flatten()
    .output()
    .then(() => {
      console.log('Success');
    })
    .catch(err => {
      console.log(err);
    });

Output:

WARNING: The creator of the input PDF:
forms/myPdf.pdf
has set an owner password (which is not required to handle this PDF).
You did not supply this password. Please respect any copyright.

michaelgodshall avatar Sep 27 '19 01:09 michaelgodshall

Hopefully fixed in 2.1.2. Let me know if it's still a problem

jjwilly16 avatar Jan 03 '20 04:01 jjwilly16

I'm still getting a similar error when trying to parse a document. What I'm sure of is that it has a placeholder password since the document can be opened through any other means with no issues. Is there a way I can supply an empty string as a password using your wrapper library ?

Thank you for your work on the library !

Error output:

Failed to open PDF file: 
   /home/user/project/node_modules/node-pdftk/node-pdftk-tmp/4e520d879039e8f5e4ef11d716f15ccd.pdf
   OWNER PASSWORD REQUIRED, but not given (or incorrect)
Errors encountered.  No output created.
Done.  Input errors, so no output created.

m-majetic avatar Oct 02 '20 12:10 m-majetic

@m-majetic Can you get me a sample PDF to test?

jjwilly16 avatar Oct 05 '20 15:10 jjwilly16