Samples
FenScribe Graphical User Interface
Example of PDF Optimization
Key Features
- Detect and remove long blank regions (by brightness threshold). New: marginal scan edge trimming (advanced option).
- Split pages into content segments (pre-line) and save as individual images.
- Optional Word export: insert segments into a
.docxtemplate. - New: Automatic image width fitting for Word documents using
python-docx, reducing the need for post-processing macros.
Installation & Dependencies
1. First, download or clone the repository:
- Option A (Git): Clone the repository using Git:
git clone https://github.com/ordylan/FenScribe.git cd FenScribe - Option B (Download ZIP): Download the ZIP file from the GitHub page: https://github.com/ordylan/FenScribe. Then, unzip the file and navigate into the extracted directory in your terminal.
2. Install the required Python libraries using pip:
pip install PyMuPDF Pillow python-docx tkinterdnd2 pywin32
Note: pywin32 is required only if you want the program to inject/run VBA macros in Word (Windows only). If you only need image output or python-docx insertion, Word and pywin32 are optional.
Usage
- Navigate to the directory where you downloaded/cloned FenScribe.
- Run
gui.pywfor the graphical interface (CLI version currently unavailable). Double-click the file or runpython gui.pywin your terminal. - After processing, the output Word document (
output_*.docx) will be saved in the__Output/directory.
Typical Workflow
- Select a PDF file, single image, or a folder containing images.
- Tune parameters in Step 2 (threshold, DPI, min_height, blank_height).
- Choose a
.docxtemplate in Step 3 if Word output is desired. - Start processing. Images/segments are saved under
_temp/<input>_segments. If Word insertion is enabled, the final document is written to__Output/output_<basename>.docx.
Configuration Parameters
These parameters can be adjusted within the GUI or potentially in a future configuration file:
| Parameter | Description |
|---|---|
| threshold | Brightness threshold for blank line detection (0-255). Converts RGB to grayscale average; rows ≥ threshold are considered blank. Higher values detect lighter grays as blank. |
| dpi | Image resolution (Dots Per Inch) used when converting PDF pages to images for analysis. Higher DPI increases precision but also processing time and memory usage. |
| min_height | Content validity filter (in pixels). Only preserves content blocks with height ≥ this value. Helps filter out small noise or artifacts. |
| blank_height | Paragraph separation baseline (in pixels). Content is split into separate paragraphs when consecutive blank lines reach this height. Defines the minimum vertical gap considered a paragraph break. |
Macros & Word Automation
The app can optionally inject and run a VBA macro from the _Macros folder after producing the .docx file. That requires Microsoft Word and pywin32 (Windows only).
Enable VBA access in Word: File → Options → Trust Center → Trust Center Settings → Macro Settings → Trust access to the VBA project object model.
Note: the program now attempts to auto-fit images to the document/column width using python-docx. The macro remains available as an optional post-processing step.
Troubleshooting
- If Word macro injection fails with an access error, verify the VBA trust setting described above.
- If Word is not installed or
pywin32is missing, use the advanced optionDo not insert Wordto only save images. - For scanned documents with slanted pages, run a deskew/preprocessing step first.
- Small images or geometric shapes might be accidentally removed or cropped during blank space removal if they fall below the
min_heightthreshold. - Narrow vertical images or color blocks could be misidentified as separators; adjusting
min_heightorthresholdmay help. - Manual margin trimming might still be required in the source PDF or output Word document to remove headers/footers.
- Performance depends on PDF complexity, DPI setting, and system resources.
License
This project is licensed under the MIT License.
Development Notes
This third-generation version of FenScribe features:
- A Graphical User Interface (GUI) implementation for more user-friendly operation.
- Partial utilization of AI-assisted development tools during its creation.
- Continuous optimization and refinement through multiple development iterations.
- Focus on converting PDF content to Word format (
.docx) for easier editing and manipulation post-processing.