Parsing form object that is referenced by Do command
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.24
- PDFParser Version: 2.12.5
Description:
User of the website im working on apparently used the website https://online2pdf.com to convert a word document into a pdf.
This website seems to generate PDFs in a weird way:
Instead of just putting the text into the page object as content it generated a form object containing the text and referenced this object in the page content with the Do command.
Currently PDFParser doesnt support the Do command and also can't correctly extract content (DataTm) from form objects.
PDF input
Expected output & actual output
Expected:
Array containing the text Test and the coordinates of this textarea
Actual:
array (size=0)
empty
Code
$filepath = "C:/Users/dd/Desktop/Test.pdf";
$filecontent = file_get_contents($filepath);
$config = new Config();
$config->setDataTmFontInfoHasToBeIncluded(true);
$parser = new Parser([], $config);
$pdf = $parser->parseContent($filecontent);
$pages = $pdf->getPages();
foreach ($pages as $page) {
var_dump($page->getDataTm());
}
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 with Parser::parseContent, then trace page getDataTm and the Config option setDataTmFontInfoHasToBeIncluded using the attached Test.pdf. Investigate handling of the PDF Do command and text extraction from referenced form objects. Done means the sample PDF returns the text "Test" with its coordinates instead of an empty array.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100