
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
PdftocCreates Table of Contents in PDF documents
npm run buildnpx pdftocRecipes describe how to detect headings in the PDF. There are basically two strategies, which may be combined:
The recipe file is a json file consisting of an array of recipies. Each recipe may contain the following properties, of which all except level are optional.
Hint: If you use a regular expressions, it might happen that the table of content of the document itself duplicates all heading. In that case, set pages accordingly, e.g. pages="5-", so that the table of content pages are ignored.
Detect headings based on font:
[
{ "fontName": "BHTCaseMicro", "fontSizeFrom": 64,
"bold": true, "italic": false, "level": 1 },
{ "fontName": "BHTCaseMicro", "fontSizeFrom": 60,
"bold": true, "italic": false, "level": 2 },
{ "fontName": "BHTCaseMicro", "fontSizeFrom": 52,
"bold": true, "italic": false, "level": 3 },
{ "fontName": "BHTCaseMicro", "fontSizeFrom": 48,
"bold": true, "italic": false, "level": 4 },
]
Detect heading based on regular expression:
[
{ "regexp": "^\\d+\\s+.*", "level": 1 },
{ "regexp": "^\\d+\\.\\d+\\s+.*", "level": 2 },
{ "regexp": "^\\d+\\.\\d+\\.\\d+\\s+.*", "level": 3 },
]
Tip: Using regular expressions with "bold": true works in many cases :-)
This package relies on PDF.js, which is added as dependency (pdfjs-dist). This package uses ES modules, and as a consequence ES modules are used here as well. There are some problems with that, in particular with TypeScript:
As noted at the PDF.js-FAQ, we need to import the legacy build of PDF.js.
In development. Works with some files, sometimes font is not detected. In order to use fonts in settings, usually access to original document with font information is required (as the analysis is not really usable at the moment). But using regex works quite well even for unknown documents.
Probably need a GUI sooner or later ;-)
This program and the accompanying materials are made available under the terms of the Eclipse Public License v. 2.0 which is available at https://www.eclipse.org/legal/epl-2.0.
FAQs
Creates Table of Contents in PDF documents
We found that pdftoc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.