getColumnVal("rev"); $_SESSION["revisioncertm30"] = $certificationrevision->getColumnVal("revm30"); $_SESSION["certname"] = $certificationrevision->getColumnVal("name_certification"); $_SESSION["certname30"] = $certificationrevision->getColumnVal("m30namecert"); $daterevformat = $certificationrevision->getColumnVal("date"); $timeStamp = strtotime($daterevformat); $_SESSION["certdate"] = date("d-m-Y", $timeStamp); $daterevformatm30 = $certificationrevision->getColumnVal("datem30"); $timeStampm30 = strtotime($daterevformatm30); $_SESSION["certdatem30"] = date("d-m-Y", $timeStampm30); $_SESSION["certtitle"] = $_SESSION["certname"] . ' rev. ' . $_SESSION["revisioncert"] . ' del ' . $_SESSION["certdate"]; $_SESSION["certtitlem30"] = $_SESSION["certname30"] . ' rev. ' . $_SESSION["revisioncertm30"] . ' del ' . $_SESSION["certdatem30"]; class PDF extends FPDF { /* CENTER IMAGE IN CELL */ const DPI = 96; const MM_IN_INCH = 25.4; const A4_HEIGHT = 297; const A4_WIDTH = 210; // tweak these values (in pixels), convert mm to px const MAX_WIDTH = 359.05511811; /* IMG CONTAINER - WIDTH */ const MAX_HEIGHT = 226.77165354; /* IMG CONTAINER - HEIGHT */ const MAX_WIDTH_S = 264.56692913; /* IMG CONTAINER SMALL - WIDTH */ const MAX_HEIGHT_S = 158.74015748; /* IMG CONTAINER SMALL - HEIGHT */ function pixelsToMM($val) { return $val * self::MM_IN_INCH / self::DPI; } function resizeToFit($imgFilename, $cellWidth, $cellHeight, $containerSize) { list($width, $height) = getimagesize($imgFilename); if ($containerSize == 'S') { /* SMALL CONTAINER SIZE */ $widthScale = self::MAX_WIDTH_S / $width; $heightScale = self::MAX_HEIGHT_S / $height; } else { /* DEFAULT CONTAINER SIZE */ $widthScale = self::MAX_WIDTH / $width; $heightScale = self::MAX_HEIGHT / $height; } $scale = min($widthScale, $heightScale); $width_in_mm = round($this->pixelsToMM($scale * $width)); /* IMAGE WIDTH */ $height_in_mm = round($this->pixelsToMM($scale * $height)); /* IMAGE HEIGHT */ /* IF IMAGE WIDTH IS SMALLER THAN THE CELL WIDTH, STRETCH IMAGE */ if ($width_in_mm < $cellWidth) { $add_w = $cellWidth - $width_in_mm; } else { $add_w = 0; } /* IF IMAGE IS IN PORTRAIT MODE, ALIGN TO CENTER */ if ($width_in_mm <= ($cellWidth / 2)) { $image_x = $width_in_mm / 2; $add_w = 0; } else { $image_x = 1; } /* IF IMAGE IS TALLER THAN CELL HEIGHT, RESIZE TO FIT */ if ($height_in_mm > $cellHeight) { $height_in_mm = $cellHeight; } /* IF IMAGE IS WIDER THAN CELL, RESIZE TO FIT */ if ($width_in_mm > $cellWidth) { $width_in_mm = $cellWidth - 2; } return array( $width_in_mm, $height_in_mm, $add_w, $image_x ); } function centreImage($img, $cellWidth, $cellHeight, $containerSize) { list($width, $height, $add_image_width, $add_abscissa) = $this->resizeToFit($img, $cellWidth - 2, $cellHeight - 1, $containerSize); // $this->Image($img, $this->GetX()+$add_abscissa, $this->GetY(), $width+$add_image_width, $height); $this->Image($img, $this->GetX() + $add_abscissa, $this->GetY() + 1, $width + $add_image_width, $height - 1); } /* END CENTER IMAGE IN CELL */ // Page header function Header() { // Logo // Assumi che $companyData sia giĆ definito e contenga i dati necessari if (isset($_SESSION['companylogo']) && !empty($_SESSION['companylogo'])) { // Costruisci il percorso dell'immagine nella cartella logos $companylogo = "logos/" . $_SESSION['companylogo']; if (file_exists($companylogo)) { list($width, $height) = getimagesize($companylogo); // Ottiene le dimensioni originali dell'immagine $max_height = 15; // Imposta l'altezza massima desiderata $scale = $max_height / $height; // Calcola il fattore di scala per mantenere le proporzioni $new_width = $width * $scale; // Calcola la nuova larghezza basata sul fattore di scala // Inserisci l'immagine del logo con le dimensioni scalate e la posizione specificate $this->Image($companylogo, 5, 5, $new_width, $max_height); } // Se il file non esiste, non fare nulla, lasciando lo spazio vuoto } $this->SetFont('Arial', '', 7); $this->Ln(5); $this->Cell(0, -5, $_SESSION['companyname'], 0, 0, "R"); $this->Cell(0, 2, $_SESSION['companyaddress'], 0, 0, "R"); $this->Cell(0, 9, $_SESSION['phonemail'], 0, 0, "R"); $this->SetFont('Arial', 'B', 10); $this->Ln(5); if ($_SESSION["sndrptsession"] == 'N' and $_SESSION["idcertificatesession"] == 1 || $_SESSION["idcertificatesession"] == 3 || $_SESSION["idcertificatesession"] == 8 || $_SESSION["idcertificatesession"] == 9) { $this->Cell(0, 35, $GLOBALS['nappformfinaltest'], 0, 0, "C"); } else { $this->Cell(0, 35, $GLOBALS['nappformfinal'], 0, 0, "C"); } // Line break $this->Ln(25); } // Page footer function Footer() { // Position at 1.5 cm from bottom $this->SetY(-45); // Arial italic 8 $this->SetFont('Arial', '', 8); // Page number and certification revision // $revisioncert=$certificationrevision->getColumnVal("rev"); // $certname=$certificationrevision->getColumnVal("name_certification"); // $certdate=$certificationrevision->getColumnVal("date"); // $certtitle=$certname.' rev. '.$revisioncert.' '.$certdate; $certittle = $_SESSION["certtitle"]; $certittlem30 = $_SESSION["certtitlem30"]; if ($_SESSION["sndrptsession"] == 'N' and $_SESSION["idcertificatesession"] == 1 || $_SESSION["idcertificatesession"] == 3 || $_SESSION["idcertificatesession"] == 8 || $_SESSION["idcertificatesession"] == 9) { $this->Cell(0, 10, $certittlem30 . ' - Pagina ' . $this->PageNo() . '/{nb}', 0, 0, 'C'); $this->Image('../images/cimaclaboratories.png', 10, 260, 190); } else { $this->Cell(0, 10, $certittle . ' - Pagina ' . $this->PageNo() . '/{nb}', 0, 0, 'C'); $this->Image('../images/cimaccertifications.png', 10, 260, 190); } } //include('pdfcreation/headerandfooter.php'); } //some general data $certname = $certificationrevision->getColumnVal("name_certification"); // Instanciation of inherited class $pdf = new PDF(); $pdf->AddFont('DejaVuSans', '', 'DejaVuSans.php'); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Times', '', 9); $pdf->SetAutoPageBreak(true, 45); // from here start customization based on certification required required // certificate 5 and 6 Table: contacts auditdpi and documents //header manufacturer data include('tdpdfcreation/headercertificatetable.php'); $pdf->Ln(); //header prod place include('tdpdfcreation/prodplace.php'); $pdf->Ln(); //header risk assesment include('tdpdfcreation/riskassesment.php'); $pdf->Ln(); //description table //include('pdfcreation/descriptiontable.php'); $pdf->Ln(); // standards table //include('pdfcreation/standardstable.php'); $pdf->Ln(); // additionalinfo requirements //include('pdfcreation/addreqtable.php'); $pdf->Ln(); // additionalinfo //include('pdfcreation/addinfotable.php'); $pdf->Ln(); // parts table //include('pdfcreation/partstable.php'); $pdf->Ln(); // chem table //include('pdfcreation/chemtable.php'); $pdf->Ln(); //trf option //include('pdfcreation/trfoption.php'); $pdf->Ln(); //trf option //include('pdfcreation/fileattached.php'); $pdf->Ln(); $pdf->Ln(); //header certificate contact //include('pdfcreation/headercertificatetable.php'); $pdf->Ln(); //invoice contact //include('pdfcreation/invoicecontacttable.php'); $pdf->Ln(); //Sign datatable //include('pdfcreation/signdatatable.php'); $pdf->Ln(); //outpt pdf for all certificate include('tdpdfcreation/pdfoutput.php'); //include('pdfcreation/pdf1sndbis.php'); ?>