pdf-corruption-lab / README.md
islam ayoub
Update links after organization rename
7079631 verified
|
Raw History Blame Contribute Delete
2.94 kB
---
license: mit
task_categories:
- tabular-classification
tags:
- pdf
- pdf-repair
- test-corpus
- synthetic
pretty_name: PDF Corruption Lab
size_categories:
- 1K<n<10K
configs:
- config_name: features
data_files: features/train.csv
default: true
---
# pdf-corruption-lab
A **fully synthetic** corpus of damaged PDF files with a known kind and severity
of damage, the scripts that generate it, and a ready-to-use feature table.
It is meant for testing and benchmarking PDF repair / recovery tools and for
training small damage-type classifiers.
Everything here is original: documents are built from scratch with
[`pdf-lib`](https://github.com/Hopding/pdf-lib) (MIT). No third-party
documents or models are included.
## What is in this repository
| Path | Description |
|---|---|
| `output/` | 7 hand-checkable reference files: one valid PDF and 6 damaged variants, plus `manifest.json` |
| `training/` | 1,200 randomized PDFs (200 per class: pages, fonts, text and images vary) and `labels.csv` |
| `features/train.csv` | 12 byte-level structural features + label for each training file (powers the dataset viewer) |
| `generate.js` | regenerates the reference files in `output/` |
| `gen_training.js` | regenerates the randomized training set (seeded, reproducible) |
## Damage classes
| Class | Damage | Severity (1-5) |
|---|---|---|
| `valid` | none | 0 |
| `missing_eof` | trailing `%%EOF` removed | 1 |
| `invalid_startxref` | `startxref` value is non-numeric | 2 |
| `scrambled_xref` | xref offsets replaced with bogus values | 3 |
| `bad_root_reference` | trailer `/Root` points to a missing object | 3 |
| `truncated` | file cut at a random point (30-90 % of its length) | 4-5 |
## Features (`features/train.csv`)
`has_pdf_header`, `eof_in_last_1k`, `ends_with_eof`, `startxref_present`,
`startxref_numeric`, `startxref_points_to_xref`, `xref_valid_fraction`,
`has_trailer`, `root_object_exists`, `obj_endobj_gap`, `stream_endstream_gap`,
`log10_size`, and `label`. The extraction code is in the model repo:
[`utilvo-com/pdf-damage-classifier`](https://huggingface.co/utilvo-com/pdf-damage-classifier).
## Regenerate
```bash
npm install
node generate.js ./output
node gen_training.js ./training 200
```
## Suggested evaluation for repair tools
For each damaged file, run your tool and record:
1. Does the output open in a strict parser?
2. How many pages were recovered?
3. Was the embedded image preserved (where present)?
## Limitations
All files are generated by `pdf-lib` with classic xref tables (no object streams
or xref streams) and each file has a single kind of damage. Real-world
corruption (bit flips, mixed damage, files from other producers, encryption) is
not represented. Treat results here as a controlled benchmark, not as a
guarantee for real files.
## Disclosure
Maintained by the Utilvo team. The organization profile links to our website.
## License
MIT. See `LICENSE`.