-->

What PDF meta data does dompdf support?

2019-07-04 10:18发布

问题:

When using dompdf what PDF meta data can be set in the document information dictionary?

Originally asked elsewhere:

Are you able to parse more META info to be added to PDF information during PDF generation?

/Creator (DOMPDF) /CreationDate (D:20150818031116-05'00') /ModDate (D:20150818031116-05'00')

Can you specify Author, Copyright, etc..?

I cannot find ANY reference to this. Only just saw your: Creator, Creation Date and Modification Date!

回答1:

In the current stable release (0.6.1) the HTML <title> element and some <meta> elements (author, keywords, description) are used to set the relevant PDF meta data.

<html>
<head>
  <title>Ehhhhhhh</title>
  <meta name="author" content="Arthur Herbert Fonzarelli">
  <meta name="keywords" content="fonzie, cool, ehhhhhhh">
</head>
<body>
  <p>Ehhhhhhh</p>
</body>
</html>

In addition, you can add other info to the PDF using the $dompdf->add_info() method. The full list of supported metadata info that you can set is: Title, Author, Subject, Keywords, Creator, Producer, CreationDate, ModDate, Trapped.

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->add_info('Subject', 'Cool');