- Add jedarden/pdftract Composer package (sdk/php/) - Implement Client.php with proc_open subprocess execution - Add PSR-3 LoggerInterface integration (defaults to NullLogger) - Add 9 contract methods: extract, extractText, extractMarkdown, extractStream, search, getMetadata, hash, classify, verifyReceipt - Add readonly model classes: Document, Page, Metadata, Fingerprint, Classification, Match, Receipt - Add exception classes: PdftractException base + 8 subclasses - Add PHPUnit conformance test suite - Add phpunit.xml configuration - Add composer.json with jedarden/pdftract package name - Add .ci/argo-workflows/pdftract-php-publish.yaml (Packagist auto-discovery from git tags) Also includes Ruby SDK scaffold from parallel workflow. Closes pdftract-2m3gl
58 lines
1.1 KiB
PHP
58 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Jedarden\Pdftract\Models;
|
|
|
|
/**
|
|
* JSON representation of an explicit destination array
|
|
*
|
|
* Describes a specific location within a PDF page.
|
|
*/
|
|
class DestArray
|
|
{
|
|
/**
|
|
* Zero-based page index within the document
|
|
*/
|
|
public int $page_index;
|
|
|
|
/**
|
|
* Destination type and coordinates
|
|
*/
|
|
public DestType $dest;
|
|
|
|
/**
|
|
* Create DestArray from JSON array
|
|
*
|
|
* @param array<string,mixed> $data JSON data
|
|
* @return self
|
|
*/
|
|
public static function fromArray(array $data): self
|
|
{
|
|
$destArray = new self();
|
|
$destArray->page_index = $data['page_index'];
|
|
$destArray->dest = DestType::fromArray($data);
|
|
|
|
return $destArray;
|
|
}
|
|
|
|
/**
|
|
* Convert to JSON array
|
|
*
|
|
* @return array<string,mixed>
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
$data = [
|
|
'page_index' => $this->page_index,
|
|
];
|
|
|
|
// Merge dest type data
|
|
$destData = $this->dest->toArray();
|
|
foreach ($destData as $key => $value) {
|
|
$data[$key] = $value;
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|