NitinReddy-A/PDF_Linguist

8

stars

221

commits

Python

primary language

Feb 15, 2025

updated

README

๐Ÿ”น PDF Linguist: A Seamless PDF Content Extraction, Merging, and Translation Tool

๐ŸŒ Overview

Meet PDF Linguist โ€“ your ultimate tool for extracting, merging, and translating PDF content! ๐ŸŒŸ Whether itโ€™s digital PDFs or scanned ones, this versatile app makes it a breeze to transform and translate documents while keeping the original formatting intact. Perfect for tackling all your document translation and manipulation needs! ๐Ÿ“„โœจ

๐Ÿ”น Key Highlights:

  1. Translation for Digital PDFs ๐Ÿ”
  2. Translation for Scanned PDFs ๐Ÿ”

All these features are wrapped up in a single app, giving you complete control over your PDF workflows. ๐Ÿ 


๐Ÿ”ง Features

โญ Digital PDFs

  • ๐Ÿ“„ Extract Text and Images: Quickly extract searchable text and embedded images.
  • ๐Ÿ’ฌ Translate Content: Convert text into your desired language effortlessly.
  • ๐Ÿ”  Render Complex Scripts: Perfect for Indic languages like Devanagari, thanks to the HarfBuzz engine to handle intricate ligatures and unicode combinations.
  • ๐ŸŒˆ Merge & Preserve Layout: Combines translated content while keeping the original layout intact.
  • ๐Ÿ”– Multiple Output Formats: Save your work as PDF and Word (DOCX).
  • ๐Ÿ”„ Multi-page Handling: Process multi-page documents seamlessly.

๐Ÿ” Scanned PDFs

  • ๐Ÿ” OCR-Based Extraction: Extract text from scanned images using Tesseract OCR.
  • ๐Ÿ•’ Customizable Cropping: Select specific dimensions to exclude unwanted sections.
  • ๐Ÿ’ฌ Translate Content: High-quality translations for regional languages.
  • ๐ŸŽจ Merge & Preserve Layout: Seamlessly combine translated text with the scanned PDFโ€™s layout.
  • ๐Ÿ”– Multiple Output Formats: Export translations as PDF and Word (DOCX).

๐Ÿ› ๏ธ Installation

Prerequisites

  1. Python installed on your system.
  2. Recommended: Virtual environment setup.

Steps

  1. Clone the repository:

    git clone https://github.com/NitinReddy-A/PDF_Linguist.git
    
  2. Navigate to the project directory:

    cd PDF_Linguist
    
  3. Set up a virtual environment (optional):

    python -m venv virtual-env
    source virtual-env/bin/activate  # Linux/Mac
    virtual-env\Scripts\activate    # Windows
    
  4. Install dependencies:

    pip install -r requirements.txt
    

๐ŸŽจ Usage

Step 1: Prepare Your PDF Document

Place the PDF file you want to process in the documents/ folder.

Step 2: Run the Application

Launch the app using Streamlit:

streamlit run app.py

Step 3: Select PDF Type

  • Digital PDF: For PDFs with searchable text.
  • Scanned PDF: For image-based PDFs needing OCR.

๐Ÿ”น Digital PDFs

  1. Upload your PDF using the file uploader.
  2. Choose the target language for translation.
  3. Click the button to extract, translate, and reassemble the PDF.
  4. Download your translated file in PDF or DOCX format.

๐Ÿ”น Scanned PDFs

  1. Upload your scanned PDF.
  2. Define crop dimensions (optional).
  3. Select the target translation language.
  4. Process the file to extract text via OCR, translate, and merge the layout.
  5. Download your translated file in PDF or DOCX format.

๐Ÿ“Š Notes

  • Youโ€™ll need API keys for ConvertAPI and LightPDF API.
  • Update the script with your API keys and specify the destination language code.

๐Ÿ“ Dependencies

  • Streamlit: For the user-friendly web app.
  • PyMuPDF (fitz): Handles digital PDFs and converts pages to images.
  • Pillow (PIL): For image processing like cropping and resizing.
  • PyTesseract: Extracts text from scanned PDFs using OCR.
  • Googletrans: For language translation.
  • FPDF: Generates PDF files from translations.
  • PDF2Image: Converts PDF pages to images for OCR.

๐Ÿš€ APIs Utilized

  • LightPDF API: Enables OCR-based conversion of scanned PDFs.
  • ConvertAPI: Converts between PDF and other formats seamlessly.

๐Ÿ—ƒ๏ธ Output Files

  • Translated PDFs and DOCX files are saved in the documents/ folder.
  • Both formats preserve the layout and formatting of the original document.

๐Ÿ–Œ๏ธ Summary

PDF Linguist simplifies document management with:

  • High-accuracy text and image extraction.
  • Smooth translations in multiple languages.
  • Seamless merging while preserving original layouts.

๐Ÿ’ก The dual-mode functionality ensures youโ€™re ready for any type of PDF โ€“ digital or scanned. Manage and translate documents like a pro! ๐Ÿ”นโœจ

Contributors

NitinReddy-A

217 commits

pkr2805

2 commits

