Skip to main content
Core PDF is a PDF tooling microservice on Cloudflare: structured extraction (JSON) and page rasterization (PNG/JPEG). Use the inly/core client Inly\Core\Services\CorePdf\CorePdf. Full HTTP details (curl, query params, responses) live at pdf-services.inlycore.com/docs.
Set CORE_PDF_API_KEY from 1Password (Inly). You do not need to change the default base URL (https://pdf-services.inlycore.com) unless you use a custom endpoint.

Configuration

Values come from config/core-pdf.php (merged from the package). Minimum:
CORE_PDF_API_KEY=your-token-from-1password

Registering the service

Bind a singleton so you can type-hint CorePdf (the package does not register it globally):
use Inly\Core\Services\CorePdf\CorePdf;

public function register(): void
{
    $this->app->singleton(CorePdf::class, function ($app) {
        return new CorePdf(
            baseUrl: config('core-pdf.base_url'),
            apiKey: config('core-pdf.api_key'),
            timeout: config('core-pdf.timeout'),
            retryAttempts: config('core-pdf.retry_attempts'),
        );
    });
}

Usage

extract(UploadedFile|string $source): array — Decoded JSON from POST /extract. Throws RuntimeException on failure or invalid JSON. Uploads and paths use multipart file; HTTPS URL strings use JSON { "url": "..." }.
$data = $this->corePdf->extract($request->file('pdf'));
$data = $this->corePdf->extract(storage_path('app/documents/quote.pdf'));
$data = $this->corePdf->extract('https://example.com/static/brochure.pdf');
Example shape of the decoded array (actual keys and kids entries depend on the PDF):
{
  "file name": "2771_design.pdf",
  "number of pages": 1,
  "kids": [
    {
      "type": "heading",
      "content": "LENZERHEIDE HOUSE OF SKI 2026/27",
      "page number": 1,
      "bounding box": [77.004, 2587.761, 350.894, 2607.761]
    }
  ]
}
The extractor uses kids (not children) for tree child nodes—terminology from the internal PDF pipeline / @opendataloader/pdf-style output, not a generic JSON tree field name.
render(...): string — Raw image bytes from POST /render. Optional named args page (default 1), format (png/jpg), quality, width become query string parameters (see public docs). Throws RuntimeException on HTTP errors or unreadable input. Response Content-Type is image/png or image/jpeg.
$bytes = $this->corePdf->render(
    $pathToPdf,
    page: 1,
    format: 'jpg',
    quality: 90,
    width: 4000,
);
Use a path or upload when the PDF is not reachable as a public URL (for example local storage or http://127.0.0.1), so the client uses multipart instead of URL fetch.
Other helpers: isConfigured(), getBaseUrl(), getTimeout() / setTimeout(), getRetryAttempts() / setRetryAttempts(). The HTTP client uses Laravel Http with configurable timeout and retries; non-empty api_key sends Authorization: Bearer.

HTML documents to PDF (Core documents)

Business HTML rendered by CoreDocument is converted to PDF with Spatie Laravel PDF via Inly\Core\Services\Documents\DocumentPdfService, not via CorePdf. CorePdf remains the microservice for extracting and rasterizing existing PDFs. Document PDFs use the paper size stored on each Document (from protected string $format on the document class, default a4).