settings->page_numbering) return $pdf_data_object; try { $pdf = new PDF(); $pdf->setAlignment($company->getSetting('page_numbering_alignment')); $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['orientation'], [$templateSize['width'], $templateSize['height']]); $pdf->useTemplate($tplId); } return $pdf->Output('S'); } catch(\Exception $e) { nlog($e->getMessage()); } } }