How to place 30 items each page (arrange in 2 columns) ? #21
-
Within the content of a page, I am trying to lay out 30 items in 2 columns: Item 1 to Item 15 in the left column, Item 16 to Item 30 in the right column. When there is over 30 items, a new page break will occur, with item 31 printed on the next page (in the left column) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi, I have one potential solution in mind. I will share it tomorrow. Can you please provide your real use case so I can better understand your needs and requirements? Every detail will help a lot. I am looking for the real-world example where such layout is needed, assuming that the document is dynamically generated. |
Beta Was this translation helpful? Give feedback.
-
It is for a packing slip. For instance, after packing items in a box, you
need to print a packing slip listing the serial number of items packed. The
serial numbers can be printed in barcode format. This will make it easy for
the shipper to scan and verify whether the items are included in a box.
Since there could be many items, we want to arrange the serial numbers in 2
columns per page (with each page listing 30 items). Hence if there are 31
to 60 items packed, the packing slip document will have 2 pages. If there
are 61 to 90 items, there will be 3 pages.
…On Mon, Aug 30, 2021 at 5:42 PM Marcin Ziąbek ***@***.***> wrote:
Hi, I have one potential solution in mind. I will share it tomorrow.
Can you please provide your real use case so I can better understand your
needs and requirements? Every detail will help a lot.
I am looking for the real-world example where such layout is needed,
assuming that the document is dynamically generated.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJWK5STVN3DSEKUHFK5SBI3T7QQO3ANCNFSM5DC4TFJQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
So, does it mean that the height of each element in the grid is well known? And adjusted in such a way that there are exactly 15 items in each column? |
Beta Was this translation helpful? Give feedback.
-
This code is far from being perfect but it is shows how described layout can be accomplished: var elements = Enumerable
.Range(1, 100)
.Select(x => $"Item {x}")
.ToList();
container
.Background(Colors.White)
.Padding(25)
.Stack(pageStack =>
{
while (elements.Any())
{
var pageElements = elements.Take(30).ToList();
elements = elements.Skip(30).ToList();
pageStack.Item().Row(row =>
{
row.RelativeColumn().Stack(stack =>
{
pageElements
.Take(15)
.ToList()
.ForEach(x => stack.Item().Border(1).Padding(10).Text(x));
});
row.RelativeColumn().Stack(stack =>
{
pageElements
.Skip(15)
.ToList()
.ForEach(x => stack.Item().Border(1).Padding(10).Text(x));
});
});
pageStack.Item().PageBreak();
}
}); |
Beta Was this translation helpful? Give feedback.
This code is far from being perfect but it is shows how described layout can be accomplished: