Skip to content

Commit

Permalink
Merge pull request #13 from nykopol/master
Browse files Browse the repository at this point in the history
work well with esoteric page format
  • Loading branch information
lucas-gp authored Oct 21, 2022
2 parents 6a43f33 + e59242a commit c5b7ece
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Facturx.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function generateFacturxFromFiles(
for ($i = 1; $i <= $pageCount; ++$i) {
$tplIdx = $pdfWriter->importPage($i, '/MediaBox');
$pdfWriter->AddPage();
$pdfWriter->useTemplate($tplIdx);
$pdfWriter->useTemplate($tplIdx, 0, 0, null, null, true);
if (true == $addFacturxLogo && 1 == $i) { // add Factur-X logo on first page only
$pdfWriter->Image(__DIR__.'/../img/'.static::FACTURX_LOGO[$this->profil], 197, 2.5, 7);
}
Expand Down
6 changes: 4 additions & 2 deletions src/Fpdi/FdpiFacturx.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,19 @@ protected function _put_file_stream(array $file_info)
$this->_put('/Subtype /'.$file_info['subtype']);
}
$this->_put('/Type /EmbeddedFile');
if (@is_file($file_info['file'])) {
if (is_string($file_info['file']) && @is_file($file_info['file'])) {
$fc = file_get_contents($file_info['file']);
$md = @date('YmdHis', filemtime($file_info['file']));
} else {
$stream = $file_info['file']->getStream();
\fseek($stream, 0);
$fc = stream_get_contents($stream);
$md = @date('YmdHis');
}
if (false === $fc) {
$this->Error('Cannot open file: '.$file_info['file']);
}
$md = @date('YmdHis', filemtime($file_info['file']));

$fc = gzcompress($fc);
$this->_put('/Length '.strlen($fc));
$this->_put("/Params <</ModDate (D:$md)>>");
Expand Down

0 comments on commit c5b7ece

Please sign in to comment.