Skip to main content

PDF parser and analyzer

Project description

# PDFMiner

PDFMiner is a text extraction tool for PDF documents.

[![Build Status](https://travis-ci.org/euske/pdfminer.svg?branch=master)](https://travis-ci.org/euske/pdfminer) [![PyPI](https://img.shields.io/pypi/v/pdfminer)](https://pypi.org/project/pdfminer/)

Warning: As of 2020, PDFMiner is not actively maintained. The code still works, but this project is largely dormant. For the active project, check out its fork <a href=”https://github.com/pdfminer/pdfminer.six”>pdfminer.six</a>.

## Features:

  • Pure Python (3.6 or above).

  • Supports PDF-1.7. (well, almost)

  • Obtains the exact location of text as well as other layout information (fonts, etc.).

  • Performs automatic layout analysis.

  • Can convert PDF into other formats (HTML/XML).

  • Can extract an outline (TOC).

  • Can extract tagged contents.

  • Supports basic encryption (RC4 and AES).

  • Supports various font types (Type1, TrueType, Type3, and CID).

  • Supports CJK languages and vertical writing scripts.

  • Has an extensible PDF parser that can be used for other purposes.

## How to Use:

1. > pip install pdfminer 1. > pdf2txt.py samples/simple1.pdf

## Command Line Syntax:

### pdf2txt.py

pdf2txt.py extracts all the texts that are rendered programmatically. It also extracts the corresponding locations, font names, font sizes, writing direction (horizontal or vertical) for each text segment. It does not recognize text in images. A password needs to be provided for restricted PDF documents.

> pdf2txt.py [-P password] [-o output] [-t text|html|xml|tag]

[-O output_dir] [-c encoding] [-s scale] [-R rotation] [-Y normal|loose|exact] [-p pagenos] [-m maxpages] [-S] [-C] [-n] [-A] [-V] [-M char_margin] [-L line_margin] [-W word_margin] [-F boxes_flow] [-d] input.pdf …

  • -P password : PDF password.

  • -o output : Output file name.

  • -t text|html|xml|tag : Output type. (default: automatically inferred from the output file name.)

  • -O output_dir : Output directory for extracted images.

  • -c encoding : Output encoding. (default: utf-8)

  • -s scale : Output scale.

  • -R rotation : Rotates the page in degree.

  • -Y normal|loose|exact : Specifies the layout mode. (only for HTML output.)

  • -p pagenos : Processes certain pages only.

  • -m maxpages : Limits the number of maximum pages to process.

  • -S : Strips control characters.

  • -C : Disables resource caching.

  • -n : Disables layout analysis.

  • -A : Applies layout analysis for all texts including figures.

  • -V : Automatically detects vertical writing.

  • -M char_margin : Speficies the char margin.

  • -W word_margin : Speficies the word margin.

  • -L line_margin : Speficies the line margin.

  • -F boxes_flow : Speficies the box flow ratio.

  • -d : Turns on Debug output.

### dumppdf.py

dumppdf.py is used for debugging PDFs. It dumps all the internal contents in pseudo-XML format.

> dumppdf.py [-P password] [-a] [-p pageid] [-i objid]

[-o output] [-r|-b|-t] [-T] [-O directory] [-d] input.pdf …

  • -P password : PDF password.

  • -a : Extracts all objects.

  • -p pageid : Extracts a Page object.

  • -i objid : Extracts a certain object.

  • -o output : Output file name.

  • -r : Raw mode. Dumps the raw compressed/encoded streams.

  • -b : Binary mode. Dumps the uncompressed/decoded streams.

  • -t : Text mode. Dumps the streams in text format.

  • -T : Tagged mode. Dumps the tagged contents.

  • -O output_dir : Output directory for extracted streams.

## TODO

  • Replace STRICT variable with something better.

  • Improve the debugging functions.

  • Use logging module instead of sys.stderr.

  • Proper test cases.

  • PEP-8 and PEP-257 conformance.

  • Better documentation.

  • Crypto stream filter support.

## Related Projects

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

pdfminer-with-logger-1.0.0.tar.gz (4.2 MB view details)

Uploaded Source

Built Distribution

pdfminer_with_logger-1.0.0-py3-none-any.whl (6.1 MB view details)

Uploaded Python 3

File details

Details for the file pdfminer-with-logger-1.0.0.tar.gz.

File metadata

  • Download URL: pdfminer-with-logger-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.9

File hashes

Hashes for pdfminer-with-logger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 377ba27e72656c79f14f4e93de1304e99de42c612ee2f93f85fc5b0690a8ad2c
MD5 a797d32ba54cace3931797a90fc62919
BLAKE2b-256 0a496d9bc6d37676557b0820cb840af55f342a4ac0dfe441e2161052c989bda2

See more details on using hashes here.

File details

Details for the file pdfminer_with_logger-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pdfminer_with_logger-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.9

File hashes

Hashes for pdfminer_with_logger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78c58ddc2275ac9c803e5b29513b49dc6e2b94e83819e7e573cfee3ae2762bf5
MD5 ca6369459e5b66b3a0413b3922eda57e
BLAKE2b-256 fdc077bd11d3a1e061178845a60ddca6ed1ae61a20a5f316827a6aefd7cebfa9

See more details on using hashes here.

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