electron/spec/fixtures/api/pdf-reader.mjs
dependabot[bot] 0d4d752c1b
build(deps): bump the npm_and_yarn group across 2 directories with 3 updates (#43511)
* build(deps): bump the npm_and_yarn group across 2 directories with 3 updates

Bumps the npm_and_yarn group with 1 update in the / directory: [braces](https://github.com/micromatch/braces).
Bumps the npm_and_yarn group with 3 updates in the /spec directory: [braces](https://github.com/micromatch/braces), [pdfjs-dist](https://github.com/mozilla/pdf.js) and [ws](https://github.com/websockets/ws).


Updates `braces` from 3.0.2 to 3.0.3
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

Updates `braces` from 3.0.2 to 3.0.3
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

Updates `pdfjs-dist` from 2.16.105 to 4.2.67
- [Release notes](https://github.com/mozilla/pdf.js/releases)
- [Commits](https://github.com/mozilla/pdf.js/compare/v2.16.105...v4.2.67)

Updates `ws` from 7.5.9 to 7.5.10
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.5.9...7.5.10)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: braces
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: pdfjs-dist
  dependency-type: direct:development
  dependency-group: npm_and_yarn
- dependency-name: ws
  dependency-type: direct:development
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: update api-web-contents-spec to us newer version of pdfjs-dist

* test: create fixture to read PDF files for verification

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2024-09-09 11:49:43 +02:00

22 lines
No EOL
520 B
JavaScript

import * as pdfjs from 'pdfjs-dist';
async function getPDFDoc() {
try {
const doc = await pdfjs.getDocument(process.argv[2]).promise;
const page = await doc.getPage(1);
const { items } = await page.getTextContent();
const markInfo = await doc.getMarkInfo();
const pdfInfo = {
numPages: doc.numPages,
view: page.view,
textContent: items,
markInfo
}
console.log(JSON.stringify(pdfInfo));
process.exit();
} catch (ex) {
process.exit(1);
}
}
getPDFDoc();