Page/window title

950 views
Skip to first unread message

Andy

unread,
Apr 23, 2012, 4:14:13 PM4/23/12
to dompdf
Is there anyway to set the title from a PDF?
I have several reports, and I'd like to put the reports name as the
title of the window or tab that the PDF is in so that the user knows
what is what without having to click on it. Especially if the user has
a bunch of reports open.

John Bell

unread,
Apr 24, 2012, 4:05:54 AM4/24/12
to dom...@googlegroups.com
you can set this in the <title> attribute of the html:
        $html = '<!DOCTYPE html><head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="'.JPATH_ROOT.'/media/com_cirrus/css/pdf.css" type="text/css"/>
        <title>Document title</title>
        </head>
        <body>';
        $html .= <your html here />
        $html .= "</body></html>";
        $dompdf->load_html($html);

John

Andy

unread,
Apr 24, 2012, 9:01:39 AM4/24/12
to dompdf
I have that...
<?
if(!isset($_POST["html"])){
$html = "<!DOCTYPE html><html xmlns='http://www.w3.org/1999/
xhtml'>";
$html .= "<head>\n";
$html .= "<meta http-equiv='Content-Type' content='text/html;
charset=utf-8' />\n";
$html .= "<title>Invoice</title>\n";
$html .= "<style>td{font-size:14px;}</style>";
$html .= "</head>\n";
$html .= "<body style='font-size:14px;' >\n";
$html .= "Body stuff goes here";
$html .= "</body>\n";
$html .= "</html>\n";
$html = str_replace('"','&quot;',$html);

?>
<html>
<head><title>Building the Invoice</title></head>
<body onLoad="javascript:fsub();">
<form name="tform" id="tform" action="InvoiceView.php"
method="post">
<input type="hidden" name="html" value="<? echo $html; ?>" />
</form>
<script>function fsub(){document.tform.submit();}</script>
</body>
</html>
<?
} else {
require_once("dompdf/dompdf_config.inc.php");

$html = stripslashes($_POST["html"]);
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper("letter", "landscape");
$dompdf->render();
$dompdf->stream("Invoice.pdf" , array("Attachment" =>
0,"paper"=>"letter")); //
}
?>

The only thing that shows up on the title is InvoiceView.php

On Apr 24, 4:05 am, John Bell <j...@belmix.com> wrote:
> you can set this in the <title> attribute of the html:
>          $html = '<!DOCTYPE html><head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <link rel="stylesheet"
> href="'.JPATH_ROOT.'/media/com_cirrus/css/pdf.css" type="text/css"/>
> *<title>Document title</title>*

Fabien Ménager

unread,
Apr 24, 2012, 11:32:59 AM4/24/12
to dom...@googlegroups.com
Hello, I think I understand what you mean, your problem is this one : you have a page like this one :

which opens the PDF in the browser, like it would do with a regular HTML document, but the title in the tab is not what you want but the script name or the full URL.

We don't have any control over this, as this is the PDF viewer that handles this. I think Chrome viewer shows the complete URL as the title and Adobe reader shows the script name (here dompdf.php). I think they should definitely show the document title from the PDF file, but they don't.

The only solution for this would be to have an HTML page with a title, with only an iframe which takes all the page in which you would submit your form, which has a "target" attribute targetting the iframe.

John Bell

unread,
Apr 24, 2012, 3:05:38 PM4/24/12
to dom...@googlegroups.com
As Fabien says, its outside the scope of Dompdf. You may get some ideas
by Googling "php router"

John

Reply all
Reply to author
Forward
0 new messages