DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

2 1

I managed to parse a pdf using Smalot\PdfParser but how I can construct it back?

I am parsing a pdf file and changing its text:

    $parser = new \Smalot\PdfParser\Parser()
    $pdf    = $parser->parseFile(storage_path().'/contracts/hello.pdf');
    
    // Retrieve all pages from the pdf file.
    $pages  = $pdf->getPages();
    
    $final = "";

    // Loop over each page to extract text.
    foreach ($pages as $page) {
        $text = $page->getText();
        $text = str_replace("\${NAME}","ΜΙΤΣΟΣ",$text);

Top comments (1)

Collapse
 
thefern profile image
Fernando B 🚀

I don't know this library, but I would try to do a try catch and see if there are any errors. I tried looking up the library documentation but is pretty limited.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay