This commit is contained in:
13
docs/snippets/php/getting-started/basic_usage.md
Normal file
13
docs/snippets/php/getting-started/basic_usage.md
Normal file
@@ -0,0 +1,13 @@
|
||||
```php title="PHP"
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Kreuzberg\Kreuzberg;
|
||||
use Kreuzberg\ExtractionConfig;
|
||||
|
||||
$config = new ExtractionConfig();
|
||||
$result = Kreuzberg::extractFileSync('document.pdf', null, $config);
|
||||
|
||||
echo "Content:\n";
|
||||
echo $result->getContent();
|
||||
```
|
||||
14
docs/snippets/php/getting-started/extract_file.md
Normal file
14
docs/snippets/php/getting-started/extract_file.md
Normal file
@@ -0,0 +1,14 @@
|
||||
```php title="PHP"
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Kreuzberg\Kreuzberg;
|
||||
use Kreuzberg\ExtractionConfig;
|
||||
|
||||
$config = new ExtractionConfig();
|
||||
$result = Kreuzberg::extractFileSync('document.pdf', null, $config);
|
||||
|
||||
echo "Content: " . $result->getContent() . "\n";
|
||||
echo "MIME Type: " . $result->getMimeType() . "\n";
|
||||
echo "Tables: " . count($result->getTables()) . "\n";
|
||||
```
|
||||
25
docs/snippets/php/getting-started/extract_with_ocr.md
Normal file
25
docs/snippets/php/getting-started/extract_with_ocr.md
Normal file
@@ -0,0 +1,25 @@
|
||||
```php title="PHP"
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Kreuzberg\Kreuzberg;
|
||||
use Kreuzberg\ExtractionConfig;
|
||||
use Kreuzberg\OcrConfig;
|
||||
|
||||
$ocrConfig = new OcrConfig();
|
||||
$ocrConfig->setBackend('tesseract');
|
||||
$ocrConfig->setLanguage('eng');
|
||||
|
||||
$config = new ExtractionConfig();
|
||||
$config->setForceOcr(true);
|
||||
$config->setOcr($ocrConfig);
|
||||
|
||||
$result = Kreuzberg::extractFileSync('scanned.pdf', null, $config);
|
||||
|
||||
echo "Content:\n";
|
||||
echo $result->getContent();
|
||||
|
||||
if ($result->getDetectedLanguages() !== null) {
|
||||
echo "Detected Languages: " . implode(', ', $result->getDetectedLanguages()) . "\n";
|
||||
}
|
||||
```
|
||||
9
docs/snippets/php/getting-started/hello_world.md
Normal file
9
docs/snippets/php/getting-started/hello_world.md
Normal file
@@ -0,0 +1,9 @@
|
||||
```php title="PHP"
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Kreuzberg\Kreuzberg;
|
||||
|
||||
$result = Kreuzberg::extractFileSync('document.pdf', null, null);
|
||||
echo "Hello, " . substr($result->getContent(), 0, 50) . "\n";
|
||||
```
|
||||
10
docs/snippets/php/getting-started/install_verify.md
Normal file
10
docs/snippets/php/getting-started/install_verify.md
Normal file
@@ -0,0 +1,10 @@
|
||||
```php title="PHP"
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
if (extension_loaded('kreuzberg')) {
|
||||
echo "Kreuzberg extension loaded successfully.\n";
|
||||
} else {
|
||||
echo "Kreuzberg extension not loaded.\n";
|
||||
}
|
||||
```
|
||||
24
docs/snippets/php/getting-started/read_content.md
Normal file
24
docs/snippets/php/getting-started/read_content.md
Normal file
@@ -0,0 +1,24 @@
|
||||
```php title="PHP"
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Kreuzberg\Kreuzberg;
|
||||
use Kreuzberg\ExtractionConfig;
|
||||
use Kreuzberg\ChunkingConfig;
|
||||
|
||||
$config = new ExtractionConfig();
|
||||
$config->setChunking(new ChunkingConfig());
|
||||
$result = Kreuzberg::extractFileSync('document.pdf', null, $config);
|
||||
|
||||
echo "Total content length: " . strlen($result->getContent()) . "\n";
|
||||
|
||||
if ($result->getChunks() !== null) {
|
||||
foreach ($result->getChunks() as $chunk) {
|
||||
echo "Chunk: " . $chunk->getContent() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($result->getTables() as $table) {
|
||||
echo "Table with " . count($table->getRows()) . " rows\n";
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user