Skip to content

Instantly share code, notes, and snippets.

@juanchehin
Created October 18, 2023 20:54
Show Gist options
  • Save juanchehin/4490219009fdb2532737b0a990eea49c to your computer and use it in GitHub Desktop.
Save juanchehin/4490219009fdb2532737b0a990eea49c to your computer and use it in GitHub Desktop.
public function crear_factura_pdf()
{
$dompdf = new Dompdf();
$html_dir =__DIR__ . '/factura.html';
$html = file_get_contents($html_dir);
print_r($html_dir);
if ($html === false) {
print_r(error_get_last()['message']);
exit;
// echo "Se produjo un error al leer el archivo: " . error_get_last()['message'];
} else {
// El archivo se leyó correctamente
}
// Cargar el HTML
$dompdf->loadHtml($html);
// Definir las opciones de configuración
$dompdf->setPaper('A3');
// $dompdf->setFont('Helvetica', '', 12);
// Crear el PDF
$dompdf->render();
// Descargar el PDF
$dompdf->stream();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment