Question Sorting for post card

theozzfactor

New member
Joined
Nov 6, 2013
Messages
1
Programming Experience
10+
I am creating an application using a PDF as template to create post cards. The page has 9 post cards across sorted (see below).
1 2 3
4 5 6
7 8 9


Now, when everything is printed and we cut the page, the sorting gets messed up. That is, the first tray contains 1, 10, 19 etc..I am trying to code (sort) in such a way that the first page contains (for eg: lets consider total of 35 post cards)
1 5 9
13 17 21
25 29 33
and second page contains
2 6 10
14 18 22
26 30 34
and so on so that when the pages are cut, each stack is sorted. Hope I made myself clear.
Any help is appreciated.
Thanks
 
I might be missing something, but it looks to me like you're just adding '4' to the start (top left) number. Can you not take the current page number, use that in the top left, then cycle through numbering your cards accordingly? I'm guessing by your example that there's only going to be 4 pages of 9 postcards.
 
This sounds to me like a school exercise on looping, but I will give you some clues. This code just show the item numbers that is to be used on a single line so that it is easy to see the linearity of the stacks. Depending on how "printing" is to take place, you just need to add placement/breaks every 3 items each page.
        Dim items = Enumerable.Range(1, 35)
        Dim perpage = 9
        Dim stacksize = CInt(Math.Ceiling(items.Count / perpage)) 'example=4
        For s = 1 To stacksize 'page 1-4
            Dim pageitems = items.Skip(s - 1).Where(Function(item, index) index Mod stacksize = 0)
            Debug.WriteLine(String.Join(" ", pageitems.ToArray))
        Next

VB.NET:
1 5 9  13 17 21 25 29 33 
2 6 10 14 18 22 26 30 34 
3 7 11 15 19 23 27 31 35
4 8 12 16 20 24 28 32
The "For s" loop signifies each page, and is used to seed the start index for the Linq expression, which could also be expressed as a For loop with a Step counter like this:
For i = s To items.Count Step stacksize
 
Back
Top