Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

tcpdf

fpdi

odf

I am getting an error while deleting a page from an scanned pdf using TCPDF & FPDI. Other pdf are working fine.

ERROR: Unable to find object (8, 0) at expected location
like image 924
shabeer Avatar asked Dec 14 '22 22:12

shabeer


1 Answers

Your file might be corrupted. Some scanners will produce corrupted PDF's, But nothing to worry there. You can recreate pdf if you are using 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 recreation has completed,please delete pages . Hope this answer will solve your problems..

like image 104
Harish U Warrier Avatar answered Dec 27 '22 12:12

Harish U Warrier