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'); }
// $stretch=1, $ignore_min_height=false, $calign='T', $valign='M'); //} } // print a block of text using Write() /** * This method prints text from the current position.<br /> * @param $h (float) Line height * @param $txt (string) String to print * @param $link (mixed) URL or identifier returned by AddLink() * @param $fill (boolean) Indicates if the cell background must be painted (true) or transparent (false). * @param $align (string) Allows to center or align the text. Possible values are:<ul><li>L or empty string: left align (default value)</li><li>C: center</li><li>R: right align</li><li>J: justify</li></ul> * @param $ln (boolean) if true set cursor at the bottom of the line, otherwise set cursor at the top of the line. * @param $stretch (int) font stretch mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if text is larger than cell width</li><li>2 = forced horizontal scaling to fit cell width</li><li>3 = character spacing only if text is larger than cell width</li><li>4 = forced character spacing to fit cell width</li></ul> General font stretching and scaling values will be preserved when possible. * @param $firstline (boolean) if true prints only the first line and return the remaining string. * @param $firstblock (boolean) if true the string is the starting of a line. * @param $maxh (float) maximum height. The remaining unprinted text will be returned. It should be >= $h and less then remaining space to the bottom of the page, or 0 for disable this feature. * @param $wadj (float) first line width will be reduced by this amount (used in HTML mode). * @param $margin (array) margin array of the parent container * @return mixed Return the number of cells or the remaining string if $firstline = true. * @public * @since 1.5 public function Write($h, $txt, $link='', $fill=false, $align='', $ln=false, $stretch=0, $firstline=false, $firstblock=false, $maxh=0, $wadj=0, $margin='') { // check page for no-write regions and adapt page margins if necessary */ // --------------------------------------------------------- //Close and output PDF document $pdf->Output('report.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+