PHP extract PPTX or PPT powerpoint files format to TXT Example

kevinmel2000

Teddy Zugana

Posted on February 17, 2020

PHP extract PPTX or PPT powerpoint files format to TXT Example
    function pptx_to_text($input_file){
        $zip_handle = new ZipArchive;
        $output_text = "";
        if(true === $zip_handle->open($input_file)){
           $slide_number = 1; //loop through slide files
           while(($xml_index = $zip_handle->locateName("ppt/slides  /slide".$slide_number.".xml")) !== false){
            $xml_datas = $zip_handle->getFromIndex($xml_index);
            $xml_handle = DOMDocument::loadXML($xml_datas, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
           $output_text .= strip_tags($xml_handle->saveXML());
           $slide_number++;
        }
        if($slide_number == 1){
            $output_text .="";
        }
       $zip_handle->close();
   }else{
       $output_text .="";
   }
      return $output_text;
 }
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
kevinmel2000
Teddy Zugana

Posted on February 17, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related