pdftract/templates/sdk-skeleton/go
jedarden 4777c3d0c3 feat(pdftract-1534): complete Tera-template-driven code generator
Add verify_receipt method support to Go templates:
- client.go.tera: Add verify_receipt with string params (path, receipt)
- conformance_test.go.tera: Add testVerifyReceipt test case

Code generator cleanup:
- Add uses_string_params and string_param_count to Method struct
- Fix unused variable warnings in contract parsing
- Document TODO for full markdown contract parsing

Verification:
- All 9 methods generated correctly (extract, extract_text, extract_markdown, extract_stream, search, get_metadata, hash, classify, verify_receipt)
- All 7 error types generated with exit code mapping
- Drift detection working (validate command)
- Protection against overwriting hand-written code (GENERATED marker)

See notes/pdftract-1534.md for full acceptance criteria status.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 01:48:27 -04:00
..
client.go.tera feat(pdftract-1534): complete Tera-template-driven code generator 2026-05-18 01:48:27 -04:00
conformance_test.go.tera feat(pdftract-1534): complete Tera-template-driven code generator 2026-05-18 01:48:27 -04:00
errors.go.tera fix(pdftract-2hm4): fix hex string lexer invalid char handling and whitespace/comment skipping 2026-05-18 01:47:17 -04:00
GENERATED.tera fix(pdftract-2hm4): fix hex string lexer invalid char handling and whitespace/comment skipping 2026-05-18 01:47:17 -04:00
go.mod.tera fix(pdftract-2hm4): fix hex string lexer invalid char handling and whitespace/comment skipping 2026-05-18 01:47:17 -04:00
README.md.tera fix(pdftract-2hm4): fix hex string lexer invalid char handling and whitespace/comment skipping 2026-05-18 01:47:17 -04:00
types.go.tera fix(pdftract-2hm4): fix hex string lexer invalid char handling and whitespace/comment skipping 2026-05-18 01:47:17 -04:00

# pdftract-go

Go SDK for pdftract - PDF extraction and conformance testing.

## Installation

```bash
go get github.com/jedarden/pdftract-go@{{ version }}
```

## Usage

### Basic extract

```go
package main

import (
    "fmt"
    "github.com/jedarden/pdftract-go"
)

func main() {
    client := pdftract.NewClient()
    doc, err := client.Extract("document.pdf", nil)
    if err != nil {
        panic(err)
    }
    fmt.Printf("Pages: %d\n", len(doc.Pages))
}
```

### Extract with OCR

```go
options := &pdftract.ExtractOptions{
    OCRLanguage: "eng",
    OCRThreshold: 0.7,
}
doc, err := client.Extract("scanned.pdf", options)
```

### Search

```go
matches, err := client.Search("document.pdf", "invoice", &pdftract.SearchOptions{
    CaseInsensitive: true,
})
for match := range matches {
    fmt.Printf("Found on page %d: %s\n", match.Page, match.Text)
}
```

## Binary version compatibility

This SDK requires pdftract {{ version }}. Download from:
https://github.com/jedarden/pdftract/releases/tag/v{{ version }}

## Troubleshooting

### Binary not found
Ensure `pdftract` is on your PATH. The SDK probes PATH for the executable.

### Version mismatch
The SDK will refuse to invoke mismatched binary versions. Install the correct version.

### Network failure
For remote URLs, check your network connection and TLS certificate chain.