예제 #1
0
 public function save(Doctrine_Connection $conn = null)
 {
     if ($this->isNew()) {
         $this->changeUri();
         if ($this->getMimeType() == 'application/pdf') {
             $pdf = new PDF2Text();
             $pdf->setFilename($this->getFullURI());
             $content = '';
             try {
                 $pdf->decodePDF();
                 $content = $pdf->output();
                 if ($content == '') {
                     // try with different multibyte setting
                     $pdf->setUnicode(true);
                     $pdf->decodePDF();
                     $content = $pdf->output();
                 }
             } catch (Exception $e) {
             }
             if ($content != '') {
                 $this->setExtractedInfo(utf8_encode($content));
             }
         }
         if ($this->getMimeType() == 'text/plain') {
             $content = file_get_contents($this->getFullURI());
             $this->setExtractedInfo(utf8_encode($content));
         }
     }
     parent::save($conn);
 }