@php function mmToPx($mm, $dpi = 96) { // Assuming 1 inch is equal to 25.4 millimeters // and 1 inch is approximately equal to 96 pixels (in web development) $inch = $mm / 25.4; $px = $inch * $dpi; return $px; } function pxToMm($px, $dpi = 96) { // Assuming 1 inch is equal to 25.4 millimeters // and 1 inch is approximately equal to 96 pixels (in web development) $inch = $px / $dpi; $mm = $inch * 25.4; return $mm; } $style_width = $certificate->width . 'mm'; $style_height = $certificate->height . 'mm'; $style_width = str_replace('.', '', $style_width); $style_height = str_replace('.', '', $style_height); $body_font_size = $certificate->body_font_size; $page_height= mmToPx(floatval($certificate->height)); $page_width= mmToPx(floatval($certificate->width)); //mm to px //first element should 15% margin top of page_height $first_element_margin_top= intval($page_height)* 0.05; $first_element_margin_top= $first_element_margin_top.'px'; $student_image_size= intval($page_height)* 0.1; $student_image_size= $student_image_size.'px'; $second_element_margin_top= intval($page_height)* 0.2; $second_element_margin_top= $second_element_margin_top.'px'; // dd(pxToMm($page_height)); $certificate_height = floatval($certificate->height); $certificate_width = floatval($certificate->width); $half_of_a4_sheet = 297 / 2; $half_of_a4_sheet_height = 210 / 2; $half_of_certificate_height = $certificate_height / 2; //check is possible to print 2 certificate in a page if ($certificate_height <= $half_of_a4_sheet_height && $certificate_width <= $half_of_a4_sheet) { $is_possible_to_print_2_certificate_in_a_page = true; } else { $is_possible_to_print_2_certificate_in_a_page = false; } @endphp
@foreach ($students as $key => $student)
@if($certificate->student_photo == 1) @endif
{{ @$certificate->header_left_text }}
@lang('common.date'): {{ @$certificate->date }}
{{ isset($student['student_id']) ? App\SmStudentCertificate::certificateBody($certificate->body, 2, $student['student_id']) : '' }}
{{ @$certificate->footer_left_text }}
{{ @$certificate->footer_center_text }}
{{ @$certificate->footer_right_text }}
@if($is_possible_to_print_2_certificate_in_a_page) @if($key % 2 != 0)
@endif @elseif($certificate->layout == 1)
@endif @endforeach