smalot / smalot/pdfparser

Having error when trying to get details from pdf page generated with html emoji code inside pdf text

Open
#701 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug de-/encoding issue
Dominant language
PHP
Stars
2.7k
Forks
579
Avg merge
2m
Merged PRs (30d)
1

Description

  • PHP Version: 8.1
  • PDFParser Version: 2.9.0
Description:

When trying to call $currentpage->getDetails(); with a pdf contains an emoji html code, I have this error :
Object of class Smalot\PdfParser\Header could not be converted to string
it's happening in Font.php file, when function getName return "[Unknown]";

Code

I fix this error replacing the code by :
$details['Encoding'] = $this->getName() != "[Unknown]" ? ($this->has('Encoding') ? (string) $this->get('Encoding') : 'Ansi') : 'Ansi';

Is that possible to check this,
Best Regards.

file-test.pdf

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Font.php around getName() and the Encoding assignment, then reproduce $currentpage->getDetails() with the attached file-test.pdf using PHP 8.1 and PDFParser 2.9.0. Done means the emoji-containing PDF no longer raises the Header-to-string conversion error and details can be retrieved successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.