Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgedmin/pdf2html
Wrapper for pdftohtml that tries to extract paragraph structure
https://github.com/mgedmin/pdf2html
Last synced: about 2 months ago
JSON representation
Wrapper for pdftohtml that tries to extract paragraph structure
- Host: GitHub
- URL: https://github.com/mgedmin/pdf2html
- Owner: mgedmin
- Created: 2014-08-01T12:09:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-11-29T12:33:20.000Z (about 6 years ago)
- Last Synced: 2024-10-13T18:27:47.603Z (2 months ago)
- Language: Python
- Size: 35.2 KB
- Stars: 48
- Watchers: 7
- Forks: 32
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
pdf2html
========Converts PDF e-books to HTML. Relies on the PDF actually having text (not images).
It's a wrapper for pdftohtml_ (from poppler-utils) that tries to restore paragraph
structure by looking at text positioning and font information. It requires Python 2.The HTML produced differs from the one you'd get from pdftohtml in these ways:
* Paragraphs are preserved; line breaks inside paragraphs are lost.
* Multiple adjacent spaces are left as spaces, not converted to a run of
* Page boundaries are discarded, not rendered as
* The HTML produced is modern XHTML, not ancient HTML 3 with an explicit dark-grey
bgcolor on the (what's up with that???)... _pdftohtml: https://poppler.freedesktop.org/
Usage
-----Usage: pdf2html input.pdf [output.html]
Options:
-h, --help show this help message and exit
--version print version and exit
--debug print verbose diagnostics
--keep keep temporary files
--title=TITLE document title
--subtitle=SUBTITLE document subtitle
--header-pos=HEADER_POS
suppress text above this point (header)
--footer-pos=FOOTER_POS
suppress text below this point (footer)
--leading=LEADING override autodetected intra-paragraph leading
--indent=INDENT override autodetected indent
--left-margin=LEFT_MARGIN
override autodetected left margin
--horiz-leeway=HORIZ_LEEWAY
override autodetected horizontal leeway
--skip-initial-pages=SKIP_INITIAL_PAGES
skip the first N pages of output
--skip-generator skip
--encoding=ENCODING character set for the HTML
Configuration
-------------Put a .pdf2htmlrc in the same directory as the source PDF file. Every
section, denoted [pattern] can apply options to files matching the
pattern, e.g. ::[hello.pdf]
header_pos = 166
[*.pdf]
footer_pos = -1
All options you can specify on the command line can be specified
in the config file (with the obvious exceptions of --version and --help).Currently the most useful options you can specify this way are header and
footer positions if you want to suppres header/footer text from the output.
The position is specified in points, with 0 at the top of the page,
increasing downwards. All text above the header pos as well as all text
below the footer pos is discarded. Specify -1 (which is the default) to
disable. To find out the right values, use --keep and take a look at
text coordinates in the intermediate .xml file.Bugs
----* it's not easy to use; overriding the heuristics when they go wrong requires a deep knowledge of the internals
* doesn't handle superscript well
* doesn't handle small caps
* loses information such as fonts and colours
* there are no tests
* it doesn't support Python 3