files[] = array('file'=>$file, 'name'=>$name, 'desc'=>$desc); } function OpenAttachmentPane() { $this->open_attachment_pane = true; } function _put($s) { $this->buffer .= $s."\n"; } function _putfiles() { $s = ''; foreach($this->files as $i=>$info) { //if (file_exists($file)) { $file = $info['file']; $name = $info['name']; $desc = $info['desc']; $fc = file_get_contents($file); if($fc===false) $this->Error('Cannot open file: '.$file); $md = @date('YmdHis', filemtime($file)); $this->_newobj(); $s .= $this->_textstring(sprintf('%03d',$i)).' '.$this->n.' 0 R '; $this->_put('<<'); $this->_put('/Type /Filespec'); $this->_put('/F ('.$this->_escape($name).')'); $this->_put('/UF '.$this->_textstring(utf8_encode($name))); $this->_put('/EF <n+1).' 0 R>>'); if($desc) $this->_put('/Desc '.$this->_textstring($desc)); $this->_put('>>'); $this->_put('endobj'); $this->_newobj(); $this->_put('<<'); $this->_put('/Type /EmbeddedFile'); $this->_put('/Length '.strlen($fc)); $this->_put("/Params <>"); $this->_put('>>'); $this->_putstream($fc); $this->_put('endobj'); //} } $this->_newobj(); $this->n_files = $this->n; $this->_put('<<'); $this->_put('/Names ['.$s.']'); $this->_put('>>'); $this->_put('endobj'); } function _putresources() { parent::_putresources(); if(!empty($this->files)) $this->_putfiles(); } function _putcatalog() { parent::_putcatalog(); if(!empty($this->files)) $this->_put('/Names <n_files.' 0 R>>'); if($this->open_attachment_pane) $this->_put('/PageMode /UseAttachments'); } } ?>