https://github.com/luciopaiva/pdfhacker
A low-level PDF file parser (still a work in progress).
https://github.com/luciopaiva/pdfhacker
Last synced: 6 months ago
JSON representation
A low-level PDF file parser (still a work in progress).
- Host: GitHub
- URL: https://github.com/luciopaiva/pdfhacker
- Owner: luciopaiva
- License: mit
- Created: 2014-10-11T14:24:55.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T17:53:53.000Z (almost 3 years ago)
- Last Synced: 2024-04-13T23:54:58.353Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.04 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
PDF Hacker
==========[](https://travis-ci.org/luciopaiva/pdfhacker)
[](https://coveralls.io/r/luciopaiva/pdfhacker)**Beware this is a WIP in its early stages!**
The goal of this project is to have a lib that allows you to programmatically read from (and possibly write to) PDF files. It is meant as a low-level PDF file editor API.
## Features
Basic PDF info:
const pdf = pdfhacker('test.pdf');
> console.dir(pdf.version);
{
major: 1,
minor: 5
}Simple text replacement:
pdf.replace('foo', 'bar').saveTo('out.pdf');
Will replace all occurrences of ``foo`` with ``bar``, finally saving to file ``out.pdf``.
Chaining:
.replace('foo', 'bar')
.replace(/\d{3}/, '456')
.saveTo('out.pdf');Will replace all occurrences of ``foo`` with ``bar`` and will also replace all ``123`` with ``456``, finally saving to file ``out.pdf``.
Display object tree:
> pdf.dumpTree();
Root
|- Catalog
|- Page 1
|- Page 2
...Change specific objects:
pdf('/Root/Catalog/Page 1/Text')[0].val('first text object will be affected');
pdf('/Root/Catalog/Page 1/Text').val('all page 1 text objects will be affected');