Чтобы распечатать чек с помощью PHP и CodeIgniter, вы можете воспользоваться несколькими способами. Вот несколько примеров:
Метод 1. Использование HTML и CSS
<?php
$amount = 1000; // Amount to be printed on the cheque
$date = date('Y-m-d'); // Current date
$html = '
<html>
<head>
<title>Cheque Example</title>
<style>
body {
font-family: Arial, sans-serif;
}
.cheque {
width: 600px;
height: 300px;
border: 2px solid #000;
padding: 10px;
}
.amount {
font-size: 24px;
font-weight: bold;
margin-bottom: 20px;
}
.date {
font-size: 14px;
}
</style>
</head>
<body>
<div class="cheque">
<div class="amount">$' . $amount . '</div>
<div class="date">Date: ' . $date . '</div>
</div>
</body>
</html>';
// Output the HTML
echo $html;
?>
Метод 2: использование библиотеки PDF (TCPDF)
<?php
require_once('tcpdf/tcpdf.php');
$amount = 1000; // Amount to be printed on the cheque
$date = date('Y-m-d'); // Current date
// Create new PDF document
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
// Set document information
$pdf->SetCreator('Your Name');
$pdf->SetAuthor('Your Name');
$pdf->SetTitle('Cheque Example');
$pdf->SetSubject('Cheque Printing');
$pdf->SetKeywords('cheque, payment');
// Add a page
$pdf->AddPage();
// Set font
$pdf->SetFont('helvetica', '', 12);
// Print amount
$pdf->Cell(0, 10, 'Amount: $' . $amount, 0, 1);
// Print date
$pdf->Cell(0, 10, 'Date: ' . $date, 0, 1);
// Output the PDF as a file
$pdf->Output('cheque.pdf', 'D');
?>
Метод 3: использование сторонней библиотеки (mike42/escpos-php)
<?php
require_once('escpos-php/autoload.php');
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\CapabilityProfile;
$amount = 1000; // Amount to be printed on the cheque
$date = date('Y-m-d'); // Current date
$connector = new FilePrintConnector("cheque.txt");
$printer = new Printer($connector);
// Set font
$printer->setJustification(Printer::JUSTIFY_CENTER);
$printer->setTextSize(2, 2);
$printer->text("Amount: $" . $amount . "\n");
// Set font
$printer->setTextSize(1, 1);
$printer->text("Date: " . $date . "\n");
$printer->cut();
$printer->close();
?>