Skip to main content

A CLI tool to edit PDF slides using natural language prompts, powered by Gemini 3 Pro Image

Project description

Nano PDF Logo

Nano PDF Editor

PyPI version Python 3.10+ License: MIT

A CLI tool to edit PDF slides using natural language prompts, powered by Google's Gemini 3 Pro Image ("Nano Banana") model.

Features

  • Natural Language Editing: "Update the graph to include data from 2025", "Change the chart to a bar graph".
  • Add New Slides: Generate entirely new slides that match your deck's visual style.
  • Non-Destructive: Preserves the searchable text layer of your PDF using OCR re-hydration.
  • Multi-page & Parallel: Edit multiple pages in a single command with concurrent processing.

How It Works

Nano PDF uses Gemini 3 Pro Image (aka Nano Banana) and PDF manipulation to enable quick edits of PDFs with natural language editing:

  1. Page Rendering: Converts target PDF pages to images using Poppler
  2. Style References: Optionally includes style reference pages with generation request to understand visual style (fonts, colors, layout)
  3. AI Generation: Sends images + prompts to Gemini 3 Pro Image, which generates edited versions
  4. OCR Re-hydration: Uses Tesseract to restore searchable text layer to generated images
  5. PDF Stitching: Replaces original pages with AI-edited versions while preserving document structure

The tool processes multiple pages in parallel for speed, with configurable resolution (4K/2K/1K) to balance quality vs. cost.

Installation

pip install nano-pdf

Configuration

You need a paid Google Gemini API key with billing enabled. Free tier keys do not support image generation.

  1. Get an API key from Google AI Studio
  2. Enable billing on your Google Cloud project
  3. Set it as an environment variable:
export GEMINI_API_KEY="your_api_key_here"

Note: This tool uses Gemini 3 Pro Image which requires a paid API tier. See pricing for details.

Usage

Basic Edit

Edit a single page (e.g., Page 2):

nano-pdf edit my_deck.pdf 2 "Change the title to 'Q3 Results'"

Multi-page Edit

Edit multiple pages in one go:

nano-pdf edit my_deck.pdf \
  1 "Update date to Oct 2025" \
  5 "Add company logo" \
  10 "Fix typo in footer"

Add New Slides

Insert a new AI-generated slide into your deck:

# Add a title slide at the beginning
nano-pdf add my_deck.pdf 0 "Title slide with 'Q3 2025 Review'"

# Add a slide after page 5
nano-pdf add my_deck.pdf 5 "Summary slide with key takeaways as bullet points"

The new slide will automatically match the visual style of your existing slides and uses document context by default for better relevance.

Options

  • --use-context / --no-use-context: Include the full text of the PDF as context for the model. Disabled by default for edit, enabled by default for add. Use --no-use-context to disable.
  • --style-refs "1,5": Manually specify which pages to use as style references.
  • --output "new.pdf": Specify the output filename.
  • --resolution "4K": Image resolution - "4K" (default), "2K", or "1K". Higher quality = slower processing.
  • --disable-google-search: Prevents the model from using Google Search to find information before generating (enabled by default).

Examples

Fixing Presentation Errors

# Fix typos across multiple slides
nano-pdf edit pitch_deck.pdf \
  3 "Fix the typo 'recieve' to 'receive'" \
  7 "Change 'Q4 2024' to 'Q1 2025'"

Visual Design Changes

# Update branding and colors
nano-pdf edit slides.pdf 1 "Make the header background blue and text white" \
  --style-refs "2,3" --output branded_slides.pdf

Content Updates

# Update financial data
nano-pdf edit report.pdf 12 "Update the revenue chart to show Q3 at $2.5M instead of $2.1M"

Batch Processing with Context

# Use full document context for consistency
nano-pdf edit presentation.pdf \
  5 "Update the chart colors to match the theme" \
  8 "Add the company logo in the bottom right" \
  --use-context

Adding New Slides

# Add a new agenda slide at the beginning
nano-pdf add quarterly_report.pdf 0 "Agenda slide with: Overview, Financial Results, Q4 Outlook"

Using Google Search

# Google Search is enabled by default - the model can look up current information
nano-pdf edit deck.pdf 5 "Update the market share data to latest figures"

# Disable Google Search if you want the model to only use provided context
nano-pdf add deck.pdf 3 "Add a summary slide" --disable-google-search

Requirements

  • Python 3.10+
  • poppler (for PDF rendering)
  • tesseract (for OCR)

System Dependencies

macOS

brew install poppler tesseract

Windows

choco install poppler tesseract

Note: After installation, you may need to restart your terminal or add the installation directory to your PATH.

Linux (Ubuntu/Debian)

sudo apt-get install poppler-utils tesseract-ocr

Troubleshooting

"Missing system dependencies" error

Make sure you've installed poppler and tesseract for your platform. After installation, restart your terminal to refresh PATH. Run which pdftotext and which tesseract to verify they're accessible.

"GEMINI_API_KEY not found" error

Set your API key as an environment variable:

export GEMINI_API_KEY="your_key_here"

"Gemini API Error: PAID API key required" error

Gemini 3 Pro Image requires a paid API tier. Visit Google AI Studio to enable billing on your project.

Generated images don't match the style

Try using --style-refs to specify reference pages that have the desired visual style. The model will analyze these pages to better match fonts, colors, and layout.

Text layer is missing or incorrect after editing

The tool uses Tesseract OCR to restore searchable text. For best results, ensure your generated images are high resolution (--resolution "4K"). Note that OCR may not be perfect for stylized fonts or small text.

Pages are processing slowly

  • Use --resolution "2K" or --resolution "1K" for faster processing

Running from Source

If you want to run the latest development version:

# Clone the repository
git clone https://github.com/gavrielc/Nano-PDF.git
cd Nano-PDF

# Install dependencies
pip install -e .

# Run the tool
nano-pdf edit my_deck.pdf 2 "Your edit here"

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nano_pdf-0.2.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nano_pdf-0.2.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file nano_pdf-0.2.1.tar.gz.

File metadata

  • Download URL: nano_pdf-0.2.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nano_pdf-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f1a8c5eabdf5a67d7f2a99e73e3c49a52cbbc754b801816d46a2ebed6d3eb592
MD5 0b60da836dc0cc723d55674a4c3fb884
BLAKE2b-256 d957db3c079d5beb54c13ae16419aeb7e0ef7267a4f5f6db47bc42a3e8890ad8

See more details on using hashes here.

File details

Details for the file nano_pdf-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: nano_pdf-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nano_pdf-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 780338018a802edc7ef8b7438c23fef3a6fd5cc47beedf4bfba77376778db673
MD5 bba32e52ae76f00d8a2b174ea8149d81
BLAKE2b-256 44ed7019a6a4ac4d5f66d2d5fdfb162df6869f6571cd1a5d85e74c63b711d14b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page