Dear ceTe,
I truly believe you got the product right. I was looking at the demo for version 4 for some time now. I really enjoy extensibility and degree of control the Generator provides.
However, there is something that I would like to ask you. We have tree-based data structures that our code works with,
Node1(Type A)
leaf
leaf
Node1.1(Type A)
leaf
leaf
leaf
leaf
Node1.1.1(Type B)
leaf
leaf
Node1.1.2(Type A)
leaf
leaf
Node1.2(Type A)
leaf
and so on. There are really no restrictions on number of leaves, node depth, etc.
Text derived from nodes and leaves' properties needs to end up in a ceTe PDF report.
There is an additional requirement that every Node of type A, regardless of depth needs to start a new page. Having a started a new page, the node outputs its leaves, Type B nodes and their leaves and this output may span multiple pages. So for a structure as above the output would be:
Page 1
Node1
leaf
leaf
Page 2
Node1.1
leaf
leaf
leaf
Page 3 (continues for Node 1.1)
leaf
Node1.1.1
leaf
leaf
Page 4
Node1.1.2
leaf
leaf
Page 5
Node1.2
leaf
I was not able to produce a working general recursion-based solution for this using ceTe version 4. I do have an table-based iterative solution for a special limited case of the tree, but even this solution is extremely hairy calculating text height, passing around Y coordinates and running ugly conditionals against them. It is unmaintainable and we cannot put it in production.
Dear ceTe, is there the right way to do this possibly using enhancements in version 5? Several lines of pseudocode will work,
Appreciate your help,
Y.
Clean design for hierarchial structures output
Re: Clean design for hierarchial structures output
Support · Jun 20, 2008Hello,
You can do this by using the OrderedList
or UnOrderedList
page elements.
You will have to create a list item and add the items (nodes) to the list. If you find a node of type A then stop adding the items to the list and add the list to the page.
You will have to create another list from the node type A and add it to a new page. You may have to take care of these breaks using your logic, so that you can continue adding the remains nodes without any problem.
You can take the overflow list (list which does not fit in the given dimensions) by using the GetOverflowList method and add it to a new page. You can do this in a loop until you have the overflow.
You can also get the height required for the list by using the GetRequiredHeight method of the list object.
Thanks,
ceTe Software Support Team.
Re: Clean design for hierarchial structures output
Forum member · Jun 20, 2008Thanks a lot for pointing out these classes and filling this gap in my ceTe knowledge.
I will give it a try today-tomorrow and post here.
Re: Clean design for hierarchial structures output
Forum member · Jun 23, 2008Dear ceTe,
the class work very well. I am using UnorderedList (node type A) and UnorderedSublist (type B) to draw the data structure. Every type A node adds a new page to the document while type B adds a sublist of its leaves to the list.
I also write a header before every type A node that is made out of a label and a line. Everything works naturally well because every node A makes a new page and header with line are always added to the same position on the top. Overflows take care of leafs and node B sublists. Then the next node A starts the process all over again by added header and a line.
Let me ask you this, however. There are rare cases when type A=new page does not hold true (to decrease paper output volume). The header label and line need to be added immediately following type A node end of output. It appears that in this case tracking of Y throughout the recursive pass comes back as I would need to:
1. Calculate/return where the node of type A finished its output
2. Check if header label and line will fit
3. If fits, calculate how much space remains for the
UnorderedList, add list from calculated Y to available Y-span (height), overflow to new pages as necessary (changing height to full page). Start from 1.
4. If does not fit, add new page, add list, overflow, start from 1.
Is there a way to overflow mixed elements "together"? Am I understand correctly that in cases of mixed elements Y-tracking is inevitable?
Re: Clean design for hierarchial structures output
Support · Jun 24, 2008Hello,
You can get the height required by the List by using the GetRequiredHeight() method of the list object. You can use this method to get the height of the list in the loop where you are taking care of the overflow.
The variable you are using to hold the height required will have the height required for the list which is added in the last overflow (last page). You can add some padding to this height and add new elements to the same page by using this height as the Y coordinate.
You will have to compare the height avaialable on the page and height of the element you are adding so that you can add the elements to the next page if it does not fit the same page. You can also use a variable to represent the height available, you will have to decrease it every time when you add an element. If you are adding lists, tables, textareas etc you can get the height required.
It is not possible to overflow mixed elements. However you can add any element in the new page when ever you have an overflow.
Thanks,
ceTe Software Support Team.
Re: Clean design for hierarchial structures output
Forum member · Jun 24, 2008Understood, thanks!
I would like to ask, is the functionality for a generic page element container that will overflow regardless of element types contained planned? It appears that the general algorithm you described can be implemented by creating a page elment ordered aggregation class with its own GetOverflowElements() that knows its height (and by knowing the height of member elements knows what to return for GetOverflowElements() automatically excluding member fitting in its height).
Is this a good way to go or there is something I am missing?
THanks!
Re: Clean design for hierarchial structures output
Support · Jun 24, 2008Hello,
Currently we do not have plans to implement a generic overflow mechanism for all page elements. The page overflow will work for elements that take textual data like TextArea, FormattedTextArea, Lists, and Tables.
Thanks,
ceTe Software Support Team
Re: Clean design for hierarchial structures output
Forum member · May 19, 2009Dear ceTe,
continuing this discussion, is there a way to set the indentation increment for sublist adding (without tracking and manually incrementing indents in recursion)? I am running into situations when the default indentation increment pushes deeper branches a bit too far to the right into the area that I need for list item details.
Re: Clean design for hierarchial structures output
Support · May 20, 2009Hello,
Yes, you can add the sublist items at required positions. You have to use BulletAreaWidth for the UnorderedList items . This will place the SubList items bullets at specified positions. Then you can use the LeftIndent property of the SubList object. This will make the SubList items to be placed at required positions. The LeftIndent will set the indent of the text from the starting position of the list object and not from the bullet. Below is the sample code for it.
UnorderedList list = new UnorderedList(50, 120, 300, 500, Font.Helvetica, 12, UnorderedListStyle.Disc);
ListItem item1 = list.Items.Add(".NET products");
item1.BulletAreaWidth = 10;
// Add UnorderedSubList under ListItem item1.
UnorderedSubList subList1 = item1.SubLists.AddUnorderedSubList(UnorderedListStyle.Square);
subList1.LeftIndent = 7;
ListItem item4 = subList1.Items.Add("LeftIndent");
Thanks,
ceTe Software Support Team
Re: Clean design for hierarchial structures output
Forum member · Sep 17, 2009Taking this further, is there a way to get a placed ListItem's X and Y to target with an XYDestination?
Thanks!
Re: Clean design for hierarchial structures output
Support · Sep 17, 2009Hello,
Currently it is not possible to get the X, Y position of a list item from the list. We may add this feature of getting X, Y position of a list item but currently we do not have any immediate plans on this.
Thanks,
ceTe Software Support Team.
Re: Clean design for hierarchial structures output
Forum member · Sep 17, 2009Thanks for your quick reply,
certainly that would be very useful should you consider it for future releases.