A Python CLI to export pages from PDF files as images.
- macOS:
- Install poppler:
brew install poppler
.
- Install poppler:
- WSL/Ubuntu:
- Install poppler:
sudo apt-get install poppler-utils
.
- Install poppler:
Usage:
$ pdfshot [OPTIONS] INPUT_PATH PDF_PAGE
Arguments:
INPUT_PATH
: The input PDF file. [required]PDF_PAGE
: The page number of the PDF file to export as an image. Page numbering starts at 1 (1-based indexing). [required]
Options:
-b, --add-border
: Add border to the page image. [default: False]--version
: Show the version and exit.--install-completion
: Install completion for the current shell.--show-completion
: Show completion for the current shell, to copy it or customize the installation.--help
: Show this message and exit.
- pdf2image:
- To only convert PDF files to images.
- Commands:
poetry init
+poetry install
.poetry add "typer[all]"
.which pdfshot
.pdfshot test.pdf 1
orpdfshot test.pdf 1 --add-border
.
- Typer:
- CLI arguments (required by default): CLI parameters (
./myproject
, for example) passed in some specific order to the CLI application (ls
, for example). - CLI options (optional by default): CLI parameters (
--size
, for example) passed to the CLI application with a specific name. - Data validation.
- Numeric validation.
- For commands, think of
git
(git push
,git clone
, etc.).
- CLI arguments (required by default): CLI parameters (
- Poetry:
- Outdated metadata after version bump for local package (open) issue.
- On Windows, to keep the LF line ending (source and source):
git config core.eol lf
git config core.autocrlf input
- Check the line ending format of a file on Ubuntu:
file README.md
vs.file pyproject.toml
(source)