47 lines
1.0 KiB
Markdown
47 lines
1.0 KiB
Markdown
|
|
```swift title="Swift"
|
||
|
|
import Kreuzberg
|
||
|
|
|
||
|
|
final class PdfOnlyProcessor: PostProcessor {
|
||
|
|
func name() -> String {
|
||
|
|
"pdf-only-processor"
|
||
|
|
}
|
||
|
|
|
||
|
|
func version() -> String {
|
||
|
|
"1.0.0"
|
||
|
|
}
|
||
|
|
|
||
|
|
func processingStage() -> String {
|
||
|
|
"middle" // ProcessingStage enum name
|
||
|
|
}
|
||
|
|
|
||
|
|
func priority() -> Int32 {
|
||
|
|
50 // Default priority
|
||
|
|
}
|
||
|
|
|
||
|
|
func process(result: ExtractionResult, config: ExtractionConfig) -> String {
|
||
|
|
// Returns JSON-encoded Result<(), String>
|
||
|
|
// No-op post-processor for PDF-only processing
|
||
|
|
"{\"ok\": null}"
|
||
|
|
}
|
||
|
|
|
||
|
|
func shouldProcess(result: ExtractionResult, config: ExtractionConfig) -> Bool {
|
||
|
|
result.mimeType() == "application/pdf"
|
||
|
|
}
|
||
|
|
|
||
|
|
func estimatedDurationMs(result: ExtractionResult) -> UInt64 {
|
||
|
|
0 // No processing overhead
|
||
|
|
}
|
||
|
|
|
||
|
|
func initialize() -> String {
|
||
|
|
"{\"ok\": null}"
|
||
|
|
}
|
||
|
|
|
||
|
|
func shutdown() -> String {
|
||
|
|
"{\"ok\": null}"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
let processor = PdfOnlyProcessor()
|
||
|
|
try Kreuzberg.registerPostProcessor(processor)
|
||
|
|
```
|