5

EDIT

in accordance with @Will suggestions here is a simplified question...

Is there a tag I can use in the TCPDF PDF Creator file (example_003.php) to set the browser title to be anything other than the full URL of the php file?

I have tried this amongst lots of other things but it doesn't seem to play.

$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Author');
$pdf->SetTitle('Title');
$pdf->SetSubject('Subject');
$pdf->SetKeywords('Keywords');
$pdf->setHeaderData($ht='Browser Title?');

Any help would be great, thanks

1
  • New updated question with another tag Commented Aug 8, 2011 at 13:04

3 Answers 3

1

Whether or not a browser will display anything other than the URL for a downloaded file (regardless of whether or not the browser displays the PDF) is entirely vendor specific. My testing doesn't indicate that any data from the PDF is displayed in the title bar of the browser.

Something you can do is give the PDF file an alternate filename so that when the user saves the file they don't get a weird .php extension on their PDF. You do this with the Content-Disposition HTTP header. In PHP it could be done like this:

header('Content-Disposition: attachment; filename=document-name.pdf');
0

If you're using html2pdf with tcpdf as the base class, it does contain the SetTitle function. You just have to create a function override in html2pdf.class.

/**
 * Defines the title of the document.
 * @param string $title The title.
 * @access public
 * @since 1.2
 * @see SetAuthor(), SetCreator(), SetKeywords(), SetSubject()
 */
 public function SetTitle($title) {
  //Title of document
  $this->pdf->SetTitle($title);
  return $this;
 }
0

In Html2Pdf with tcpdf, you can add a new function called SetTitle and then call it from your code.

Html2Pdf.php

public function SetTitle($title) {
    $this->pdf->SetTitle($title);
    return $this;
}

yourcode.php

SetTitle('Hello');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.