function print_letter($id) { $sql = 'select * from letter where id=\'' . $id . '\''; $link = start_nchsls(); if (!($result = mysql_query($sql, $link))) { echo mysql_error(); } $letter = mysql_fetch_assoc($result); $pdf = new MYPDF_NABL('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->letter = $letter; $pdf->SetMargins(10, 50); $pdf->SetAutoPageBreak(TRUE, 10); $pdf->SetFont('helvetica', '', 8); $pdf->AddPage(); $border = 0; $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, 50); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Subject:', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(30, 50); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['subject'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, 55); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Sub-subject:', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 2, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(30, 55); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['sub_subject'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $border = 0; $max_height = 0; if (strlen($pdf->letter['reference']) > 0) { $c_str = count_chars($pdf->letter['reference'], 0); $max_height = $c_str[13] * 5 + 5; $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, 60); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Reference:', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(30, 60); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['reference'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = $max_height, $valign = 'T', $fitcell = true); } $my_y = 55 + 5 + $max_height; $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, $my_y); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['greeting'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(10, $my_y + 5); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['body'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = true); $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY($x, $y + 10); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['thanks'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = true); $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY($x, $y + 5); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['closing'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = true); $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY($x, $y + 5); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['signature'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = true); if (strlen($pdf->letter['attachment_list']) > 0) { $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, $y + 10); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Attachments:', $border, $align = 'L', $fill = false, $ln = 0, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['attachment_list'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = $max_height, $valign = 'T', $fitcell = true); } if (strlen($pdf->letter['copy_to']) > 0) { $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, $y + 10); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Copy to:', $border, $align = 'L', $fill = false, $ln = 0, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['copy_to'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = $max_height, $valign = 'T', $fitcell = true); } $filename = $pdf->letter['id'] . '-' . $pdf->letter['type'] . '-' . $pdf->letter['date'] . '.pdf'; $pdf->Output($filename, 'I'); }
function print_report_pdf_A5($sample_id_array, $doctor) { $acr_check_code = array('-1' => '', '-2' => '', '-3' => '', '0' => '', '1' => 'low absurd', '2' => 'high absurd', '3' => 'low critical', '4' => 'high critical', '5' => '', '6' => ''); //A5=210,148 $pdf = new MYPDF_NABL('L', 'mm', 'A5', true, 'UTF-8', false); $pdf->sample_id_array = $sample_id_array; $pdf->doctor = $doctor; $pdf->login = $_SESSION['login']; // set default monospaced font //$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(10, 50); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, 10); //set image scale factor //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //$pdf->SetFont('times', '', 10); $pdf->SetFont('helvetica', '', 8); foreach ($sample_id_array as $value) { $pdf->sample_id = $value; $pdf->startPageGroup(); $pdf->AddPage(); $linkk = start_nchsls(); $sql_examination_data = 'select * from examination where sample_id=\'' . $pdf->sample_id . '\' order by name_of_examination'; $result_examination_data = mysql_query($sql_examination_data, $linkk); $counter = 45; $pdf->SetFont('helvetica', '', 10); $border = 0; while ($examination_array = mysql_fetch_assoc($result_examination_data)) { $counter = $counter + 5; if ($examination_array['id'] < 1000) { //available 190 mm //10+40+40+40+20+40 $pdf->SetXY(10, $counter); $pdf->Cell($w = 10, $h = 0, $examination_array['NABL_Accredited'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetXY(20, $counter); $pdf->Cell($w = 40, $h = 0, $examination_array['name_of_examination'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetXY(60, $counter); $pdf->Cell($w = 40, $h = 0, $examination_array['result'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetXY(100, $counter); $pdf->Cell($w = 40, $h = 0, $examination_array['referance_range'] . ' ' . $examination_array['unit'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetXY(140, $counter); $acr = $acr_check_code[check_critical_abnormal_reportable($examination_array['sample_id'], $examination_array['code'])]; $pdf->Cell($w = 20, $h = 0, $acr, $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetXY(160, $counter); $pdf->Cell($w = 40, $h = 0, $examination_array['method_of_analysis'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); if ($counter >= 120) { $counter = 45; $pdf->AddPage(); } } else { $pdf->SetXY(10, $counter); $pdf->Cell($w = 50, $h = 0, trim($examination_array['name_of_examination'], 'Z_'), $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetXY(60, $counter); $pdf->Cell($w = 140, $h = 0, $examination_array['result'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); if ($counter >= 120) { $counter = 45; $pdf->AddPage(); } } } } $pdf->Output('report.pdf', 'I'); }
// Page number $this->Cell(0, 10, 'Page ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); } } // create new PDF document $pdf = new MYPDF_NABL('L', 'mm', 'A5', true, 'UTF-8', false); $pdf->sample_id = 102907; $sample_id = 102907; //$pdf->setPrintHeader(false); //$pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(5, 55); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, 5); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('times', '', 10); $acr_check_code = array('-1' => '', '-2' => '', '-3' => '', '0' => '', '1' => 'low absurd', '2' => 'high absurd', '3' => 'low critical', '4' => 'high critical', '5' => '', '6' => ''); // add a page $pdf->AddPage(); $wth = $pdf->getPageWidth() - 10; $linkk = start_nchsls(); $sql_examination_data = 'select * from examination where sample_id=\'' . $sample_id . '\' order by name_of_examination'; $result_examination_data = mysql_query($sql_examination_data, $linkk); $counter = 55;