Slice specific pages from a PDF and copy their text to the clipboard — for building shorter LLM contexts.
Project description
pdf-prompt-slicer
A tiny CLI that slices specific pages out of a PDF and copies the extracted text to your clipboard — so you can feed an LLM a focused subset of a document instead of uploading the whole thing.
- Pick pages individually or by range:
"[1, 2, 3-6]" - Get a new, shorter PDF saved next to the original
- Get the raw text of those pages on your clipboard, ready to paste
- Optional clipboard-only mode when you don't need a new PDF
Install (simplest)
Requires uv. If you don't have it:
# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Then install this tool in one line:
uv tool install git+https://github.com/ChuckySRB/PDFPromptSlicer
That puts a pdfslice command on your PATH. You can now run it from anywhere.
To upgrade later: uv tool upgrade pdf-prompt-slicer
To uninstall: uv tool uninstall pdf-prompt-slicer
Usage
pdfslice <path_to_pdf> "<pages>" [-c]
Arguments
<path_to_pdf>— path to the source PDF.<pages>— a list of pages or ranges. Brackets are optional; whitespace is fine. Examples:"[1, 2, 3-6]","1,2,3-6","4-4","7".-c,--clipboard-only— copy text to the clipboard only; do not write a sliced PDF.
Examples
Slice pages 1, 2, and 3 through 6 into a new PDF and copy their text:
pdfslice paper.pdf "[1, 2, 3-6]"
Just copy the text (no new PDF):
pdfslice paper.pdf "[1, 2, 3-6]" -c
Output
- The sliced PDF is saved next to the original with
_sliced_<n>appended to the filename.paper.pdf→paper_sliced_1.pdf. Running again producespaper_sliced_2.pdf, etc. — existing files are never overwritten. - The combined text of all selected pages (separated by blank lines) is placed on the system clipboard.
Running without installing
From a clone of the repo:
uv run --script run.py <pdf> "[1, 3-5]"
uv reads the inline script metadata at the top of run.py and sets up a temporary env with the right dependencies — no manual install step.
Development
git clone https://github.com/ChuckySRB/PDFPromptSlicer
cd PDFPromptSlicer
uv sync
uv run pdfslice test_data/your.pdf "[1-3]"
The project layout:
PDFPromptSlicer/
├── pyproject.toml
├── run.py # inline-deps entry point (no install needed)
├── src/pdf_prompt_slicer/
│ ├── __init__.py
│ ├── __main__.py # enables `python -m pdf_prompt_slicer`
│ └── cli.py # real implementation + `main()`
└── test_data/ # gitignored; for local testing
Dependencies
On Linux, pyperclip needs either xclip or xsel installed for clipboard access. macOS and Windows work out of the box.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdf_prompt_slicer-0.1.0.tar.gz.
File metadata
- Download URL: pdf_prompt_slicer-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1534fa4e5649bd5731b4cfbf079848033527729ae7ad0b78020ca437ea78967
|
|
| MD5 |
b7ba58edb1d1da7c60919e40a12b1558
|
|
| BLAKE2b-256 |
15553e0f9ff059748f15443d16e4f3dec9cc34c71bdc5784eb83bda5d4bff83a
|
File details
Details for the file pdf_prompt_slicer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pdf_prompt_slicer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dda3493406ae5423c216a887b109cb8e2efa5b6177676288076cbcfc8283815c
|
|
| MD5 |
a6baeb0efceee678f0784838fd9f8b31
|
|
| BLAKE2b-256 |
9cf98b02e0df2457ff54fefc292d23a2ca2481fa830538b8847ba9f7d9ee14a3
|