Skip to content

kahvecci/pymupdf_code_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Visual PDF Editor & Code Generator for PyMuPDF

A lightweight, powerful web-based visual editor designed to simplify the creation of PDF templates using Python and the PyMuPDF (fitz) library. Instead of guessing coordinates and writing boilerplate code by hand, you can visually design your PDF layout on a canvas, while the application instantly generates clean, ready-to-use Python code.

PDF Drawer Preview

✨ Features

  • 🎨 Visual Canvas Editor: Design your PDFs intuitively with a drag-and-drop interface.
  • 🐍 Real-time Code Generation: Automatically outputs clean, descriptive PyMuPDF Python code. Text and properties are intelligently assigned to variables for easy integration into your own automation apps.
  • 🔄 Bidirectional Sync: Not only does the canvas generate code, but you can also edit the generated Python code in the "Edit" tab and press Ctrl+Enter to instantly update the visual canvas!
  • 🛠️ Comprehensive Toolset: Includes essential drawing tools: Pointer, Rectangle, Diamond, Circle/Ellipse, Arrow, Line, Freehand Pen, Text, Textbox, Image, and Eraser.
  • 📏 Precision Controls: Custom page sizes (A4, A5, Letter, Legal, Custom dimensions), snap-to-grid controls, and dynamic layer ordering (Bring Forward / Send Backward).
  • 🖱️ Advanced Navigation:
    • Zoom: Ctrl + Scroll
    • Pan: Scroll (vertical), Shift + Scroll (horizontal)
    • Multi-select: Ctrl + Click or Box-select by dragging on empty space.
  • ⏪ Undo/Redo: Full history tracking (up to 50 steps) via buttons or Ctrl+Z / Ctrl+Y.
  • 🌍 Multi-language UI: Supports English (default) and Turkish natively, togglable on the fly without page reloads.

🚀 Getting Started

The application is completely self-contained. It uses pure HTML/JS/CSS on the frontend and a lightweight Python script to serve the application locally.

Prerequisites

  • Python 3.x
  • PyMuPDF library (for the generated code to work in your target projects)
    pip install pymupdf

Running the Application

  1. Clone this repository or download the source files.
  2. Open your terminal or command prompt and navigate to the project directory.
  3. Run the supplied Python server script:
    python drawer.py
  4. Open your web browser and navigate to:
    http://localhost:8000/index.html
    

💻 Workflow Example

  1. Start the server and open the UI in your browser.
  2. Select your desired page size (e.g., A4) from the top bar.
  3. Use the toolbar on the left to draw a Rectangle, add some Text, and maybe an Image placeholder.
  4. Tweak the precise coordinates, stroke width, alignments, and colors via the Properties panel on the right.
  5. In the PyMuPDF Code panel at the bottom, grab your generated, bug-free Python code and paste it directly into your own automation scripts!

🤖 Built with AI

This project was developed end-to-end with the assistance of an advanced AI coding agent, turning the abstract idea of a "visual PyMuPDF builder" into a fully functional, professional-grade developer tool.

About

Browser based pymupdf code generator with drawing pdf's

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors