I had this code:
require_once __DIR__ . '/vendor/autoload.php';
use DompdfDompdf;
add_shortcode('gerar-pdf', 'pdf');
function pdf() {
ob_start();
include( get_stylesheet_directory() . '/includes/certificado.php' );
$html = ob_get_clean();
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->render();
$dompdf->stream("certificado.pdf");
}
to transform my html + css code into a PDF, but the file that be generated every goes corrupted, i alread try to remove the include and put a html directly like <p> Hello </p>
, but it’s also return corrupted. How can i solve this?
I’ve tried to clear buffer and use html directly
New contributor
Fagner Junqueira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.