BBnepal-Accounts/application/libraries/M_pdf.php

219 lines
4.5 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<?php
require_once APPPATH . '/third_party/mpdf/vendor/autoload.php';
if (!defined('BASEPATH')) exit('No direct script access allowed');
class M_pdf
{
function m_pdf()
{
$CI = &get_instance();
}
function loadforStudentIdCard()
{
// ['mode' => 'utf-8', 'format' => [56, 86]]
$mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8', 'format' => [58, 86], 'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0
]);
return $mpdf;
}
function loadforStudentAdmitCard()
{
// ['mode' => 'utf-8', 'format' => [56, 86]]
$mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8', 'format' => [100, 60],
'margin_left' => 2,
'margin_right' => 2,
'margin_top' => 0,
'margin_bottom' => 0
]);
return $mpdf;
}
function load()
{
$mpdf = new \Mpdf\Mpdf();
return $mpdf;
}
function loadforinvoice()
{
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new \Mpdf\Mpdf([
'mode' => '',
'format' => 'A4',
'default_font_size' => 0,
'default_font' => '',
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 5,
'margin_bottom' => 5,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'L',
'tempDir' => __DIR__ . '/upload',
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/fonts'
]),
'fontdata' => $fontData + [
'bentonsans' => [
'R' => "Times New Roman Font.ttf",
],
],
// 'default_font' => 'bentonsans'
]);
return $mpdf;
}
function loadformarkscard()
{
$mpdf = new \Mpdf\Mpdf([
'mode' => '',
'format' => 'A4',
'default_font_size' => 0,
'default_font' => '',
'margin_left' => 3,
'margin_right' => 3,
'margin_top' => 3,
'margin_bottom' => 3,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'P',
// 'default_font' => 'dejavusans'
]);
// $mpdf->SetWatermarkText('DRAFT');
// $mpdf->showWatermarkText = true;
// $mpdf->SetWatermarkImage('https://demo.bbnepal.com/common_assets/watermark-emerald.png', 0.1);
// $mpdf->showWatermarkImage = true;
// $mpdf->watermarkAngle = 0;
return $mpdf;
}
function loadFromCertificate()
{
$mpdf = new \Mpdf\Mpdf([
'mode' => '',
'format' => 'A4',
'default_font_size' => 12,
'default_font' => '',
'margin_left' => 4,
'margin_right' => 4,
'margin_top' => 4,
'margin_bottom' => 4,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'L',
]);
$mpdf->watermarkAngle = 45;
return $mpdf;
}
function loadforStudentQRCode()
{
// ['mode' => 'utf-8', 'format' => [56, 86]]
$mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8', 'format' => [120, 100],
'margin_left' => 4,
'margin_right' => 4,
'margin_top' => 4,
'margin_bottom' => 4
]);
return $mpdf;
}
function loadforAdmissionForm()
{
$mpdf = new \Mpdf\Mpdf([
'mode' => '',
'format' => 'A4',
'default_font_size' => 0,
'default_font' => '',
'margin_left' => 3,
'margin_right' => 3,
'margin_top' => 3,
'margin_bottom' => 3,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'P',
// 'default_font' => 'dejavusans'
]);
// $mpdf->SetWatermarkText('DRAFT');
// $mpdf->showWatermarkText = true;
// $mpdf->SetWatermarkImage('https://demo.bbnepal.com/common_assets/watermark-emerald.png', 0.1);
// $mpdf->showWatermarkImage = true;
// $mpdf->watermarkAngle = 0;
return $mpdf;
}
}