diff --git a/Tasks/PdfBuilder.cs b/Tasks/PdfBuilder.cs
index c20b328..672bc3d 100644
--- a/Tasks/PdfBuilder.cs
+++ b/Tasks/PdfBuilder.cs
@@ -12,6 +12,7 @@ public class PdfBuilder
private const int CellsPerRow = 3;
private const int CellsPerPage = 21; // 3 columns × 7 rows
private readonly XFont _boldFont = new("Arial", 9, XFontStyleEx.Bold);
+ private readonly XFont _smallFont = new("Arial", 6, XFontStyleEx.Regular);
private readonly double _cellHeight = 42.43; // mm
private readonly double _cellPaddingBottom = 5; // mm
@@ -50,8 +51,29 @@ public class PdfBuilder
// Generate markdown addresses from all KasPersons in the set
var addresses = new string?[addressSet.KasPersons.Count];
+
+ // find customer (owner) to include sender_address
+ string senderLine = null;
+ try
+ {
+ var owner = Settings._instance.customers.customers.FirstOrDefault(c => c.ID == addressSet.owner_id);
+ if (owner != null && !string.IsNullOrWhiteSpace(owner.sender_address))
+ // ensure single line and wrap in a small-font tag
+ senderLine = "" + owner.sender_address.Replace("\n", " ").Trim() + "\n";
+ }
+ catch
+ {
+ senderLine = null;
+ }
+
for (var i = 0; i < addressSet.KasPersons.Count; i++)
- addresses[i] = AddressCreator.CreateFinalMarkdownString(addressSet.KasPersons[i].refsid);
+ {
+ var addr = AddressCreator.CreateFinalMarkdownString(addressSet.KasPersons[i].refsid);
+ if (!string.IsNullOrEmpty(senderLine))
+ addresses[i] = senderLine + (addr ?? "");
+ else
+ addresses[i] = addr;
+ }
CreateAddressLabelPdf(addresses, outputPath);
}
@@ -75,8 +97,28 @@ public class PdfBuilder
// Generate markdown addresses from all KasPersons in the set
var addresses = new string?[addressSet.KasPersons.Count];
+
+ // find customer (owner) to include sender_address
+ string senderLine = null;
+ try
+ {
+ var owner = Settings._instance.customers.customers.FirstOrDefault(c => c.ID == addressSet.owner_id);
+ if (owner != null && !string.IsNullOrWhiteSpace(owner.sender_address))
+ senderLine = "" + owner.sender_address.Replace("\n", " ").Trim() + "\n";
+ }
+ catch
+ {
+ senderLine = null;
+ }
+
for (var i = 0; i < addressSet.KasPersons.Count; i++)
- addresses[i] = AddressCreator.CreateFinalMarkdownString(addressSet.KasPersons[i].refsid);
+ {
+ var addr = AddressCreator.CreateFinalMarkdownString(addressSet.KasPersons[i].refsid);
+ if (!string.IsNullOrEmpty(senderLine))
+ addresses[i] = senderLine + (addr ?? "");
+ else
+ addresses[i] = addr;
+ }
CreateAddressLabelPdfWithPlaceholder(addresses, placeholderText, outputPath);
}
@@ -233,10 +275,8 @@ public class PdfBuilder
// Calculate total height of the text block
var totalHeight = lines.Length * lineHeight;
- // Start drawing from the lower-left corner of the cell
- var startY = y + cellHeight - paddingBottomPoints - totalHeight;
- if (startY < y + paddingTopPoints)
- startY = y + paddingTopPoints; // don't overflow top padding
+ // Start drawing from the top of the cell (align addresses to top)
+ var startY = y + paddingTopPoints;
var currentY = startY;
@@ -259,6 +299,27 @@ public class PdfBuilder
while (i < line.Length)
{
+ // Check for small-font tag ...
+ if (i <= line.Length - 7 && line.Substring(i, 7) == "")
+ {
+ var endTag = line.IndexOf("", i + 7, StringComparison.Ordinal);
+ if (endTag != -1)
+ {
+ var inner = line.Substring(i + 7, endTag - (i + 7));
+ if (!string.IsNullOrEmpty(inner))
+ {
+ gfx.DrawString(inner, _smallFont, XBrushes.Black,
+ new XRect(currentX, y, maxWidth - (currentX - x), _smallFont.Size * 1.2),
+ XStringFormats.TopLeft);
+ var measuredSmall = gfx.MeasureString(inner, _smallFont);
+ currentX += measuredSmall.Width;
+ }
+
+ i = endTag + 8; // move past
+ continue;
+ }
+ }
+
// Check for bold marker (**)
if (i < line.Length - 1 && line[i] == '*' && line[i + 1] == '*')
{