Skip to main content

OCR while preserving document formatting and layout

Project description

🧾 ocralign

ocralign is an OCR utility built on top of Tesseract that preserves the layout and formatting of scanned documents. It supports both PDFs and images and outputs clean, structured text.


🔧 System Requirements

Before installing the Python package, you need to install some system dependencies required by pytesseract and pdf2image:

sudo apt update
sudo apt install -y tesseract-ocr
sudo apt install -y poppler-utils

Installation

pip install ocralign

Usage example

from ocralign import process_pdf, process_image

# OCR a single image
print(process_image("./sample.png"))

# OCR a multi-page PDF (returns list of text per page)
texts = process_pdf("./images-pdf.pdf", dpi=300)

# OCR a PDF and write result to a file
process_pdf("./images-pdf.pdf", dpi=300, output_path="test.txt")

Input image:

Sample OCR Input

Extracted Text 📎 See full output here

Sample Tables                                                                                = Print

 Tables used in papers can be so simple that they are "informal" enough to be a sentence member and not
 require a caption, or they can be complex enough that they require spreadsheets spanning several pages.
 A table’s fundamental purpose should always be to visually simplify complex material, in particular when
 the table is designed to help the reader identify trends. Here, a simple table and a complex table are used
 to demonstrate how tables help writers to record and "visualize" information and data.


 Simple Table

 The simple table that follows, from a student's progress report to his advisor, represents how tables need
 not always be about data presentation. Here the rows and columns simply make it easy for the writer to
 present the necessary information with efficiency. This unnumbered and informal table, in effect, explains
 itself.




                     Plan for Weekly Progress for the Remainder of the Semester

      Week of     Contact Dr. Berinni for relevant literature suggestions.
      11/28       Read lit reviews from Vibrational Spectroscopy.
                  Research experimental methods used to test polyurethanes, including infrared (IR)
                  spectroscopy and nuclear magnetic resonance (NMR).

      Week of     Define specific ways that polyurethanes can be improved.
      12/5        Develop experimental plan.

      Week of     Create visual aids, depicting chemical reactions and experimental setups.
      12/12       Prepare draft of analytical report.

      Week of     Turn in copy of preliminary analytical report, to be expanded upon next semester.
      12/18





 Complex Table

 The following sample table is excerpted from a student's senior thesis about tests conducted on
 Pennsylvania coal. Note the specificity of the table’s caption. Also note the level of discussion following the
 table, and how the writer uses the data from the table to move toward an explanation of the trends that
 the table reveals.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocralign-0.1.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ocralign-0.1.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file ocralign-0.1.1.tar.gz.

File metadata

  • Download URL: ocralign-0.1.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ocralign-0.1.1.tar.gz
Algorithm Hash digest
SHA256 87b21828bf551cafddafc23e3d1d77bcfc2527bdf7fd998242dc049cf8734c37
MD5 5f59fb6c9319f51db896368e74b6bb07
BLAKE2b-256 ada728fa5e54a1bc7712e70d9892bbb129f0d00de3b7faeb41519a214e035c2a

See more details on using hashes here.

File details

Details for the file ocralign-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ocralign-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ocralign-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0af556bf9b130c7482ffb10cad812ec8cde6faa1652161afaf181788f4b3370c
MD5 8712f84c9c5689a3919c91f0ea823bd0
BLAKE2b-256 dbac7247b28435b84e756754b9a5b150835e34326361a7ea8e7e2ae921d18fdd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page