Wrong Character - can detect this ?
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.7k
- Forks
- 579
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
- PHP Version: 8.2
- PDFParser Version: 2.9
Description:
I want to parse some CV, and I have sometimes wrong character.
I would to try to parse correctly the pdf, and if not possible, if I have some wrong characters, return an empty string to $text.
PDF input
curriculum_vitae_Victor-Faria.pdf
Expected output & actual output
The result
����������� � ue Oscar--Bider 104b, 1950 Sion ��������������������������������� ��������� �������������������������� ����������������� ���������������� ��;������2����� ��;�������4��;��������� ��;������2����������� ��������� �;�����;�����������������������������; ���� ���;��������������������� ���������;���������������� ������� ���@������� ����������;����������;�����;� ��;�����������������;��������� ���������� ����������� ���� ��������������;��� ���;������������;����������� ���������� ����������� ����������� ����������� ���� �� ������������� ���;����������� ����;���;����;��������������;����� �������������������� ������� ����� ���� ������������������ ���;����������������������� ��������� ������������������������;�����;� �������������� ��������� ��������������������� ������������ ���������������������� ������������������� ����������������������������� ��������� ������� ��������������� ��;�������������������������� ������� ����������� ������������������� �;��������������� ��������������� ����M����� ��������������� �������� ���������������� ������������ ����������; ���������� �������� ������;��� ����;������ ������������;����������� ����������������� ������������;����� ������ ������� �������� ��������� ���@�����������������;����������;�����;� ��;�����������������;������������������� ���������;���������� Cap 3D ��������� ��� 3
Code
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($pdf_temp_path);
if ($pdf) {
$pages = $pdf->getPages();
}
if ($pages && !empty($pages)) {
try {
$text = $pages[0]->getText();
} catch (Exception $e) {
echo 'Erreur lors de la vérification du PDF : ' . $e->getMessage();
}
} else { $text = '';}
$text = str_replace(
array('\\\\', '\(', '\)', '\n', '\r', '\t', '\f', '\ '),
array('\\', '(', ')', "\n", "\r", "\t", "\f", ' '),
$text
);
return $text;
Thanks for your help
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
Reproduce the report with the linked curriculum vitae PDF using Parser::parseFile() and the page getText() call shown in the issue. Inspect the extracted text for the reported replacement characters and determine whether the expected behavior is corrected text or an empty string; done should be demonstrated against this PDF with a regression test or documented reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100