[fix:] fixed creation of empty lines

This commit is contained in:
Elias Fierke
2026-01-15 10:12:40 +01:00
parent af1c3ff8cc
commit 58964896ad
2 changed files with 11 additions and 12 deletions

View File

@@ -97,14 +97,14 @@ public static class AddressCreator
} }
CountryFound: CountryFound:
string_address = "\n**" + countryToShow + "**"; // Needs to be bold string_address = "**" + countryToShow + "**"; // Needs to be bold
address_line_count++; address_line_count++;
} }
// Alternative A: pplz valid and city existing // Alternative A: pplz valid and city existing
if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.pplz, address.land)) if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.pplz, address.land))
{ {
string_address = address.pplz + " " + address.ort + string_address; string_address = address.pplz + " " + address.ort + "\n" + string_address;
address_line_count++; address_line_count++;
if (!string.IsNullOrWhiteSpace(address.postfach)) if (!string.IsNullOrWhiteSpace(address.postfach))
{ {
@@ -122,7 +122,7 @@ public static class AddressCreator
if (!string.IsNullOrWhiteSpace(nameline)) if (!string.IsNullOrWhiteSpace(nameline))
{ {
string_address = nameline + string_address; string_address = nameline + "\n" + string_address;
address_line_count++; address_line_count++;
} }
@@ -168,7 +168,7 @@ public static class AddressCreator
if (!string.IsNullOrWhiteSpace(nameline)) if (!string.IsNullOrWhiteSpace(nameline))
{ {
string_address = nameline + string_address; string_address = nameline + "\n" + string_address;
address_line_count++; address_line_count++;
} }
@@ -206,16 +206,14 @@ public static class AddressCreator
new[] { anredezus, titel, vorname, adel, name } new[] { anredezus, titel, vorname, adel, name }
.Where(s => !string.IsNullOrWhiteSpace(s)) .Where(s => !string.IsNullOrWhiteSpace(s))
) )
+ (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})") + (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})");
+ "\n";
// else // else
return string.Join(" ", return string.Join(" ",
new[] { anrede, titel, vorname, adel, name } new[] { anrede, titel, vorname, adel, name }
.Where(s => !string.IsNullOrWhiteSpace(s)) .Where(s => !string.IsNullOrWhiteSpace(s))
) )
+ (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})") + (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})");
+ "\n";
} }
/// <summary> /// <summary>

View File

@@ -225,6 +225,7 @@ public class PdfBuilder
private void DrawLineWithMarkdown(XGraphics gfx, string line, double x, double y, double maxWidth) private void DrawLineWithMarkdown(XGraphics gfx, string line, double x, double y, double maxWidth)
{ {
if (string.IsNullOrWhiteSpace(line)) return;
var currentX = x; var currentX = x;
var i = 0; var i = 0;
@@ -318,7 +319,7 @@ public class PdfBuilder
if (string.IsNullOrEmpty(text)) if (string.IsNullOrEmpty(text))
return text; return text;
for (int len = text.Length; len > 0; len--) for (var len = text.Length; len > 0; len--)
{ {
var truncated = text.Substring(0, len); var truncated = text.Substring(0, len);
var measured = gfx.MeasureString(truncated, font); var measured = gfx.MeasureString(truncated, font);