<?php

declare(strict_types=1);

require_once __DIR__ . '/../includes/auth.php';
require_once __DIR__ . '/../includes/pdf_generator.php';

auth_require();

$path = generate_template_pdf(false);

if (!is_file($path)) {
    http_response_code(404);
    echo 'Template PDF not found.';
    exit;
}

header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="karvi_partner_contract_template.pdf"');
header('Content-Length: ' . (string)filesize($path));
readfile($path);
exit;
