Skip to content

Conversation

@joebordes
Copy link

PR for issue #817

joe:~/TCPDF$ php examples/example_001.php  > example001.pdf
joe:~/TCPDF$ exiftool -XMP:All example001.pdf 
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:08:04
Format                          : application/pdf
Title                           : TCPDF Example 001
Creator                         : Nicola Asuni
Description                     : TCPDF Tutorial
Subject                         : TCPDF, PDF, example, test, guide
Create Date                     : 2025:10:01 18:35:53+00:00
Creator Tool                    : TCPDF
Modify Date                     : 2025:10:01 18:35:53+00:00
Metadata Date                   : 2025:10:01 18:35:53+00:00
Producer                        : TCPDF 6.10.0 (http://www.tcpdf.org)
Document ID                     : uuid:0cba4c67-099e-fe74-fea7-a279fb39678d
Instance ID                     : uuid:0cba4c67-099e-fe74-fea7-a279fb39678d
Schemas Namespace URI           : http://ns.adobe.com/pdf/1.3/
Schemas Prefix                  : pdf
Schemas Schema                  : Adobe PDF Schema
Schemas Property Category       : internal
Schemas Property Description    : Adobe PDF Schema
Schemas Property Name           : InstanceID
Schemas Property Value Type     : URI

The code that generates that is

$pdf->setCreator(PDF_CREATOR);
$pdf->setAuthor('Nicola Asuni');
$pdf->setTitle('TCPDF Example 001');
$pdf->setSubject('TCPDF Tutorial');
$pdf->setKeywords('TCPDF, PDF, example, test, guide');

We can see here that

  • Description contains the Subject
  • Subject contains the keywords

With this PR the code to create the PDF is now

$pdf->setCreator(PDF_CREATOR);
$pdf->setAuthor('Nicola Asuni');
$pdf->setTitle('TCPDF Example 001');
$pdf->setSubject('TCPDF Tutorial');
$pdf->setDescription('TCPDF Tutorial Description');
$pdf->setKeywords('TCPDF, PDF, example, test, guide');

and the output is

joe:~/TCPDF$ php examples/example_001.php  > example001.pdf
joe:~/TCPDF$ exiftool -XMP:All example001.pdf 
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:08:04
Format                          : application/pdf
Title                           : TCPDF Example 001
Creator                         : Nicola Asuni
Description                     : TCPDF Tutorial Description
Subject                         : TCPDF Tutorial
Create Date                     : 2025:10:01 18:54:34+00:00
Creator Tool                    : TCPDF
Modify Date                     : 2025:10:01 18:54:34+00:00
Metadata Date                   : 2025:10:01 18:54:34+00:00
Producer                        : TCPDF 6.10.0 (http://www.tcpdf.org)
Document ID                     : uuid:91da612c-5ad4-9b90-89fb-aa6525362f2f
Instance ID                     : uuid:91da612c-5ad4-9b90-89fb-aa6525362f2f
Schemas Namespace URI           : http://ns.adobe.com/pdf/1.3/
Schemas Prefix                  : pdf
Schemas Schema                  : Adobe PDF Schema
Schemas Property Category       : internal
Schemas Property Description    : Adobe PDF Schema
Schemas Property Name           : InstanceID
Schemas Property Value Type     : URI

where you can see that we have description and subject as per the methods.

@CLAassistant
Copy link

CLAassistant commented Oct 1, 2025

CLA assistant check
All committers have signed the CLA.

@joebordes
Copy link
Author

please add the hacktoberfest tag

$xmp .= "\t\t\t".'<dc:subject>'."\n";
$xmp .= "\t\t\t\t".'<rdf:Bag>'."\n";
$xmp .= "\t\t\t\t\t".'<rdf:li>'.TCPDF_STATIC::_escapeXML($this->keywords).'</rdf:li>'."\n";
$xmp .= "\t\t\t\t\t".'<rdf:li>'.TCPDF_STATIC::_escapeXML($this->subject).'</rdf:li>'."\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this not break some users workflow?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be, but putting "keywords" in a "subject" field seems wrong to me

@nicolaasuni comments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanation, I will review this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that in a PDF file's metadata, the "subject" field and the Dublin Core (dc) element "dc:description" are distinct but related properties that describe the document's content.

  • The "subject" property is part of the legacy "Document Information Dictionary" in a PDF file.
  • The "dc:description" element is part of the Extensible Metadata Platform (XMP) metadata stream, which is the modern, standardized way to store metadata in Adobe products and PDF/A compliant files.

While distinct in name and original location, these fields are often synchronized. Indeed in TCPDF the "dc:description" value is set to the "subject" field value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In similar ways, "dc:subject" and "keywords" both serve to categorise a PDF document using specific topics or terms. They are essentially two different references for the same information within a modern PDF file.

$xmp .= "\t\t\t".'</dc:description>'."\n";
$xmp .= "\t\t\t".'<dc:subject>'."\n";
$xmp .= "\t\t\t\t".'<rdf:Bag>'."\n";
$xmp .= "\t\t\t\t\t".'<rdf:li>'.TCPDF_STATIC::_escapeXML($this->keywords).'</rdf:li>'."\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this change. Why keywords was removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keywords haven't been removed. They are still where they should be; a few more lines after this one, you will find.

$xmp .= "\t\t\t".'<pdf:Keywords>'.TCPDF_STATIC::_escapeXML($this->keywords).'</pdf:Keywords>'."\n";

What I am doing is using subject inside the <dc:subject> section instead of keywords

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants