smalot / smalot/pdfparser

phpunit pdf tofu characters detection

Open
#741 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
2.7k
Forks
579
Avg merge
2m
Merged PRs (30d)
1

Description

I'm trying to design a phpunit test to detect tofu characters within a generated pdf. (If none of the fonts included in the pdf supports the language within the pdf, tofu characters will appear.)

First, I tried to get the pdf text, however the getText method always returns the correct unicode text, even if tofu characters are seen within the pdf.

Second, I've considered listing the available fonts and simply reviewing that all the required fonts are present.

$parser = new PdfParser();
$document = $parser->parseFile($pdf);

$fonts = $document->getFonts();

foreach ($fonts as $font) {
    $font->getDetails();
}

Would anyone have a better approach to suggest?

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 with the issue's PdfParser parseFile call and the getText, getFonts, and getDetails entry points. Determine how a PHPUnit test could distinguish rendered tofu characters from the extracted Unicode text, then define a reproducible PDF fixture and a passing detection test as the completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.