Skip to content

Commit 214f699

Browse files
committed
Update Readme
1 parent f2cc48b commit 214f699

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
[![Test](https://github.com/speedata/pdfdisassembler/actions/workflows/test.yml/badge.svg)](https://github.com/speedata/pdfdisassembler/actions/workflows/test.yml)
44
[![Coverage](https://github.com/speedata/pdfdisassembler/raw/badges/.badges/main/coverage.svg)](https://github.com/speedata/pdfdisassembler/actions/workflows/test.yml)
5+
[![Go Reference](https://pkg.go.dev/badge/github.com/speedata/pdfdisassembler.svg)](https://pkg.go.dev/github.com/speedata/pdfdisassembler)
6+
57

68
A focused, read-only PDF parser for Go. Built for tooling that **inspects**
79
PDFs — accessibility checkers, validators, debuggers — without dragging in
810
the writing, optimisation, signing and image-rendering machinery that
911
general-purpose PDF libraries carry.
1012

13+
Full API documentation: <https://pkg.go.dev/github.com/speedata/pdfdisassembler>
14+
1115
## Status
1216

1317
Pre-1.0. The API may break between minor releases.
@@ -35,6 +39,8 @@ verification, content-stream graphics-state interpretation, LTV.
3539

3640
## Usage
3741

42+
Open a file and read top-level metadata:
43+
3844
```go
3945
import "github.com/speedata/pdfdisassembler"
4046

@@ -49,6 +55,36 @@ info := r.DocumentInfo()
4955
fmt.Println("Title:", info.Title)
5056
```
5157

58+
Walk every live indirect object and decode any streams that carry one of
59+
the supported filters:
60+
61+
```go
62+
r, err := pdfdisassembler.OpenFile("doc.pdf")
63+
if err != nil {
64+
return err
65+
}
66+
defer r.Close()
67+
68+
for entry := range r.Objects() {
69+
s, ok := entry.Object.(*pdfdisassembler.Stream)
70+
if !ok {
71+
continue
72+
}
73+
ref := entry.Reference
74+
data, err := r.DecodeStream(ref)
75+
if err != nil {
76+
fmt.Printf("%d %d R: %v\n", ref.Number, ref.Generation, err)
77+
continue
78+
}
79+
fmt.Printf("%d %d R: %d bytes raw, %d bytes decoded\n",
80+
ref.Number, ref.Generation, s.RawLength(), len(data))
81+
}
82+
```
83+
84+
More complete examples live under [`examples/`](examples): `inspect`
85+
prints a summary of a PDF, `structtree` walks the `/StructTreeRoot` as a
86+
starting point for accessibility tooling.
87+
5288
## Testing
5389

5490
Snapshot tests live under `testdata/fixtures/<name>/`. Each fixture has an

0 commit comments

Comments
 (0)