Git Product home page Git Product logo

optimize-pdf-ereaders's Introduction

About

PDF books and articles found online are usually poorly rendered on small e-readers (e.g. Kindle Oasis), as a whole PDF page is displayed on the small screen.

This lib uses OCR to correct the skewed angle of the page, crop around the text and re-paginate; as to optimize for the best reading experience on small e-readers.

The code was initially written in 2018 in Java, alongside an online converter website that I decided to take down as it would cost quite a bit (OCR and image processing being quite resource-intensive). I also couldn't maintain it as I was working full time.

Therefore, the project probably needs a bit of a cleanup.

The unit tests using full PDF books can not be shared publicly, so I will re-add them later, using only individual pages rather than complete books.

Examples

Example 1

Input

download PDF

Output

download PDF

Example 2

Input

download PDF

Output

download PDF

Example 3

Input

download PDF

Output

download PDF

Requirements

sudo apt-get install tesseract-ocr

The data in tessdata/ is found on https://github.com/tesseract-ocr/tessdata_best

Usage

    RequestConfig requestConfig = RequestConfig
        .builder()
        .pdfFile(file)
        .minPage(minPage)
        .maxPage(maxPage)
        .correctAngle(true)
        .build();

    Processor processor = new Processor(requestConfig);
    processor.process();
    processor.joinThread();
    File outputFile = processor.writeToPDFFile(fileName + "_optimized.pdf");

TODO

  • Move to Gradle
  • Re-add unit tests that can be shared publicly, adapt the other ones
  • Add language as a parameter
  • Create a user-friendly runnable
  • Move to Kotlin
  • Finish picture detection

optimize-pdf-ereaders's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.