Getting table height dynamically in iText - dynamic

Is there a way of getting the height of a table before adding it to the document?
At first glance, I supposed that the number of rows in the table is enough to calculate height since I know the font size. However, some rows break that rule. For instance, one cell might store a paragraph that has more than one line. Hence, what I need to know is the total of the heights of every row.

Yeah, answer was not complicated.
In order to get the height of a table, one must set the width of the table first. In other words,
table.setTotalWidth((PageSize.A4.getWidth() - document.leftMargin()
- document.rightMargin()) * table.getWidthPercentage() / 100);
System.out.println(table.calculateHeights());
does give the height of the table.

If you want to get table's height dynamically you can do so only after you have added all the content to it. In order to make this work you have to set its fixed width property and locked width property first.
e.g.
table.setTotalWidth(555f);
table.setLockedWidth(true);
after this you can get table's height by using its table.getTotalHeight() method

Related

DataGridViewAutoFilterTextBox displaying small number of items

Using this article (https://learn.microsoft.com/en-us/previous-versions/dotnet/articles/aa480727(v=msdn.10)#initialization) and the library included in the demo project I have setup Excel-like autofiltering on a datagridview.
However on columns where there are not many distinct values, only one or two rows are displayed:
In this example, there are actually 3 or 4 values in the filter list that the user could select but only two rows are displayed and the rest you must scroll to find.
I've been unable to find where the height of the list box is set. Any can anyone point out where I can change/set this?
I believe that this may be what you are looking for.
In the documentation is the following paragraph:
The SetDropDownListBoxBounds Method
The SetDropDownListBoxBounds method initializes the size and location of the drop-down list.
The preferred size depends primarily on the dropDownListBox contents, which are the formatted values stored in the Keys collection of the filters dictionary. The SetDropDownListBoxBounds method first calls the Graphics.MeasureString method for each filter value. For each value, the width is stored if it is wider than all previous values, and the height is added to an accumulating total height for all values. The results are then used to determine the preferred size.
The preferred height is the smallest of the following values:
The accumulated height of all filter values.
The user-specified maximum height as calculated from the
DropDownListBoxMaxLines property value.
The available height of the DataGridView control client area.

Datatables FixedHeader sets columns to equal widths after scrolling is done

I initialize my HTML table using the columns option, so that I can set the widths for each indiviual column. Initially, fixedHeader preserves the specified columns widths, once I start scrolling. After I scroll all the way back up, to the point that 'fixedHeaders' are deactivated (no more sticky headers), the column widths are not preserved - but they are all set to equal widths.
Anybody have an idea on how can I force the column widths to be preserved?
You should set autoWidth option to false,as described here:autowidth . Then the related topics of :columns.adjust(). will be helpful too.

Custom UICollectionViewLayout With Equal Inter-Item Spacing

I'm having a difficult time figuring out how to designing what feels like it should be a fairly straightforward layout for my collection view. The heights of each cell are equal. The widths vary. The inter-item spacing should always be equal. The distance between rows should also always be equal. As more items are added, the width of the collection view will increase "intelligently." Let me give an example.
When I insert a new item, I will calculate the movement of items from rows (maybe the first item of row 1 moves up to row 0, maybe the first item of row 2 moves up to row 1. I then move it and the collection view grows wider.
I feel like this should be reasonably straightforward but I'm struggling.
Does anyone have some sample code that could help?
Have you tried this using UICollectionViewFlowLayout?
http://skeuo.com/uicollectionview-custom-layout-tutorial
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionViewFlowLayout_class/

How to make rows invisible while printing reports?

I am using an .rldc file to define the layout of the reports from my program. The problem is, it is to be used for incremental printing. That means the paper will be used over and over as newer rows need to be printed. I'm attempting to approach it this way:
List all corresponding data on the report view.
Make the older rows invisible and only show the latest row.
Print.
That way, the last row is already properly placed. The problem is, I don't know how to implement this. Can anyone help me out?
You could create an IIF(condition,true,false) statement in your report definition on the row visibility variable.
The best way i guess is to define in your data source something of a rank column.
example :
select col1,col2,col3,RANK() OVER (ORDER BY col3 DESC) AS 'rank' from table1
Then in your table or matrix, you click on the row or/and column that you want to make the borders and text white based on a expression.
Go to the properties and dropdown on bordercolor
choose expression and type in (based on my example query)
=IIf(rank.value <> max(rank.value),White,Black)
That will not remove the rows only make the borders white ( unvisible)
The same you can do with Font Color property.
I think this is your best shot at this issue.
Other solution I could think of is to just hide unneccesary rows (which also replaces the visible row)
Then to move the table down by using a expression with a formula like nr of rows hidden before the actual row * height of 1 row, only I m not sure if this is applicable without programming an RDL extension..
Good Luck !

Getting position of pdfptable

in my document I am creating 3-4 pdfptables.
At design time I don't know the size of the tables. I need to place the 2nd table right after the first, but I dont know the position of the first (I can't calculate it because I dont know how big it is). How do I know where to place the second table?
You can figure out the total height of the table dynamically. After you use the WriteSelectedRows() function, you can call the .TotalHeight() property to find out how tall your table was (in points). Then figure out with some calculations where it ends and where the next one should begin.
That's right the table height and width is dynamically calculated, but you don't have to call WriteSelectedRows() function. You have to set either height or width.
In my case I had to first calculate that if font used can fill the page if not I had to dynamically change the font appropriately. So I find (by mistake) if you set TotalWidth the TotalHeight is automatically set/calculated.
Sanjay