This commit is contained in:
36
docs/snippets/php/metadata/page_tracking_basic.php
Normal file
36
docs/snippets/php/metadata/page_tracking_basic.php
Normal file
@@ -0,0 +1,36 @@
|
||||
```php title="page_tracking_basic.php"
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Basic Page Tracking
|
||||
*
|
||||
* Extract individual pages with their content, tables, and images
|
||||
* using page extraction configuration.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use Kreuzberg\Kreuzberg;
|
||||
use Kreuzberg\Config\ExtractionConfig;
|
||||
use Kreuzberg\Config\PageConfig;
|
||||
|
||||
$config = new ExtractionConfig(
|
||||
pages: new PageConfig(
|
||||
extractPages: true
|
||||
)
|
||||
);
|
||||
|
||||
$kreuzberg = new Kreuzberg($config);
|
||||
$result = $kreuzberg->extractFile('document.pdf');
|
||||
|
||||
if (!empty($result->pages)) {
|
||||
foreach ($result->pages as $page) {
|
||||
echo "Page {$page->pageNumber}:\n";
|
||||
echo " Content: " . strlen($page->content) . " chars\n";
|
||||
echo " Tables: " . count($page->tables) . "\n";
|
||||
echo " Images: " . count($page->images) . "\n\n";
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user