Skip to content

kushagra-25/PDF_tweaker

 
 

Repository files navigation

PDF Fun Studio 🎭📖

A unified web application that combines beautiful PDF viewing capabilities with hilarious PDF transformation features! Built with modern web technologies and Python backend processing.

✨ Features

📖 PDF Viewer Tab

  • Beautiful PDF Rendering: View PDFs with the same stunning UI from PDF-Tweaker
  • Interactive Controls: Navigate pages, zoom in/out, and view page information
  • Drag & Drop: Simply drag PDFs onto the viewer area
  • Responsive Design: Works perfectly on desktop and mobile devices
  • Visual Enhancements: Subtle visual effects and overlays for a polished experience

🎭 Funny PDF Generator Tab

  • Multiple Humor Styles: Choose from Mild, Spicy, or Chaotic humor levels
  • Customizable Options: Control cat insertions, emoji sprinkling, and more
  • AI Integration: Optional OpenAI-powered text rewriting (requires API key)
  • Random Cat Images: Automatically inserts random cat images throughout the PDF
  • Real-time Processing: See processing status and download results instantly

🚀 Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • Python 3.8 or higher
  • pip (Python package manager)

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd Noob_Coderz
  2. Install Python dependencies

    pip install -r requirements.txt
  3. Install Node.js dependencies

    npm install
  4. Start the server

    npm start
  5. Open your browser Navigate to http://localhost:3000

🎯 How to Use

PDF Viewer

  1. Click the "📖 PDF Viewer" tab
  2. Upload a PDF file using the file picker or drag & drop
  3. Navigate through pages using the arrow buttons
  4. Use zoom controls to adjust the view
  5. Keyboard shortcuts: Arrow keys for navigation, +/- for zoom

Funny PDF Generator

  1. Click the "🎭 Funny PDF Generator" tab
  2. Select a PDF file to transform
  3. Choose your preferred humor style:
    • Mild: Gentle, family-friendly humor
    • Spicy: Moderate chaos and fun
    • Chaotic: Maximum chaos and hilarity
  4. Customize options:
    • Insert cats every N paragraphs
    • Enable/disable emojis
    • Enable/disable random cat images
    • Optional AI rewriting (requires OpenAI API key)
  5. Click "🎭 Generate Funny PDF!"
  6. Download your transformed PDF when ready!

🔧 Configuration

Environment Variables

Create a .env file in the root directory:

# Server configuration
PORT=3000
PYTHON_BIN=python3

# OpenAI API (optional, for AI rewriting feature)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4o-mini

Python Path

If you're on Windows or have multiple Python versions, you can specify the Python executable:

PYTHON_BIN=python
# or
PYTHON_BIN=C:\Python39\python.exe

🏗️ Architecture

  • Frontend: Modern HTML5, CSS3, and vanilla JavaScript with ES6 modules
  • Backend: Node.js/Express server with Python integration
  • PDF Processing: Python scripts using pdfplumber, FPDF2, and Pillow
  • Styling: Beautiful gradient-based design with Poppins font
  • PDF.js: Client-side PDF rendering for the viewer

📁 Project Structure

Noob_Coderz/
├── public/
│   └── index.html          # Main unified website
├── PDF-Tweaker/            # PDF.js library files
│   ├── pdf.mjs
│   └── pdf.worker.mjs
├── server.js               # Node.js backend server
├── funnyify.py            # Python PDF transformation script
├── requirements.txt        # Python dependencies
├── package.json           # Node.js dependencies
└── README.md              # This file

🎨 Customization

Styling

The website uses CSS custom properties (variables) for easy theming. Modify the :root section in the HTML file to change colors and gradients.

Humor Styles

Edit the STYLES dictionary in funnyify.py to adjust the intensity levels for different humor styles.

PDF Processing

The Python script can be extended to add more transformation features like:

  • Different image types (not just cats)
  • Custom text replacements
  • Layout modifications
  • Additional visual effects

🐛 Troubleshooting

Common Issues

  1. Python not found

    • Ensure Python is installed and in your PATH
    • Set PYTHON_BIN environment variable to the correct Python executable
  2. PDF processing fails

    • Check that all Python dependencies are installed
    • Ensure the PDF file is not corrupted or password-protected
    • Check server logs for detailed error messages
  3. Port already in use

    • Change the PORT environment variable
    • Kill any processes using port 3000
  4. AI features not working

    • Verify your OpenAI API key is set correctly
    • Check that the OPENAI_API_KEY environment variable is set
    • Ensure you have sufficient API credits

Debug Mode

Enable debug logging by setting the DEBUG environment variable:

DEBUG=true

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

📄 License

This project is open source and available under the MIT License.

🙏 Acknowledgments

  • PDF.js: For client-side PDF rendering capabilities
  • pdfplumber: For PDF text extraction
  • FPDF2: For PDF generation
  • Pillow: For image processing
  • Express.js: For the web server framework

Happy PDF fun-making! 🎉📄

About

Contributions by Kushagra Agrawal: kushagra25

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 99.0%
  • Other 1.0%