Skip to content

PDF metadata extraction fails when optional "Trapped" field is NULL #60

Description

@responsemlanger

We encountered an issue with PDF metadata extraction in the metadata extension.

The error occurs in:

Classes/Index/PdfMetadataExtractor.php

Error message:

Argument 1 passed to Fab\Metadata\Utility\UnicodeUtility::convert()
must be of the type string, null given

The problematic line is:

$value = $this->getUnicodeUtility()->convert($value);

While debugging, we found that some PDFs contain an optional metadata field:

["Trapped"] => NULL

The extension iterates over all PDF properties and passes values directly into convert(), but null values are not handled.

Suggested fix:

$value = $this->getUnicodeUtility()->convert($value ?? '');

This seems to affect PDFs where optional metadata fields are unset/null, which is valid according to the PDF specification.

Environment:

TYPO3 9.5.5
PHP 7.4

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions