mikehaertl/php-pdftk

Querying the metadata of a PDF file produces too few results

Calvinstefan opened this issue · 3 comments

Hello,
I try to read the metadata of a PDF file with the following code:

$data = $pdf->getData();
$txt  = (string) $data;

I expect a result as mentioned in the source example src/InfoFile.php, like:

array (
'Title',
'Author',
'Subject',
'Keywords',
'Creator',
'Producer',
'CreationDate',
'ModDate',
'Trapped',
);

First and foremost I need the values ​​of the fields Creator and Producer.
But I only get:

Warning: no info dictionary found
PdfID0: a4ca5463835c33c75b290e9a523c9bcb
PdfID1: a4ca5463835c33c75b290e9a523c9bcb
NumberOfPages: 1
PageMediaBegin
PageMediaNumber: 1
PageMediaRotation: 0
PageMediaRect: 0 0 595.2 841.6
PageMediaDimensions: 595.2 841.6

Please, tell me how I can read the two mentioned fields of a PDF file using your PHP library.
Thank you!

Greetings,
Stefan

This library will only forward whatever information it receives from pdftk. In this case it seems that the PDF does not contain more information, as this warning indicates:

Warning: no info dictionary found

So you should find out, how to add this information to the PDF. It's beyond the scope of this library.

Many thanks for your response! But I'm sure the PDF containes the informations I want to read via pdftk (please see the screenshot).

11-03-_2024_10-34-51

How can I read the marked information using PDFTK?
Thank you.

The lib does pdftk some.pdf dump_data_utf8 internally.