dealfonso / sapp

Simple and Agnostic PDF Document Parser in PHP - sign PDF docs using PHP
GNU Lesser General Public License v3.0
110 stars 29 forks source link

Is there any option to add attach/embed files on PDF? #72

Closed jose123v closed 2 months ago

jose123v commented 2 months ago

https://help.adobe.com/user-guide/frm_text_tx-attach-embed-files.html lib/Cpdf.php#L5471-L5487 FPDF/scripts/Attachments/AttachmentsTrait.php

dealfonso commented 2 months ago

not at this time

parallels999 commented 2 months ago

Hi, there is an example on FPDF, maybe it can be added

http://www.fpdf.org/en/script/script95.php

$fc = file_get_contents($file);
if($fc===false)
    $this->Error('Cannot open file: '.$file);
$size = strlen($fc);
$date = @date('YmdHisO', filemtime($file));
$md = 'D:'.substr($date,0,-2)."'".substr($date,-2)."'";;

$this->_put('<<');
$this->_put('/Type /Filespec');
$this->_put('/F ('.$this->_escape($name).')');
$this->_put('/UF '.$this->_textstring($name));
$this->_put('/EF <</F '.($this->n+1).' 0 R>>');
if($desc)
    $this->_put('/Desc '.$this->_textstring($desc));
$this->_put('/AFRelationship /Unspecified');
$this->_put('>>');
$this->_put('endobj');

$this->_newobj();
$this->_put('<<');
$this->_put('/Type /EmbeddedFile');
$this->_put('/Subtype /application#2Foctet-stream');
$this->_put('/Length '.$size);
$this->_put('/Params <</Size '.$size.' /ModDate '.$this->_textstring($md).'>>');
$this->_put('>>');
$this->_putstream($fc);
$this->_put('endobj');

https://github.com/tecnickcom/TCPDF/issues/578#issuecomment-1367309727