This script fetches Markdown tables from the specified GitHub repository, extracts paper links, resolves them to PDF URLs, and downloads the PDFs. It supports various link formats, handles errors gracefully, and allows for parallel downloads. A JSON manifest of downloaded papers is generated for reference.
Marker PDF Converter - Reflex Framework
A modern web application built with Reflex that converts PDFs, images, and documents to Markdown, HTML, JSON, or chunks using the Marker library.
Features
- 📄 Multi-format Support: Convert PDFs, images, and documents (PNG, JPG, GIF, PPTX, DOCX, XLSX, HTML, EPUB)
- 🎨 Live Preview: View document pages in real-time as you navigate
- 📝 Multiple Output Formats: Export as Markdown, JSON, HTML, or chunks
- ⚡ Flexible Processing: Choose between fast, balanced, or auto processing modes
- 🔍 Advanced OCR Options: Control OCR behavior with granular settings
- 🤖 LLM Support: Optional LLM integration for higher quality processing
- 🐛 Debug Mode: Analyze document layout with debug visualizations
- 🎯 Page Range Selection: Process specific pages or page ranges
Installation
Prerequisites
- Python 3.11 or higher
- UV package manager (recommended) or pip
Setup
- Clone the repository:
git clone <repository-url>
cd reflex-framework-rebuild
- Install dependencies using UV:
uv sync
Or with pip:
pip install -e .
- Install Reflex CLI (if not included):
pip install reflex
Running the Application
Using Reflex Development Server
reflex run
The application will start on http://localhost:3000
Production Build
reflex build
reflex export
Then deploy the generated files or run:
reflex run --env prod
Usage Guide
Basic Workflow
-
Upload a Document
- Click the "Choose File" button in the left sidebar
- Select your PDF, image, or supported document format
-
Navigate (PDF only)
- Use the page number input or the arrow buttons to view different pages (page navigation is 1-based; page ranges remain zero-based)
- Preview updates in the left panel
-
Configure Conversion Options
- Output Format: Choose output type (markdown, JSON, HTML, chunks)
- Processing Mode:
auto: Automatically selects based on device (GPU = balanced, CPU/MPS = fast)balanced: Uses VLM layout model + full-page OCR (best on GPU)fast: Lightweight CPU detectors, only OCRs garbled/empty content
- Page Range: Specify which pages to process with zero-based ranges (e.g., "0,5-10,20")
-
Configure Advanced Options
- Use LLM: Enable for higher quality processing
- Force OCR: Force OCR on all pages
- Disable OCR: Skip OCR (text-layer extraction only)
- Strip Existing OCR: Re-OCR the document
- Show Page Headers/Footers: Include headers and footers in output
- Debug Mode: Generate debug visualizations
-
Run Conversion
- Click the "Run Conversion" button
- Monitor progress via status messages
- View results in the right panel (automatically formatted)
Output Formats
Markdown
- Clean, readable markdown representation
- Images embedded as base64-encoded HTML
- Tables, equations, and formatting preserved
JSON
- Structured data format
- Useful for programmatic processing
- Full metadata included
HTML
- Web-ready HTML output
- Fully styled and formatted
- Direct preview in browser
Chunks
- Segmented content
- Useful for RAG (Retrieval-Augmented Generation)
- JSON format with chunk metadata
Parts lists: Markdown tables → Excel
The marker output for parts / servicing manuals keeps the tables as Markdown.
scripts/md_tables_to_excel.py turns those tables into a ready-to-order Excel
spare-parts list:
- it extracts every table and remembers the heading above it as its component (that header is written on the first row of each worksheet);
- it understands two kinds of component tables and filters them accordingly:
- Part tables – a dedicated Part Number column exists; only the rows that carry a part number are kept (blank / duplicate rows are dropped, while wrapped text and quantities that belong to a part are merged back);
- Locator tables – no part number, but a Landmark / Rep. column
is used to locate parts or components on an illustration (common in
GUINAULT manuals); only the rows that carry a landmark are kept, and
side-by-side legends like
Landmark | Description | Landmark | Descriptionare flattened into one sortedLandmark | Descriptionlist.
- it also captures inline figure legends: parts/components printed under a
subtitle as a plain numbered paragraph (not a table), e.g. the DEUTZ engine
callouts
1\_Air pressure/temperature transmitter 2\_Oil filter cap 3\_Exhaust manifold …(the subtitle becomes the component, and a trailing(left view)-style line is kept in the component name); - it writes one worksheet per component (sheet name = component heading)
plus an
Indexoverview sheet (with aKindcolumn).
# CIMC TAM 7002 servicing manual: 53 part tables -> one sheet each
python scripts/md_tables_to_excel.py "conversion_results/1. Servicing Manual TAM 7002.pdf 01072026/1. Servicing Manual TAM 7002.pdf 01072026.md"
# GUINAULT GPU GA180 manual: Landmark legends + DEUTZ engine callouts
# (10 component sheets: figures + engine left/right view part lists)
python scripts/md_tables_to_excel.py "conversion_results/GUINAULT - GPU GA180 - Operation and maintenance manual (1)/GUINAULT - GPU GA180 - Operation and maintenance manual (1).md"# keep the non-component tables too (e.g. maintenance schedules)
python scripts/md_tables_to_excel.py manual.md --include-other-tables -o parts.xlsx
# scan a whole folder of markdown files
python scripts/md_tables_to_excel.py conversion_results -o all_manuals.xlsx
The parser deliberately targets the output that marker produces: headers can
span several rows, some converters merge the header with the first data row,
and cell text can wrap over several visual rows. Tables where several parts
were collapsed into a single header line (e.g. Item # 2 3 4 …) are expanded on
a best-effort basis and reported in the console so they can be double-checked.
Art books: PDF → images
scripts/pdf_images.py pulls the pictures out of an art book, portfolio or
scanned magazine. It copies the embedded streams verbatim (JPEG / JPEG 2000
are written byte-for-byte, no decode and no re-encode), so a 26-page art book
finishes in ~0.05 s and the output is bit-identical to the source artwork.
- walks page content recursively, so images nested in form XObjects are found too;
- de-duplicates identical images (a background reused on several pages is kept once);
- names files
<pdf>-p0001-01.jpg(page + index), so they sort back into reading order; --format png|jpg|webp|tifre-encodes from the decoded pixel data when you need a different container,--flattenbakes in alpha masks (transparency);--render-missingrasterizes the pages that hold no extractable image at all (vector or tiled art) at a chosen--dpi;- CMYK artwork is converted to sRGB by default. Print-sourced art books store
their JPEGs as CMYK with the samples inverted (Adobe marker) and usually no
colour profile, so anything that reads those samples literally — PIL, browsers,
VS Code — shows the page as a negative. PDFium does the conversion (it
honours the Adobe marker / embedded ICC), and the result is written as RGB JPEG
(
--quality, default 95) so it looks right everywhere.--cmyk keepcopies the original CMYK streams byte-for-byte instead, if you need them for print; --manifest out/manifest.jsonrecords page, size, filters and duplicates per image;- input can be a single PDF, a whole folder (scanned recursively) or a glob
pattern — a folder of art books converts in one command, and
-othen gives each PDF its own sub-folder.
# whole art book -> "God of War ..._images/" next to the PDF
python scripts/pdf_images.py "ingress/God of War Ragnarök - Digital Artbook.pdf"
# a folder, scanned recursively (hidden files/folders are skipped)
python scripts/pdf_images.py artbooks/
# a glob pattern -- quote it so the shell does not expand it first
python scripts/pdf_images.py "artbooks/**/*.pdf" -o out
# pages 1-12 and 40+, ignoring thumbnails and decoration
python scripts/pdf_images.py artbook.pdf -o out --pages 1-12,40- --min-px 256
# vector/tiled PDF: rasterize whatever had no embedded image
python scripts/pdf_images.py artbook.pdf --render-missing --dpi 300
# normalize to PNG with transparency flattened, plus a JSON manifest
python scripts/pdf_images.py artbook.pdf --format png --flatten --manifest out/manifest.json
# keep the original CMYK streams instead of converting them to sRGB
python scripts/pdf_images.py artbook.pdf --cmyk keep
Architecture
Components
-
State Management (
MarkerState):- Centralized state for file handling, options, and results
- Async conversion handling
-
UI Components:
render_sidebar(): Controls and optionsrender_preview(): Document preview with debug imagesrender_results(): Formatted output display
-
Backend Integration:
- Marker library integration for PDF/document conversion
- PyPDF integration for page extraction
- PIL for image handling
File Structure
ingressor/
├── src/ingressor/ # Main application package
│ ├── app.py # Reflex app bootstrap
│ ├── components.py # UI composition
│ ├── marker.py # Marker conversion helpers
│ └── state.py # Reflex state and actions
├── reflex_app.py # Legacy compatibility entrypoint
├── marker_converter/ # Reflex entrypoint module
├── rxconfig.py # Reflex configuration
├── pyproject.toml # Project dependencies
└── app/ # Legacy Streamlit helpers
Technology Stack
- Frontend Framework: Reflex (Python-based React)
- Backend: FastAPI (integrated with Reflex)
- Document Processing: Marker PDF
- PDF Handling: PyPDF, pypdfium2
- Image Processing: Pillow
Configuration
Environment Variables
# PyTorch/ML
PYTORCH_ENABLE_MPS_FALLBACK=1 # Enable MPS fallback on Apple Silicon
# Logging
GRPC_VERBOSITY=ERROR # Suppress gRPC logging
GLOG_minloglevel=2 # Suppress TensorFlow logging
Troubleshooting
Models not loading
- First run downloads large ML models (~2GB)
- Initial conversion may take 1-2 minutes
- Check internet connection
Memory issues
- Use "fast" mode for resource-constrained systems
- Process one page at a time
- Disable LLM and OCR if not needed
OCR not working
- Ensure scanned pages are high quality
- Enable "Force OCR" option
- Check debug images to verify detection
Layout detection issues
- Use "balanced" mode on GPU systems
- Check debug images in debug mode
- Try adjusting page range
Performance Tips
- GPU Systems: Use "balanced" mode for best quality
- CPU Systems: Use "fast" mode for reasonable speed
- Large Documents: Process page ranges instead of full documents
- Memory: Disable LLM if running low on memory
Development
Adding New Features
- Extend
MarkerStatefor new state variables - Add handler methods for new operations
- Create UI components with
rx.Componentreturn type - Integrate into main layout
Running Tests
# Run linting
reflex lint
# Format code
reflex format
Known Limitations
- Reflex rendering may be resource-intensive for very large PDFs
- Some advanced Marker features may require CLI usage
- Real-time live updates require WebSocket connection
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
Same license as the parent project
References
Support
For issues or questions:
- Check the Marker Issues
- Check the Reflex Docs
- Open an issue in this repository