Skip to main content

Python package for combining .hocr files and images into searchable PDFs

Project description

HOCkeR

Python package for combining hOCR files and images into searchable PDFs

Table of Contents

  1. What is hoCKeR?
  2. How to install
  3. How to Use
  4. Credits

What is hOCkeR?

HOCkeR is a Python package for combining hOCR files and images into searchable PDFs. The package lays the text on top of the image, and then creates a PDF with the text and image. The code used is from HOCRConverter by jbrinley. The code was designed for Python 2, therefore does not work with newer version of python, so I created this package as an update to the original code.

How to install

To install the package, run the following command within a python environment:

pip install hocker

If any errors occur whilst installing, try using the .whl file instead linked here

How to use hOCkeR

Below is an example of how to use hOCkeR to combine an png and a .hocr file into a PDF

import hocker as hkr

image_path = 'path/to/image.png'
hocr_path = 'path/to/image.hocr'

# Specify the element in the hocr file to use as the text
hocr = hkr.HOCRCombiner('ocrx_word') # For tesseract outputs, it is 'ocrx_word'

# Specify the hocr and image path
hocr.locate_image(image_path)
hocr.locate_hocr(hocr_path)

# Output the PDF
hocr.to_pdf('path/to/output.pdf')

Credits & links

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

hocker-1.0.4.tar.gz (280.4 kB view hashes)

Uploaded Source

Built Distribution

hocker-1.0.4-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

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