I have a list itemDescList that contains n number of strings. In pdfCreate , the app draws a rectangle and in the same rectangle it draws a string or multiple. My problem is when I tried it like this, the strings overlap when I need them to be one under the other. I understand why this isn't working - foreach string in the list it gets drawn on the same position, however I cannot figure out how to do this. Any ideas?
rect = new XRect(35, 320, 300, 125);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.Alignment = XParagraphAlignment.Center;
foreach (string item in itemDescList)
{
tf.DrawString(item + "\n", invoiceItemsFont, XBrushes.Black, rect, XStringFormats.TopLeft);
}
If anyone stumbles upon this question. Here's the answer:
yBase = 320;
yOffset = 0;
lineHeight = 15;
rect = new XRect(340, yBase, 30, 155);
gfx.DrawRectangle(XBrushes.SeaShell, rect);
tf.Alignment = XParagraphAlignment.Center;
foreach (string item in quantityList)
{
XRect lineRect = new XRect(340, yBase + yOffset, 30, 125);
tf.DrawString(item, invoiceItemsFont, XBrushes.Black, lineRect, XStringFormats.TopLeft);
yOffset += lineHeight;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.