I want to generate a pdf when someone clicks on the generate pdf button. This pdf contains the image of the pile of squares highlighted corresponding to what the user highlighted in the image on the web page. Whenever I try to include the svg I get a blank pdf. Any help?
trial.html:
<?php
use Dompdf\Dompdf;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
if(isset($_POST['send']))
{
$output = ' <!DOCTYPE html>
<svg width="564" height="409" >
<image
href="https://media.geeksforgeeks.org/wp-content/uploads/unique-rectangles-formed-using-
n-unit-squares.png"
width="564"
height="409"
/>
<polygon title="1" points="21,385 24,309 100,309 101,385" />
<polygon title="2" points="102,305 23,304 23,228 101,227" />
<polygon title="3" points="103,225 26,228 25,149 99,151" />
<polygon title="4" points="103,147 102,65 25,70 23,147" />
</svg>';
// $output .= '<img src="data:image/svg+xml;base64,'.base64_encode($svg).'" width="100" height="100" />';
require 'C:\Users\Main\vendor/autoload.php';
$cart_body='<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Squares</title></head><body><p>Test Printing...</p></body></html>';
$dompdf = new Dompdf();
$dompdf->load_html($output);//body -> html content which needs to be converted as pdf..
$dompdf->render();
$dompdf->stream("sample.pdf");
}?>
script.js:
function handleSVGClick(event) {
if (event.target.tagName === "polygon") {
event.target.style.fill = `hsl(${Math.random() * 360}, 90%, 60%)`;
}
}
style.css:
polygon {
stroke-width: 2px;
stroke: #333;
fill: transparent;
}