diff --git a/Tasks/AddressCreation.cs b/Tasks/AddressCreation.cs index 6c7beab..faccf68 100644 --- a/Tasks/AddressCreation.cs +++ b/Tasks/AddressCreation.cs @@ -97,14 +97,14 @@ public static class AddressCreator } CountryFound: - string_address = "\n**" + countryToShow + "**"; // Needs to be bold + string_address = "**" + countryToShow + "**"; // Needs to be bold address_line_count++; } // Alternative A: pplz valid and city existing 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++; if (!string.IsNullOrWhiteSpace(address.postfach)) { @@ -122,7 +122,7 @@ public static class AddressCreator if (!string.IsNullOrWhiteSpace(nameline)) { - string_address = nameline + string_address; + string_address = nameline + "\n" + string_address; address_line_count++; } @@ -168,7 +168,7 @@ public static class AddressCreator if (!string.IsNullOrWhiteSpace(nameline)) { - string_address = nameline + string_address; + string_address = nameline + "\n" + string_address; address_line_count++; } @@ -206,16 +206,14 @@ public static class AddressCreator new[] { anredezus, titel, vorname, adel, name } .Where(s => !string.IsNullOrWhiteSpace(s)) ) - + (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})") - + "\n"; + + (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})"); // else return string.Join(" ", new[] { anrede, titel, vorname, adel, name } .Where(s => !string.IsNullOrWhiteSpace(s)) ) - + (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})") - + "\n"; + + (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})"); } /// diff --git a/Tasks/PdfBuilder.cs b/Tasks/PdfBuilder.cs index f1b5f82..7b892ec 100644 --- a/Tasks/PdfBuilder.cs +++ b/Tasks/PdfBuilder.cs @@ -225,6 +225,7 @@ public class PdfBuilder private void DrawLineWithMarkdown(XGraphics gfx, string line, double x, double y, double maxWidth) { + if (string.IsNullOrWhiteSpace(line)) return; var currentX = x; var i = 0; @@ -245,7 +246,7 @@ public class PdfBuilder if (!string.IsNullOrEmpty(inner)) { var measuredSmall = gfx.MeasureString(inner, _smallFont); - + if (measuredSmall.Width > remainingWidth) { inner = TruncateTextToWidth(gfx, inner, _smallFont, remainingWidth); @@ -272,7 +273,7 @@ public class PdfBuilder { var boldText = line.Substring(i + 2, endIndex - (i + 2)); var measured = gfx.MeasureString(boldText, _boldFont); - + if (measured.Width > remainingWidth) { boldText = TruncateTextToWidth(gfx, boldText, _boldFont, remainingWidth); @@ -297,7 +298,7 @@ public class PdfBuilder if (!string.IsNullOrEmpty(regularText)) { var measured = gfx.MeasureString(regularText, _regularFont); - + if (measured.Width > remainingWidth) { regularText = TruncateTextToWidth(gfx, regularText, _regularFont, remainingWidth); @@ -318,7 +319,7 @@ public class PdfBuilder if (string.IsNullOrEmpty(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 measured = gfx.MeasureString(truncated, font);