So right now I am trying to edit a table so that the top row of the table is
purple and the next 6 rows are white. My question's are:
-Is there a way to make it just one table? Right now I have 2 tables, one
directly on top of the other. Can I make just one row is purple and not the
others without making 2 different tables?
-Also I am looking for a autosize function for cell width. I cannot seem to
find one though. Is there something I am missing there?
Code that I have so far is below
/* create a table
* TableTop and tableModeTop refer to the top purple row of the table
* tableBody and tableModeBody refer to the white body of the table
* creating a table is (y_col, x_row) form starting at 0
*/
//create a table (y_col, x_row) with word wrap
//TableTop is the purple first row of the table
PdfTable TableTop = PdfTable(NUM_OF_COLUMN, SINGLE_ROW);
PdfSimpleTableModel tableModeTop(NUM_OF_COLUMN, SINGLE_ROW);
//TableBody is the white rows of the table with the data
PdfTable TableBody = PdfTable(NUM_OF_COLUMN, NUM_OF_ROW);
PdfSimpleTableModel tableModeBody(NUM_OF_COLUMN, NUM_OF_ROW);
//enable word wrap and center text in the cells for top row
tableModeTop.SetWordWrapEnabled(PODOFO_TRUE);
tableModeTop.SetAlignment(PoDoFo::ePdfAlignment_Center);
tableModeTop.SetAlignment(PoDoFo::ePdfVerticalAlignment_Center);
//enable word wrap and center text in the cells of the body
tableModeBody.SetWordWrapEnabled(PODOFO_TRUE);
tableModeBody.SetAlignment(PoDoFo::ePdfAlignment_Center);
tableModeBody.SetAlignment(PoDoFo::ePdfVerticalAlignment_Center);
//set the font of the table to be default pFont
tableModeTop.SetFont(pFont);
tableModeBody.SetFont(pFont);
/* use to change colour in RGB
* You could set a different color than black to draw
* default is black or 0, 0, 0
* range of numbers is 0 to 1
*/
PdfColor white = PdfColor(1.0, 1.0, 1.0);
PdfColor purple = PdfColor(0.5, 0.0, 0.5);
PdfColor black = PdfColor(0.0, 0.0, 0.0);
//first row, purple cell hardcoded names for information
tableModeTop.SetText(0, 0, "short");
tableModeTop.SetText(1, 0, "");
tableModeTop.SetText(2, 0, "");
tableModeTop.SetText(3, 0, "LONG NAME LONG NAME");
tableModeTop.SetText(4, 0, "");
tableModeTop.SetText(5, 0, "");
tableModeTop.SetText(6, 0, "");
tableModeTop.SetText(7, 0, "");
tableModeTop.SetText(8, 0, "m");
tableModeTop.SetText(9, 0, "");
tableModeTop.SetText(10, 0, "");
tableModeTop.SetText(11, 0, "");
tableModeTop.SetText(12, 0, "");
tableModeTop.SetText(13, 0, "");
tableModeTop.SetText(14, 0, "Name");
//set first row of the table color to purple
tableModeTop.SetBackgroundEnabled(PODOFO_TRUE);
tableModeTop.SetBackgroundColor(purple);
//give color of text purple cells will have white text
//body text color is black
tableModeTop.SetForegroundColor(white);
tableModeBody.SetForegroundColor(black);
//attach TableTop to tableModeTop.
//attaches the information of tableModeTop toP TableTop
TableTop.SetModel(&tableModeTop);
TableBody.SetModel(&tableModeBody);
//size of each block, width should be the same as TableBody
TableTop.SetColumnWidth(WIDTH_CELL);
TableTop.SetRowHeight(HEIGHT_CELL);
//size of each cell, width should be the same as TableTop
TableBody.SetColumnWidth(WIDTH_CELL);
TableBody.SetRowHeight(HEIGHT_CELL);
//Offset goes 10 pixels into the boarder to fit table
double const horizontalOffset = BOARDER_SIZE - 10;
//vertical offset of table
double const verticalOffset = pPage->GetPageSize().GetHeight() -
TABLE_VERT_OFFEST - BOARDER_SIZE;
//draw table slightly below title
//value found by finding the hight of the table, minus vertical offset
and baorder size
//Draw(x coordinate, y coordinate, painter)
//slightly to the left (-10) fix later
TableTop.Draw(horizontalOffset, verticalOffset, painter);
//draw body of table directly underneath the TableTop row table
//slightly to the left (-10) fix later
TableBody.Draw(horizontalOffset, verticalOffset - HEIGHT_CELL, painter);
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users