mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 13:42:49 +01:00
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* Invoice Ninja (https://invoiceninja.com).
|
||
|
*
|
||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||
|
*
|
||
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||
|
*
|
||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||
|
*/
|
||
|
|
||
|
namespace App\Utils\Traits\Pdf;
|
||
|
|
||
|
use App\Utils\Traits\Pdf\PDF;
|
||
|
use setasign\Fpdi\PdfParser\StreamReader;
|
||
|
|
||
|
trait PageNumbering
|
||
|
{
|
||
|
|
||
|
public function pageNumbers($pdf_data_object)
|
||
|
{
|
||
|
|
||
|
// initiate PDF
|
||
|
$pdf = new PDF();
|
||
|
|
||
|
// set the source file
|
||
|
$pageCount = $pdf->setSourceFile(StreamReader::createByString($pdf_data_object));
|
||
|
|
||
|
$pdf->AliasNbPages();
|
||
|
for ($i=1; $i <= $pageCount; $i++) {
|
||
|
//import a page then get the id and will be used in the template
|
||
|
$tplId = $pdf->importPage($i);
|
||
|
|
||
|
//create a page
|
||
|
$templateSize = $pdf->getTemplateSize($tplId);
|
||
|
$pdf->AddPage('', [$templateSize['width'], $templateSize['height']]);
|
||
|
|
||
|
$pdf->useTemplate($tplId);
|
||
|
}
|
||
|
|
||
|
|
||
|
return $pdf->Output();
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|