1 year ago

#289874

test-img

molyyy

Parse a PDF file using PHP at certain keywords and split it into multiple PDF files

I'd like to be able to parse a PDF file using PHP and symfony 4 framework using certain keywords and split it into multiple PDF files at the keywords searched for.

I did some research and I found a lot of ways to parse PDF files using PHP but very few to parse and split the PDF file.

any web-sites I could go to? libraries I could use?

this is the code i used to extract the whole text from a pdf file. But my purpose is to extract specific paragraphes from the pdf, for example i want to extract the paragraph that starts from the word 'hello' to the word 'world'. public function extract(): Response { $parser = new \Smalot\PdfParser\Parser(); $CV = $parser->parseFile('C:\Users\lenovo\Desktop\papiers\CV\CVmolkahchaichi.pdf');

    // Retrieve all pages from the pdf file.
    $details = $CV->getDetails();
    $pages  = $CV->getPages();

    // Loop over each page to extract text.
    foreach ($pages as $page) {
        echo $page->getText();
        foreach ($details as $property => $value) {
            if (is_array($value)) {
                $value = implode(', ', $value);
            }
            echo $property . ' => ' . $value . "<br/>";
        }
        return new Response();

}

php

parsing

pdf

symfony4

0 Answers

Your Answer

Accepted video resources