NitinReddy-A/PDF_Linguist

8

stars

221

commits

Python

primary language

Feb 15, 2025

updated

README

๐Ÿ”น PDF Linguist: A Seamless PDF Content Extraction, Merging, and Translation Tool

๐ŸŒ Overview

Meet PDF Linguist โ€“ your ultimate tool for extracting, merging, and translating PDF content! ๐ŸŒŸ Whether itโ€™s digital PDFs or scanned ones, this versatile app makes it a breeze to transform and translate documents while keeping the original formatting intact. Perfect for tackling all your document translation and manipulation needs! ๐Ÿ“„โœจ

๐Ÿ”น Key Highlights:

  1. Translation for Digital PDFs ๐Ÿ”
  2. Translation for Scanned PDFs ๐Ÿ”

All these features are wrapped up in a single app, giving you complete control over your PDF workflows. ๐Ÿ 


๐Ÿ”ง Features

โญ Digital PDFs

  • ๐Ÿ“„ Extract Text and Images: Quickly extract searchable text and embedded images.
  • ๐Ÿ’ฌ Translate Content: Convert text into your desired language effortlessly.
  • ๐Ÿ”  Render Complex Scripts: Perfect for Indic languages like Devanagari, thanks to the HarfBuzz engine to handle intricate ligatures and unicode combinations.
  • ๐ŸŒˆ Merge & Preserve Layout: Combines translated content while keeping the original layout intact.
  • ๐Ÿ”– Multiple Output Formats: Save your work as PDF and Word (DOCX).
  • ๐Ÿ”„ Multi-page Handling: Process multi-page documents seamlessly.

๐Ÿ” Scanned PDFs

  • ๐Ÿ” OCR-Based Extraction: Extract text from scanned images using Tesseract OCR.
  • ๐Ÿ•’ Customizable Cropping: Select specific dimensions to exclude unwanted sections.
  • ๐Ÿ’ฌ Translate Content: High-quality translations for regional languages.
  • ๐ŸŽจ Merge & Preserve Layout: Seamlessly combine translated text with the scanned PDFโ€™s layout.
  • ๐Ÿ”– Multiple Output Formats: Export translations as PDF and Word (DOCX).

๐Ÿ› ๏ธ Installation

Prerequisites

  1. Python installed on your system.
  2. Recommended: Virtual environment setup.

Steps

  1. Clone the repository:

    git clone https://github.com/NitinReddy-A/PDF_Linguist.git
    
  2. Navigate to the project directory:

    cd PDF_Linguist
    
  3. Set up a virtual environment (optional):

    python -m venv virtual-env
    source virtual-env/bin/activate  # Linux/Mac
    virtual-env\Scripts\activate    # Windows
    
  4. Install dependencies:

    pip install -r requirements.txt
    

๐ŸŽจ Usage

Step 1: Prepare Your PDF Document

Place the PDF file you want to process in the documents/ folder.

Step 2: Run the Application

Launch the app using Streamlit:

streamlit run app.py

Step 3: Select PDF Type

  • Digital PDF: For PDFs with searchable text.
  • Scanned PDF: For image-based PDFs needing OCR.

๐Ÿ”น Digital PDFs

  1. Upload your PDF using the file uploader.
  2. Choose the target language for translation.
  3. Click the button to extract, translate, and reassemble the PDF.
  4. Download your translated file in PDF or DOCX format.

๐Ÿ”น Scanned PDFs

  1. Upload your scanned PDF.
  2. Define crop dimensions (optional).
  3. Select the target translation language.
  4. Process the file to extract text via OCR, translate, and merge the layout.
  5. Download your translated file in PDF or DOCX format.

๐Ÿ“Š Notes

  • Youโ€™ll need API keys for ConvertAPI and LightPDF API.
  • Update the script with your API keys and specify the destination language code.

๐Ÿ“ Dependencies

  • Streamlit: For the user-friendly web app.
  • PyMuPDF (fitz): Handles digital PDFs and converts pages to images.
  • Pillow (PIL): For image processing like cropping and resizing.
  • PyTesseract: Extracts text from scanned PDFs using OCR.
  • Googletrans: For language translation.
  • FPDF: Generates PDF files from translations.
  • PDF2Image: Converts PDF pages to images for OCR.

๐Ÿš€ APIs Utilized

  • LightPDF API: Enables OCR-based conversion of scanned PDFs.
  • ConvertAPI: Converts between PDF and other formats seamlessly.

๐Ÿ—ƒ๏ธ Output Files

  • Translated PDFs and DOCX files are saved in the documents/ folder.
  • Both formats preserve the layout and formatting of the original document.

๐Ÿ–Œ๏ธ Summary

PDF Linguist simplifies document management with:

  • High-accuracy text and image extraction.
  • Smooth translations in multiple languages.
  • Seamless merging while preserving original layouts.

๐Ÿ’ก The dual-mode functionality ensures youโ€™re ready for any type of PDF โ€“ digital or scanned. Manage and translate documents like a pro! ๐Ÿ”นโœจ

Contributors

NitinReddy-A

217 commits

pkr2805

2 commits

Languages

Python

100.0%