<?php
require './HTML2PDF.php';

$template file_get_contents(__DIR__ '\input.html');
$variables = [
    
'{{firstName}}' => $_GET['firstName'] ?? 'John'
    
'{{lastName}}' => $_GET['lastName'] ?? 'Doe'
];

$html str_replace(array_keys($variables), array_values($variables), $template);

if ((
$_GET['action'] ?? '') === 'pdf'){
    
$converter = new HTML2PDF('C:\Program Files\nodejs\node.exe'__DIR__ '\html2pdf.js');
    
$converter->outputPdf($html);
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>PDF</title>
</head>
<body>
<form method="get" action="convert.php">
    <input type="hidden" name="action" value="pdf">
    <p><label>First name: <input type="text" name="firstName" value="John" maxlength="512"></label></p>
    <p><label>Last name: <input type="text" name="lastName" value="Doe" maxlength="512"></label></p>
    <p>
        <button type="submit">Generate PDF</button>
    </p>
</form>
<p><a href="./?source=convert.php">[source]</a></p>
<p><a href="./?source=HTML2PDF.php">[HTML2PDF class source]</a></p>
<p><a href="./?source=html2pdf.js">[html2pdf.js source]</a></p>
</body>
</html>