Files

34 lines
822 B
Markdown
Raw Permalink Normal View History

2026-06-01 23:40:55 +02:00
```php title="PHP"
<?php
declare(strict_types=1);
require_once __DIR__ . '/vendor/autoload.php';
use function Kreuzberg\extract_file;
use Kreuzberg\Config\ExtractionConfig;
use Kreuzberg\Config\PdfConfig;
/**
* PDF configuration with hierarchy detection
*/
$config = new ExtractionConfig(
pdf: new PdfConfig(
extractImages: true,
extractMetadata: true,
passwords: ['password1', 'password2'],
hierarchy: [
'enabled' => true,
'k_clusters' => 6,
'include_bbox' => true,
'ocr_coverage_threshold' => 0.5
]
)
);
$result = extract_file('document.pdf', config: $config);
echo "Content length: " . strlen($result->content) . " characters\n";
echo "Metadata: " . implode(', ', array_keys((array) $result->metadata)) . "\n";
```