Skip to content

Commit

Permalink
fixed wrong method name; make conversion linux-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
kohlerdominik committed Sep 3, 2024
1 parent 5490e91 commit fec65e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/PaymentPart/Output/FpdfOutput/FpdfOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function addInformationContentReceipt(): void
// Title
$this->fpdf->SetFont(self::FONT, 'B', self::FONT_SIZE_MAIN_TITLE);
$this->SetXY(self::LEFT_PART_X, self::TITLE_Y);
$this->fpdf->MultiCell(0, 7, $this->toUtf8(Translation::get('receipt', $this->language)));
$this->fpdf->MultiCell(0, 7, $this->substituteUnsupportedCharacters(Translation::get('receipt', $this->language)));

// Elements
$this->setY(204);
Expand All @@ -149,15 +149,15 @@ private function addInformationContentReceipt(): void
// Acceptance section
$this->fpdf->SetFont(self::FONT, 'B', self::FONT_SIZE_TITLE_RECEIPT);
$this->SetXY(self::LEFT_PART_X, 274.3);
$this->fpdf->Cell(54, 0, $this->toUtf8(Translation::get('acceptancePoint', $this->language)), self::BORDER, '', self::ALIGN_RIGHT);
$this->fpdf->Cell(54, 0, $this->substituteUnsupportedCharacters(Translation::get('acceptancePoint', $this->language)), self::BORDER, '', self::ALIGN_RIGHT);
}

private function addInformationContent(): void
{
// Title
$this->fpdf->SetFont(self::FONT, 'B', self::FONT_SIZE_MAIN_TITLE);
$this->SetXY(self::RIGHT_PART_X, 195.2);
$this->fpdf->MultiCell(48, 7, $this->toUtf8(Translation::get('paymentPart', $this->language)));
$this->fpdf->MultiCell(48, 7, $this->substituteUnsupportedCharacters(Translation::get('paymentPart', $this->language)));

// Elements
$this->setY(197.3);
Expand Down Expand Up @@ -229,7 +229,7 @@ private function addSeparatorContentIfNotPrintable(): void
$this->fpdf->Line(62 + $this->offsetX, 193 + $this->offsetY, 62 + $this->offsetX, 296 + $this->offsetY);
$this->fpdf->SetFont(self::FONT, '', self::FONT_SIZE_FURTHER_INFORMATION);
$this->setY(189.6);
$this->fpdf->MultiCell(0, 0, $this->toUtf8(Translation::get('separate', $this->language)), self::BORDER, self::ALIGN_CENTER);
$this->fpdf->MultiCell(0, 0, $this->substituteUnsupportedCharacters(Translation::get('separate', $this->language)), self::BORDER, self::ALIGN_CENTER);
}
}

Expand Down Expand Up @@ -273,7 +273,7 @@ private function setTextElement(Text $element, bool $isReceiptPart): void
$this->fpdf->MultiCell(
$isReceiptPart ? 54 : 0,
$isReceiptPart ? 3.3 : 4,
str_replace('text.', '', $this->toUtf8($element->getText())),
str_replace('text.', '', $this->substituteUnsupportedCharacters($element->getText())),
self::BORDER,
self::ALIGN_LEFT
);
Expand All @@ -286,7 +286,7 @@ private function setFurtherInformationElement(FurtherInformation $element): void
$this->fpdf->MultiCell(
0,
4,
$this->toUtf8($element->getText()),
$this->substituteUnsupportedCharacters($element->getText()),
self::BORDER,
self::ALIGN_LEFT
);
Expand Down Expand Up @@ -336,8 +336,8 @@ private function SetXY(float $x, float $y): void
$this->fpdf->SetXY($x + $this->offsetX, $y + $this->offsetY);
}

private function toUtf8(string $text): string
private function substituteUnsupportedCharacters(string $text): string
{
return iconv('UTF-8', 'windows-1252', $text) ?: '';
return mb_convert_encoding($text, 'ISO-8859-1', 'UTF-8');
}
}
6 changes: 3 additions & 3 deletions src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private function setFurtherInformationElement(FurtherInformation $element): void
{
$this->tcPdf->SetFont(self::FONT, '', self::FONT_SIZE_FURTHER_INFORMATION);
$this->printMultiCell(
$this->toUtf8($element->getText()),
$this->substituteUnsupportedCharacters($element->getText()),
0,
0,
self::BORDER
Expand Down Expand Up @@ -353,8 +353,8 @@ private function printLine(int $x1, int $y1, int $x2, int $y2): void
$this->tcPdf->Line($x1+$this->offsetX, $y1+$this->offsetY, $x2+$this->offsetX, $y2+$this->offsetY);
}

private function toUtf8(string $text): string
private function substituteUnsupportedCharacters(string $text): string
{
return iconv('UTF-8', 'windows-1252', $text) ?: '';
return mb_convert_encoding($text, 'ISO-8859-1', 'UTF-8');
}
}

0 comments on commit fec65e4

Please sign in to comment.