Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Adding preprocess.bat #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions preprocess.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@ECHO OFF

IF %2.==. (
ECHO Please provide an output directory and an input PDF. Example: pdf2hocr ./ocrd ~/Downloads/document.pdf
EXIT /b
)

MKDIR %1
MKDIR %1\png
MKDIR %1\tesseract
MKDIR %1\annotated
MKDIR %1\tables

gswin64c -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -r600 -sOutputFile="%1/png/page_%%d.png" %2

COPY %2 %1\orig.pdf
pdftotext %1\orig.pdf - -enc UTF-8 > %1\text.txt

for /R "%1\png" %%f in (*.png) do (
tesseract %1\png\%%~nf.png %1\tesseract\%%~nf.html hocr
move %1\tesseract\%%~nf.html.hocr %1\tesseract\%%~nf.html
python annotate.py %1/tesseract/%%~nf.html %1/annotated/%%~nf.png
)