An open API service indexing awesome lists of open source software.

https://github.com/cantabular/pdf2msgpack

Efficiently export PDF content in an easily machine readable format
https://github.com/cantabular/pdf2msgpack

msgpack pdf poppler

Last synced: 6 months ago
JSON representation

Efficiently export PDF content in an easily machine readable format

Awesome Lists containing this project

README

          

# About

`pdf2msgpack` is designed to efficiently dump information from a PDF in a portable format which is easy to consume without heavyweight PDF libraries.

At the moment it dumps glyphs (a rectangle and text) and path information.

# `pdf2msgpack` is Alpha Software

`pdf2msgpack` is used internally at The Sensible Code company. It's still quite young and the output might change significantly.

# Installation

To configure and build, run:

```
./waf configure
./waf build
```

There is an accompanying docker file which enables building a static binary.

To build the static binary, just ensure submodules are checked out and
invoke `make`.

```
git submodule update --init
make
```

# Running

```
./pdf2msgpack
```

# Output

`pdf2msgpack` writes its output to [msgpack](http://msgpack.org), which is a convenient, fast serialization format with libraries available in many languages.

Here is a description of the wire format.

At the top level the document is not a list but consecutive objects written to
the stream.

```
document (consecutive objects): ...

metadata (dict): {
"Pages": int,
"FileName": str,
"XFA": dict,
"EmbeddedFiles": [...],
"FontInfo": [...],
(other string fields supplied in PDF),
}

page (dict): {
"Size": [, ],
"Glyphs": [...],
"Paths": [...],
"Bitmap": [ [, ], ]
}

embedfile (list):
[ , , ,
, , ]

pathitem (list): [,
[...]]

pathdata (list): depending on pathitem type
EO_FILL, FILL, STROKE: pathcoord
SET_FILL_COLOR: [, , ]
SET_STROKE_WIDTH:

pathcoord (2 list or 6 list):
point: [, ]
quadratic curve: [, , , , , ]

fontinfo (dict): { }
```

# Options

Some of the options affect the wire format generated by the command.

* `--meta-only`: changes `document` to skip generation of `page` objects.
* `--bitmap`: generate grayscale bitmap in `page` object (otherwise absent)
* `--xfa`: generate XML Forms Architecture (XFA) data in `metadata` object (otherwise nil)
* `--embedded-files`: generate embedded files in `metadata` object (otherwise nil)

# Licence

`pdf2msgpack` is licensed under the GPLv2.