Having error when trying to get details from pdf page generated with html emoji code inside pdf text
Nobody has claimed this yet.
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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