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

It does not work for remote pdf files? ENOENT error #51

Open
DavideViolante opened this issue Mar 24, 2024 · 1 comment
Open

It does not work for remote pdf files? ENOENT error #51

DavideViolante opened this issue Mar 24, 2024 · 1 comment

Comments

@DavideViolante
Copy link

DavideViolante commented Mar 24, 2024

  import { PDFExtract, PDFExtractOptions } from 'pdf.js-extract';
  const pdfExtract = new PDFExtract();
  const options: PDFExtractOptions = { };
  async function main() {
    const res = await pdfExtract.extract('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', options);
  }
  main()
[Error: ENOENT: no such file or directory, open 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
}

Node v20
"pdf.js-extract": "^0.2.1"

Am I missing something?

I also tried, but same error:

import { readFile } from 'fs/promises';
import { PDFExtract, PDFExtractOptions } from 'pdf.js-extract';
const buffer = await readFile('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf');
pdfExtract.extractBuffer(buffer, options, (err, data) => {
  if (err) {
    return console.error(err);
  }
  console.log(data);
});

Does it work only with local files?

@DavideViolante
Copy link
Author

DavideViolante commented Mar 24, 2024

Like this I don't get anything on console.log, neither error.

  const { data } = await axios.get('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', {
    responseType: 'arraybuffer',
  });
  pdfExtract.extractBuffer(data, options, (err, pdf) => {
    if (err) {
      return console.error(err);
    }
    console.log(pdf);
  });

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