Skip to content

Internals Response Senders PdfSender

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

response\senders\PdfSender

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/response/senders/PdfSender.php · Snapshot 8411f4287706.

Response builds status, headers and data/file payloads, chooses a MIME sender, and emits HTTP output. JSON arrays are wrapped in a status/message/data envelope.

PdfSender

Declaration and architectural role

class PdfSender extends AbstractSender

Constants, enum cases, traits and properties

No own constants, enum cases, traits or property declarations. Inherited members are documented on the parent reference page.

Method index

Method Signature
supportedMimes public function supportedMimes(): array
send public function send(mixed $payload, int $status, array $headers): void

supportedMimes

Source line 7

public function supportedMimes(): array

Return expressions (including local callbacks): ['application/pdf'].

Implementation, validation guards and interaction order
public function supportedMimes(): array
    {
        return ['application/pdf'];
    }

send

Source line 17

public function send(mixed $payload, int $status, array $headers): void

Parameters

Parameter Type, modifiers and default Purpose
$payload mixed $payload Operation input; the exact use, validation and propagation are shown in the implementation trace.
$status int $status Operation input; the exact use, validation and propagation are shown in the implementation trace.
$headers array $headers Operation input; the exact use, validation and propagation are shown in the implementation trace.

$payload must be a file path. Pass header 'Content-Disposition: attachment; filename="file.pdf"' via $headers if you want a forced download rather than inline view.

External effects include header.

Implementation, validation guards and interaction order
/**
     * $payload must be a file path.
     * Pass header 'Content-Disposition: attachment; filename="file.pdf"'
     * via $headers if you want a forced download rather than inline view.
     */
    public function send(mixed $payload, int $status, array $headers): void
    {
        $path = (string) $payload;
        $this->requireReadable($path);

        $size = $this->fileSize($path);

        $this->emitStatus($status);
        $this->emitContentType('application/pdf');
        header("Content-Length: $size");

        // Default to inline viewing unless the caller sets Content-Disposition.
        if (!isset($headers['Content-Disposition'])) {
            $filename = basename($path);
            header("Content-Disposition: inline; filename=\"$filename\"");
        }

        $this->emitHeaders($headers);
        $this->streamFile($path);
    }

Related types

Clone this wiki locally