adachsoft / pdf-tool
AI SPI tools for PDF creation and text extraction within a sandbox.
Requires
- php: >=8.3
- adachsoft/ai-tool-call: ^1.0 || ^2.0
- adachsoft/collection: ^3.0
- adachsoft/pdf-contracts: ^0.1
- adachsoft/pdf-lib: ^0.1
- adachsoft/sandbox-contracts: ^0.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0 || ^11.0
- rector/rector: ^2.7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-10 04:36:56 UTC
README
PDF Tool provides AI-oriented tools for creating, extracting, and editing PDF documents inside a controlled sandbox.
Features
- Convert plain text or HTML content into PDF files.
- Extract text from PDF files with optional page ranges.
- Add, remove, and replace PDF pages.
- Expose each operation through the
adachsoft/ai-tool-calltool contract. - Keep file operations inside the configured sandbox.
Installation
composer require adachsoft/pdf-tool
The package requires PHP 8.3 or newer and integrates with the PDF contracts and sandbox contracts provided by the AdachSoft ecosystem.
Integration
Create a PdfToolConfig with the application sandbox path, provide an implementation of the required PDF contract, and inject both into the selected tool. Each tool exposes a static getDefinition() method for AI tool registration and a callTool() method for executing a validated tool request.
use AdachSoft\PdfTool\Tool\PdfConvertTool;
use AdachSoft\PdfTool\Tool\PdfToolConfig;
$config = new PdfToolConfig($sandboxPath);
$convertTool = new PdfConvertTool($pdfConverter, $config);
$definition = PdfConvertTool::getDefinition();
$result = $convertTool->callTool($request);
See the PDF conversion example for a complete request payload and the changelog for release history.
Available tools
| Class | Responsibility |
|---|---|
AdachSoft\\PdfTool\\Tool\\PdfConvertTool | Converts text or HTML content, or a source file, to PDF. |
AdachSoft\\PdfTool\\Tool\\PdfExtractTool | Extracts text from a PDF file. |
AdachSoft\\PdfTool\\Tool\\PdfPageEditorTool | Adds, removes, or replaces PDF pages. |
Sandbox safety
Input and output paths are resolved through the configured sandbox. Paths that escape the sandbox are rejected before the underlying PDF service is called.
License
This library is distributed under the MIT license.