pdftract/templates/sdk-skeleton/java/README.md.tera
jedarden 11257e7706 feat(pdftract-l993m): complete per-language Tera template scaffolding
Complete the Tera template scaffolding for all 8 subprocess-based SDKs
under templates/sdk-skeleton/<lang>/: node, go, java, dotnet, ruby,
php, swift, python-subprocess.

Each template directory contains:
- Package metadata template (package.json, go.mod, pom.xml, etc.)
- Method stubs template (methods.ts, client.go, Methods.java, etc.)
- Error stubs template (errors.ts, errors.go, Errors.java, etc.)
- Conformance runner template (conformance.test.ts, etc.)
- README template with {{ version }} variable substitution
- GENERATED.tera marker file

New files for python-subprocess:
- pdftract_subprocess/codegen/errors.py.tera
- tests/codegen/conformance_test.py.tera
- README.md.tera
- GENERATED.tera

All 8 language template directories are now complete and ready for
consumption by the `pdftract sdk codegen` subcommand.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-05-18 02:01:46 -04:00

73 lines
1.7 KiB
Text

# pdftract-java
Java SDK for pdftract - PDF extraction and conformance testing.
## Installation
```xml
<dependency>
<groupId>com.jedarden</groupId>
<artifactId>pdftract</artifactId>
<version>{{ version }}</version>
</dependency>
```
## Usage
### Basic extract
```java
import com.jedarden.pdftract.Pdftract;
import com.jedarden.pdftract.codegen.PathSource;
try (Pdftract client = new Pdftract()) {
Document doc = client.extract(new PathSource("document.pdf"));
System.out.println("Pages: " + doc.pages().size());
}
```
### Extract with OCR
```java
ExtractOptions options = new ExtractOptions();
options.setOcrLanguage("eng");
options.setOcrThreshold(0.7);
Document doc = client.extract(new PathSource("scanned.pdf"), options);
```
### Search
```java
import java.util.concurrent.Flow;
client.search(new PathSource("document.pdf"), "invoice", null)
.subscribe(match -> {
System.out.println("Found on page " + match.page() + ": " + match.text());
});
```
### Stream extraction
```java
client.extractStream(new PathSource("large.pdf"), null)
.subscribe(page -> {
System.out.println("Page " + page.page() + ": " + page.blocks().size() + " blocks");
});
```
## 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.