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
- Host: GitHub
- URL: https://github.com/cantabular/pdf2msgpack
- Owner: cantabular
- License: gpl-2.0
- Created: 2016-04-12T10:59:52.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2025-09-19T12:05:40.000Z (11 months ago)
- Last Synced: 2025-09-20T10:01:59.557Z (10 months ago)
- Topics: msgpack, pdf, poppler
- Language: Go
- Homepage:
- Size: 1.57 MB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE.seccomp
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.