When using mPDF to generate a sales invoice PDF that aligns with a pre-printed form, the alignment is perfect on the first print after resetting the printer. However, when printing the same or any other sales invoice again, the alignment shifts, causing the printed content to misalign with the pre-printed form. This issue occurs even though the PDF preview before printing is correct and consistent for all invoices. Each page prints with a different alignment.
I am using a custom page size of 210mm x 290mm
I am using an Epson LQ-690 dot matrix printer. Is this problem happening because of the mPDF code, or is it a hardware issue? How can I solve this problem?
Below are the mPDF settings I am using:
$mpdf = new \Mpdf\Mpdf([
'margin_header' => 0,
'margin_footer' => 0,
'margin_top' => 0,
'margin_left' => 0,
'margin_right' => 0,
'margin_bottom' => 0,
'format' => [210, 290], // Custom page size in mm (width, height)
'default_font' => 'Myriad Pro',
'default_font_size' => 10,
'keep_table_proportions' => true,
'autoPageBreak' => true,
'shrink_tables_to_fit' => 1,
'SetAutoPageBreak' => true,
'setAutoTopMargin' => 'stretch',
'setAutoBottomMargin' => 'stretch',
'adjust_font_disparity' => true,
]);
// Additional settings to ensure consistent margins
$mpdf->SetMargins(0, 0, 0);
$mpdf->SetAutoPageBreak(true, 0);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeaderByName('Header');
$mpdf->SetHTMLFooterByName('Footer');
$mpdf->SetTitle('INVOICE');
$mpdf->SetSubject('INVOICE');
$mpdf->autoScriptToLang = true;
$mpdf->autoLangToFont = true;
$mpdf->WriteHTML($htmlContent);
$mpdf->SetHTMLFooterByName('Footer');
ob_clean();
$mpdf->Output();
I need to understand whether this issue is caused by the mPDF code or if it's related to the printer hardware (Epson LQ-690 dot matrix printer). Additionally, I'm looking for guidance on how to resolve this issue to ensure consistent alignment across all prints.