I haven't been able to find a way to display on the Browser's tab a Title (like meta title) when generating a PDF suing domppdf.
In some posts they suggest adding this to the HTML code:
<html>
<head><title> My Title </title>
</head>
<body>
/** PDF Content **/
</body>
But, maybe it is due to version that I am using, but adding these tags breaks my code and dompdf returns a long error. I only have the body and it works great.
Unfortunately I can't upgrade my version of dompdf, so I am trying to find another solution. I don't think it is possible by using PHP headers, but I am open to suggestions.
I have this so far:
$dompdf = new Dompdf();
ob_start();
include("pdf_HTML.php");
$fileName = "download.pdf";
$content = ob_get_clean();
$dompdf->loadHtml($content);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('Letter', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
header("Content-type:application/pdf");
header("Content-Disposition: attachment; filename=$fileName.pdf'");
$dompdf->stream($fileName,array('Attachment'=>0));
After much looking I found the way:
$dompdf->add_info('Title', 'Your meta title');
It took me some time to find the answer so I am sure this will be helpful for someone else.