php append pdf to pdf and check the page template first

i have a form where people can upload pdfs

with fpdf I append those pdf and generate a new one.
this works ok, unless someone uploads a vertical aligned pdf.
is there a way I can determine which alignment a pdf has?
this is my code to append:

/* APPEND PDFs */
    $files = [];
    array_push($files, $upload_folder . '/' . $pdf_name);
    if($new_path != 0 & $ext == 'pdf'){
        array_push($files, $new_path);
    }
    if($new_path1 != 0  & $ext1 == 'pdf'){
        array_push($files, $new_path1);
    }
    if($new_path2 != 0  & $ext2 == 'pdf'){
        array_push($files, $new_path2);
    }
    if($new_path3 != 0  & $ext3 == 'pdf'){
        array_push($files, $new_path3);
    }
    if($new_path4 != 0  & $ext4 == 'pdf'){
        array_push($files, $new_path4);
    }
    if($new_path5 != 0 & $ext5 == 'pdf'){
        array_push($files, $new_path5);
    }
    if($new_path6 != 0  & $ext6 == 'pdf'){
        array_push($files, $new_path6);
    }

pdf = new setasignFpdiFpdi();

// iterate over array of files and merge
foreach ($files as $file) {
    $pageCount = $pdf->setSourceFile($file);
    for ($i = 0; $i < $pageCount; $i++) {
        $tpl = $pdf->importPage($i + 1, '/MediaBox');
        $pdf->addPage();
        $pdf->useTemplate($tpl);
    }
}

// output the pdf as a file (http://www.fpdf.org/en/doc/output.htm)
$pdf->Output('F',$upload_folder . '/' . $pdf_name);

thanks a lot