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 #16

Open
evolutionxbox opened this issue Nov 27, 2020 · 0 comments
Open

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

evolutionxbox opened this issue Nov 27, 2020 · 0 comments

Comments

@evolutionxbox
Copy link

evolutionxbox commented Nov 27, 2020

Please note that I am using node-qpdf2, but that's just a wrapper around this module.

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.

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

No branches or pull requests

1 participant