dynamic text

dynamic text

Forum member · May 30, 2012
Hi, We work with visual studio 2010 and dynamic pdf 6. I must to realize this : A simple table with one header. An other row with some dynamic text (user can insert one line or thousand of line) I must to detect if the row with dynamic text can contains on this page : if yes > i insert the row => pretty simple :) if no > i must to cut the text and insert a party on the page and other party on other page. The problem is this table have footer below !!! exemple : some text ----- table -------- my header -------------------- my text dynamic this text can take thousand of character -------------------- footer text Any idea, sample and so on ? Thanks Christophe beginner with dynamic pdf :)

Re: dynamic text

Support · May 30, 2012
Hello Christophe, Yes, you can achieve your requirements without any problem using our DynamicPDF Generator for .NET product. You will need to set the Splittable property of the Cell2 class to true and this will automatically overflows the remaining contents of the cell. Also please make sure that you are setting the correct height for the Table2 page element to add footer. Below is the sample code for overflowing the cell contents and adding footer to the table using another Table2 page element. float yPosition; Document document = new Document(); Table2 table = new Table2(0, 0, 600, 400); table.Columns.Add(150); table.Columns.Add(90); table.RepeatColumnHeaderCount = 1; string text = "This is to test the overflow of the cell contents to next page dynamically"; text += text; text += text; text += text; text += text; text += text; Row2 row1 = table.Rows.Add(30); row1.CellDefault.Align = TextAlign.Left; row1.CellDefault.VAlign = VAlign.Top; row1.Cells.Add("Header 1"); row1.Cells.Add("Header 2"); for (int i = 0; i < 1; i++) { Row2 row3 = table.Rows.Add(30); Cell2 cell2 = row3.Cells.Add(text); cell2.Align = TextAlign.Left; cell2.VAlign = VAlign.Top; cell2.Splittable = true; Cell2 cell3 = row3.Cells.Add("text" + (i + 1)); cell3.Splittable = true; } //Adding table to page. do { Page page = new Page(); table.Height = page.Dimensions.Body.Height-30;//value 30 is the height of the footer table. float width = table.Width; float height = table.Height; document.Pages.Add(page); page.Elements.Add(table); //Build Table to add footer. Table2 footerTable = new Table2(0, 0, 600, 30); footerTable.Columns.Add(150); footerTable.Columns.Add(90); Row2 footerRow = footerTable.Rows.Add(30); footerRow.CellDefault.Align = TextAlign.Left; footerRow.CellDefault.VAlign = VAlign.Top; footerRow.Cells.Add("Footer 1"); footerRow.Cells.Add("Footer 2"); footerTable.Width = width; footerTable.X = table.X; if (height > table.GetRequiredHeight()) { yPosition = (float)(table.Y + table.GetRequiredHeight()); } else { yPosition = (float)(table.Y + table.Height-3); } footerTable.Y = yPosition; page.Elements.Add(footerTable); //page.Elements.Add(new LayoutGrid()); table = table.GetOverflowRows(); } while (table != null); document.Draw(@"C:\Table.pdf"); Thanks, ceTe Software Support Team.

Re: dynamic text

Forum member · May 30, 2012
Hi, Thanks for your time and your sample. Just a little problem too :) I've try to develop a little your sample for to realise my futur developement.. but that's doesn't work .. look at that, i take your sample add a C# for => for to add several table in my document. I want to do that : add table and space and again add table if we have enough space we add table below the first table if not enough space add page The problem is all the time the table is locate to the new page ! any idea ? thanks a lot [C#] Document document = new Document(); float tableY = 0; for (int x = 1; x <= 10; x++) { float yPosition; Table2 table = new Table2(0, tableY, 600, 0); table.Columns.Add(150); table.Columns.Add(90); table.RepeatColumnHeaderCount = 1; // int val = 0; string text = "This is to test the overflow of the cell contents to next page dynamically"; for (int i = 0; i < x; i++) { text += text; // val = i; } text += "(" + val + ")"; Row2 row1 = table.Rows.Add(30); row1.CellDefault.Align = ceTe.DynamicPDF.TextAlign.Left; row1.CellDefault.VAlign = VAlign.Top; row1.Cells.Add("Header 1"); row1.Cells.Add("Header 2"); for (int i = 0; i < 1; i++) { Row2 row3 = table.Rows.Add(30); Cell2 cell2 = row3.Cells.Add(text.ToString()); cell2.Align = ceTe.DynamicPDF.TextAlign.Left; cell2.VAlign = VAlign.Top; cell2.Splittable = true; Cell2 cell3 = row3.Cells.Add("text" + (i + 1)); cell3.Splittable = true; } //Adding table to page. do { ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page(); table.Height = page.Dimensions.Body.Height - 30; //value 30 is the height of the footer table. float width = table.Width; float height = table.Height; document.Pages.Add(page); page.Elements.Add(table); #region footer //Build Table to add footer. Table2 footerTable = new Table2(0, 0, 600, 30); footerTable.Columns.Add(150); footerTable.Columns.Add(90); Row2 footerRow = footerTable.Rows.Add(30); footerRow.CellDefault.Align = ceTe.DynamicPDF.TextAlign.Left; footerRow.CellDefault.VAlign = VAlign.Top; footerRow.Cells.Add("Footer 1"); footerRow.Cells.Add("Footer 2"); footerTable.Width = width; footerTable.X = table.X; #endregion //if (height > table.GetRequiredHeight()) //{ // yPosition = (float)(table.Y + table.GetRequiredHeight()); //} //else //{ // yPosition = (float)(table.Y + table.Height - 3); //} yPosition = (float)(table.Y + table.Height - 3); footerTable.Y = yPosition; page.Elements.Add(footerTable); //page.Elements.Add(new LayoutGrid()); table = table.GetOverflowRows(); } while (table != null); } document.DrawToWeb(true, "Report.pdf", false); have a nice day Christophe

Re: dynamic text

Support · May 30, 2012
Hello Christophe, The sample code which we have posted earlier is to add the overflow cell contents of a sinlge table to the next page. Can you please send over the following details to our support team at: [^a|mailto:support@cete.com|opennewiwndow|support@cete.com^] so that they can look into it further? 1. More details about your requirements and what you would like to achieve using our DynamicPDF product. 2. Output PDF document. Thanks, ceTe Software Support Team.

Re: dynamic text

Support · May 31, 2012
Hello, Tables can be added one below the other and over flow the remaining contents of the cell to next page. Set the Splittable property of the Cell2 class to true for all the cells which being added to the row to make the cell contents to split and add to the next page. Also make sure to set the correct height for the Table so that it can fit in the page area. Thanks, ceTe Software Support Team.