ClipboardToPDF is a lightweight Python automation tool that instantly converts your clipboard content into professionally styled PDF documents.
Unlike standard "Save as PDF" workflows, this tool automates the entire metadata process: it intelligently parses your text to generate a filename, detects dates for organization, and archives files into a structured timeline folder system.
-
Universal Input: Works with Markdown (headers, tables, code blocks) or Plain Text.
-
Smart Auto-Naming:
-
Detects Markdown headers (
# Title) to name the file. -
Falls back to the first line of text for generic notes.
-
Automatic Filing: Creates a timeline directory structure (
Documents/Clipboard_Archives/2025/12_December/) so you never have to organize files manually. -
Professional Styling: Applies a clean, minimal CSS theme suitable for printing (A4/Letter margins).
-
Crash-Proof: Includes robust error handling for empty clipboards and text encoding issues.
This tool requires the wkhtmltopdf rendering engine.
- Windows: Download the wkhtmltopdf installer (64-bit).
- Default Path: The script expects it at
C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe.
- Python 3.8+ recommended.
- Clone or Download this repository.
- Create a Virtual Environment (Recommended):
python -m venv venv
.\venv\Scripts\activate
- Install Dependencies:
Create a
requirements.txtfile with the following content:
pdfkit>=1.0.0
pyperclip>=1.8.2
markdown>=3.4.1
Then run:
pip install -r requirements.txt
- Copy Text: Highlight text from anywhere (AI Chat, Notepad, Browser) and press
Ctrl+C. - Run Script:
python clipboard_to_pdf.py
- Done: The script will print the saved location and automatically open the folder containing your new PDF.
| Input Type | Extracted Filename | Filing Path |
|---|---|---|
| Markdown Report | # Shift Log Dec 19 |
.../2025/12_December/Shift Log Dec 19.pdf |
| Grocery List | Milk, Eggs, Bread... |
.../2025/12_December/Milk_Eggs_Bread.pdf |
| Code Snippet | # Python Script |
.../2025/12_December/Python Script.pdf |
You can customize the script by editing the constants at the top of clipboard_to_pdf.py:
# Change where files are saved
BASE_SAVE_DIR = Path.home() / "Documents" / "Clipboard_Archives"
# Update if you installed wkhtmltopdf in a custom location
WKHTMLTOPDF_PATH = Path(r'C:\Custom\Path\wkhtmltopdf.exe')Error: "wkhtmltopdf not found"
- Ensure you have installed the software (not just the Python library).
- Verify
WKHTMLTOPDF_PATHmatches your installation path.
Error: "Clipboard is empty"
- Copy your text before running the script.
- Some remote desktop apps do not share the clipboard with the host machine.
This project is licensed under the MIT License - see the LICENSE file for details.
Author: Md Samshad Rahman