TCPDF ERROR: Unable to find object (8, 0) in expected location

I get an error when deleting a page from scanned pdf using TCPDF and FPDI. Other pdfs work fine.

ERROR: Unable to find object (8, 0) at expected location
+4
source share
1 answer

Your file may be corrupted. Some scanners will create corrupted PDF files, but there is nothing to worry about. You can recreate PDF if you use linux with shell_exec

function pdf_recreate($f)
    {

        rename($f,str_replace('.pdf','_.pdf',$f));  

        $fileArray=array(str_replace('.pdf','_.pdf',$f));
        $outputName=$f;
        $cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";

        foreach($fileArray as $file)
        {
          $cmd .= $file." ";
        }
        $result = shell_exec($cmd);
        unlink(str_replace('.pdf','_.pdf',$f));

    }

After resting, delete the pages. Hope this answer solves your problems.

+11
source

Source: https://habr.com/ru/post/1542889/


All Articles