Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory - file name contains a space #8

Closed
evolutionxbox opened this issue Nov 27, 2020 · 2 comments · Fixed by #10
Closed

No such file or directory - file name contains a space #8

evolutionxbox opened this issue Nov 27, 2020 · 2 comments · Fixed by #10

Comments

@evolutionxbox
Copy link

I have also added an issue on node-qpdf

Trying to encrypt a file that has one or more spaces in the name

qpdf
    .encrypt(
      '/Users/my/absolute/path/to/A Sample PDF.pdf',
      {
        keyLength: 40,
        password: {
          user: '',
          owner: 'YOUR_PASSWORD_TO_ENCRYPT_FOR_OWNER',
        },
        restrictions: {
          print: 'y',
        },
      },
      '/Users/my/absolute/path/to/protected.pdf'
    )
    .then((x) => console.log('Done: ', x))
    .catch((e) => console.error('Error: ', e));

Result:

Error:  open /Users/my/absolute/path/to/A\ Sample\ PDF.pdf: No such file or directory

I thought that maybe adding double quotes around the path would help, as that is what you do in the shell to allow paths with spaces:

qpdf
    .encrypt(
      '"/Users/my/absolute/path/to/A Sample PDF.pdf"',
      {
        keyLength: 40,
        password: {
          user: '',
          owner: 'YOUR_PASSWORD_TO_ENCRYPT_FOR_OWNER',
        },
        restrictions: {
          print: 'y',
        },
      },
      '/Users/my/absolute/path/to/protected.pdf'
    )
    .then((x) => console.log('Done: ', x))
    .catch((e) => console.error('Error: ', e));

Result:

Done:  Input file doesn't exist

Using path.resolve also results in the "Input file doesn't exist" error.

@Sparticuz
Copy link
Owner

Hey there, I have no idea why github didn't notify me of issues in this repo. I've started looking at this bug. Sorry for the delay.

@Sparticuz
Copy link
Owner

I'm not sure why, but I was manually escaping the input variable. I changed that and added tests for this case. Thanks for the issue and sorry I missed it for so long!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants