DEV Community

Teddy Zugana
Teddy Zugana

Posted on • Updated on


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());
        if($slide_number == 1){
            $output_text .="";
       $output_text .="";
      return $output_text;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image description

Join the One Year Club

You can earn this badge by being a registered member of the DEV Community for at least one year. Create an account and get started today.