Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1725
Understanding Document RelativeHeight & Width
posted

I'm hoping that someone can help me understand how the Document RelativeHeight/Width are intended to work.

What I'm trying to do is to create a Document section (or really a page within a section) that consists of a quadrant made up of 4
equally sized cells. Within each cell will be content that should fill that cell.

What I did in an attempt to accomplish the objective was to create a section made up of a table with 2 rows each row with 2 cells.

The code looks something like the following

Report report = new Report();
ISection section = report.AddSection();
//* Add a table to the section
ITable table = section.AddTable();
//* I don't want a header or footer on the table and want to table to fill the section so I did the following
//*    assuming that setting the height/width to 100% would fill the section within the page bounds
table.Header.Height = new Infragistics.Documents.Report.FixedHeight(0f);
table.Footer.Height = new Infragistics.Documents.Report.FixedHeight(0f);
table.Height = new Infragistics.Documents.Report.RelativeHeight(100);
table.Width = new Infragistics.Documents.Report.RelativeWidth(100);

//* Now create the rows/cells
ITableRow toprow = table.AddRow();
toprow.Height = new Infragistics.Documents.Report.RelativeHeight(50);

//* I assumed that setting the row height to 50 and cell width to 50 and height to 100 would create my
//*   quadrant of equally sized cells
ITableCell upperLeftCell = toprow.AddCell();
ITableCell upperRightCell = toprow.AddCell();
upperLeftCell.Width = new Infragistics.Documents.Report.RelativeWidth(50);
upperLeftCell.Height = new Infragistics.Documents.Report.RelativeHeight(100);
upperRightCell.Width = new Infragistics.Documents.Report.RelativeWidth(50);
upperRightCell.Height = new Infragistics.Documents.Report.RelativeHeight(100);

ITableRow bottomRow = table.AddRow();
ITableCell lowerLeftCell = toprow.AddCell();
ITableCell lowerRightCell = toprow.AddCell();
lowerLeftCell.Width = new Infragistics.Documents.Report.RelativeWidth(50);
lowerLeftCell.Height = new Infragistics.Documents.Report.RelativeHeight(100);
lowerRightCell.Width = new Infragistics.Documents.Report.RelativeWidth(50);
lowerRightCell.Height = new Infragistics.Documents.Report.RelativeHeight(100);

//* I then call "fill" methods on each of the cells just created
fillUpperLeft(upperLeftCell);
fillUpperRight(upperRightCell);
fillLowerLeft(lowerLeftCell);
fillLowerRight(lowerRightCell);

Stopping here for a second. Is this the proper way to accomplish my objective? If not, do I need to somehow get the page size (within the page
boundaries) in points and then create the table as fixedheight/width somehow?

Now, each of the fill methods does something like the following, again assuming that the Relative height/width values relate to the cell size.

private fillUpperLeftCell( ITableCell baseCell )
{
   ITable table = baseCell.AddTable();
   table.Height = new Infragistics.Documents.Report.RelativeHeight(100);
   table.Width = new Infragistics.Documents.Report.RelativeWidth(100);

   //* What I want is for the header to be 40% of the cell/table height, the footer to be 10% and the middle 50% to contain other content
   Infragistics.Documents.Report.Table.ITableHeader header = table.Header;
   header.Height = new Infragistics.Documents.Report.RelativeHeight(40);   
   header.Repeat = true;
   //* Add a cell to the header with an image.
   ITableCell cell = header.AddCell();
   cell.Width = new Infragistics.Documents.Report.RelativeWidth(100);

   IImage image = AddImage(new Infragistics.Documents.Graphics.Image( myHeaderImage ));
   image.KeepRatio = true;
   cell.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Middle;
   cell.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Center;

   //* Add the footer with an image
   Infragistics.Documents.Report.Table.ITableFooter footer = table.Footer;
   footer.Height = new Infragistics.Documents.Report.RelativeHeight(10);
   cell = footer.AddCell();
   cell.Width = new Infragistics.Documents.Report.RelativeWidth(100);
   image = AddImage(new Infragistics.Documents.Graphics.Image( myFooterImage ));
   image.KeepRatio = true;
   cell.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Middle;
   cell.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Center;   

   //* Now, add some content to the middle (the one table row that I add)
   //* Add 2 cells with the first being 30% of the width and the second being 70%
   ITableRow row = table.AddRow();
   cell = row.AddCell();
   cell.Width = new Infragistics.Documents.Report.RelativeWidth(30);
   cell.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Right;
   IText txt = cell.AddText();
   txt.AddContent("Text in cell1");

   
   cell = row.AddCell();
   cell.Width = new Infragistics.Documents.Report.RelativeWidth(70);
   cell.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Left;
   IText txt = cell.AddText();
   txt.AddContent("Text in the second cell");
}


So, what I expected here was that there would be an image centered in a header that was 40% of the cell height, an image centered in the footer
taking 10% of the cell height and the rest filled by a row with text.

What I end up with is something that does not look anything like what I expected.

Can someone set me straight? What am I missing here?

Thanks
Neil