Allow settings X-Axis position
This commit is contained in:
parent
2d30499b48
commit
4c5ab38bb1
|
|
@ -17,6 +17,7 @@ use setasign\Fpdi\Fpdi;
|
|||
class PDF extends FPDI
|
||||
{
|
||||
public $text_alignment = 'L';
|
||||
public $x_offset = 0; // New property for X-axis offset
|
||||
|
||||
public function Footer()
|
||||
{
|
||||
|
|
@ -33,16 +34,26 @@ class PDF extends FPDI
|
|||
// Set Y position
|
||||
$this->SetY(config('ninja.pdf_page_numbering_y_alignment'));
|
||||
|
||||
// Calculate X position with offset
|
||||
$base_x = config('ninja.pdf_page_numbering_x_alignment');
|
||||
$x_position = $base_x + $this->x_offset;
|
||||
|
||||
// Set X position based on alignment
|
||||
if ($this->text_alignment == 'L') {
|
||||
$this->SetX(5);
|
||||
$this->Cell($this->GetPageWidth() - 10, 5, $trans, 0, 0, 'L');
|
||||
$this->SetX($x_position);
|
||||
// Adjust cell width to account for X offset
|
||||
$cell_width = $this->GetPageWidth() - $x_position - 10;
|
||||
$this->Cell($cell_width, 5, $trans, 0, 0, 'L');
|
||||
} elseif ($this->text_alignment == 'R') {
|
||||
$this->SetX(0);
|
||||
$this->Cell($this->GetPageWidth(), 5, $trans, 0, 0, 'R');
|
||||
$this->SetX($x_position);
|
||||
// For right alignment, calculate width from X position to right edge
|
||||
$cell_width = $this->GetPageWidth() - $x_position;
|
||||
$this->Cell($cell_width, 5, $trans, 0, 0, 'R');
|
||||
} else {
|
||||
$this->SetX(0);
|
||||
$this->Cell($this->GetPageWidth(), 5, $trans, 0, 0, 'C');
|
||||
$this->SetX($x_position);
|
||||
// For center alignment, calculate appropriate width
|
||||
$cell_width = $this->GetPageWidth() - ($x_position * 2);
|
||||
$this->Cell($cell_width, 5, $trans, 0, 0, 'C');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ return [
|
|||
'storecove_email_catchall' => env('STORECOVE_CATCHALL_EMAIL',false),
|
||||
'qvalia_api_key' => env('QVALIA_API_KEY', false),
|
||||
'qvalia_partner_number' => env('QVALIA_PARTNER_NUMBER', false),
|
||||
'pdf_page_numbering_x_alignment' => env('PDF_PAGE_NUMBER_X', 5),
|
||||
'pdf_page_numbering_x_alignment' => env('PDF_PAGE_NUMBER_X', 0),
|
||||
'pdf_page_numbering_y_alignment' => env('PDF_PAGE_NUMBER_Y', -6),
|
||||
'hosted_einvoice_secret' => env('HOSTED_EINVOICE_SECRET', null),
|
||||
'e_invoice_quota_warning' => env('E_INVOICE_QUOTA_WARNING', 15),
|
||||
|
|
|
|||
Loading…
Reference in New Issue