This commit is contained in:
33
docs/snippets/php/config/pdf_config.md
Normal file
33
docs/snippets/php/config/pdf_config.md
Normal file
@@ -0,0 +1,33 @@
|
||||
```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";
|
||||
```
|
||||
Reference in New Issue
Block a user