/** * @return object * @throws SampleIDMissingException * @throws BaseReportTCPDFClassMissingException */ public static function get_barcode_report() { if (class_exists("TCPDF")) { if ($_GET['sample_id']) { $sample_id = $_GET['sample_id']; if ($_GET['paper_size']) { $paper_size_info_array = PaperSize::get_size_by_id($_GET['paper_size']); } else { $paper_size_info_array = PaperSize::get_standard_size(); } $format = array($paper_size_info_array['width'], $paper_size_info_array['height']); if ($paper_size_info_array['width'] >= $paper_size_info_array['height']) { $orientation = "L"; } else { $orientation = "P"; } $pdf = new TCPDF($orientation, "mm", $format, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Open-LIMS'); $pdf->SetTitle('Sample Report'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins($paper_size_info_array['margin_left'], $paper_size_info_array['margin_top'], $paper_size_info_array['margin_right']); $pdf->SetAutoPageBreak(TRUE, $paper_size_info_array['margin_bottom']); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->AddPage(); $page_width = $paper_size_info_array['width'] - $paper_size_info_array['margin_left'] - $paper_size_info_array['margin_right']; $page_height = $paper_size_info_array['height'] - $paper_size_info_array['margin_top']; $font_size = $page_height * 0.1; if ($page_width * 0.6 > $page_height) { $barcode_height = $page_height - $font_size; $barcode_width = null; } else { $barcode_height = $page_width * 0.6; $barcode_width = $page_width; } $print_sample_id = "S" . str_pad($sample_id, 8, '0', STR_PAD_LEFT); $style = array('position' => '', 'align' => 'C', 'stretch' => true, 'fitwidth' => false, 'cellfitalign' => '', 'border' => false, 'hpadding' => 'auto', 'vpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'text' => true, 'font' => 'helvetica', 'fontsize' => $font_size, 'stretchtext' => 4); $pdf->write1DBarcode($print_sample_id, 'C128B', '', '', $barcode_width, $barcode_height, 0.2, $style, 'M'); return $pdf; } else { throw new SampleIDMissingException(); } } else { throw new BaseReportTCPDFClassMissingException(); } }