İstediğiniz bu sanırım.
<?php
// HTML içeriği
$html_content = "<html><head></head><body><h1>Hello, World!</h1></body></html>";

// HTML içeriğini geçici bir dosyaya yaz
$temp_file = tempnam(sys_get_temp_dir(), 'html');
file_put_contents($temp_file, $html_content);

// HTML2Canvas JavaScript kodu
$js_code = '
    const htmlContent = document.documentElement.outerHTML;
    html2canvas(htmlContent).then(canvas => {
        const imgData = canvas.toDataURL("image/png");
        const img = new Image();
        img.src = imgData;
        document.body.appendChild(img);
    });
';

// JavaScript kodunu geçici bir dosyaya yaz
$js_file = tempnam(sys_get_temp_dir(), 'js');
file_put_contents($js_file, $js_code);

// JavaScript kodunu çalıştır
$output = shell_exec("node $js_file $temp_file");

// Ekran görüntüsünü al
$image_data = file_get_contents("$temp_file.png");

// Geçici dosyaları temizle
unlink($temp_file);
unlink($js_file);
unlink("$temp_file.png");

// PNG dosyasını kullanabilirsiniz
file_put_contents('screenshot.png', $image_data);

echo "Ekran görüntüsü oluşturuldu: screenshot.png";
?>
Buna göre paylaş butonu hazırlayın.
Kodları sitenize entegre edin.