Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
PDF compiler for your source code
Uses Shiki
for perfect syntax highlighting and shiki-renderer-pdf
to create the PDFs.
npm install pdfc
Most uses are through the CLI, but there is a programatic API.
To compile all files in a directory to PDFs you can use this:
pdfc src
src
is the rootDir
here, so all paths will be relative to that. You cannot include files outside of the rootDir
.
Output is placed in the pdfs
directory by default. To change the output directory you can use the -d
or --out-dir
flag:
pdfc src -d pdf-build
This will compile all files in src
by default. If you want to restrict to a subset of files you can use the --include
flag:
pdfc src --include "src/**/*.js"
This will compile only the js files in src
. The same can be done with the --exclude
flag:
pdfc src --exclude "node_modules" --exclude "src/**/*.test.js"
This will exclude all test files from compilation. Note that node_modules
should also be excluded here because it is only excluded by default if --exclude
is not passed. If include
is specified, exclude
will apply to the included files.
You can also specify a theme to use with the -t
or --theme
flag:
pdfc src -t github-light
If none if specified, it will default to light-plus
. See shiki docs for a list of themes.
Run pdfc --help
for more on what you can do.
Please note that this package is pure ESM, see this for more details.
Compile PDFs, this will also write files to pdfs
by default:
import { compilePdfs } from 'pdfc'
;(async () => {
await compilePdfs({
rootDir: 'src',
include: ['src/**/*.js'],
theme: 'light-plus',
})
})()
Compile string to a PDFDocument
instance:
import fs from 'node:fs/promises'
import { stringToPdf } from 'pdfc'
;(async () => {
const code = 'console.log("Hello World")'
const pdfDocument = await stringToPdf(code, {
lang: 'js',
theme: 'light-plus',
})
const pdfBytes = await pdfDocument.save()
await fs.writeFile('hello-world.pdf', pdfBytes, 'binary')
})()
Read more about what you can do with pdfDocument
here.
FAQs
PDF compiler for your source code
The npm package pdfc receives a total of 2 weekly downloads. As such, pdfc popularity was classified as not popular.
We found that pdfc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.