Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Dynamic row add |
Post Reply ![]() |
Author | |
pdfinfo411 ![]() Beginner ![]() Joined: 14 May 11 Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() Posted: 14 May 11 at 10:23PM |
Hi, I used the code on the below lines to draw the table rows.
The issue is there will be data overruns. so i use the api AppendTableRows(). This also does not seem to help prevent data overruns. Please advise. QuickPDFAX0724.PDFLibraryClass qp base.Library(); { int fontID = qp.AddTrueTypeFont("Arial", 1); qp.SetTextSize(8); qp.SelectFont(fontID); qp.SetHTMLNormalFont("Default", fontID); qp.SetPageSize("Letter"); qp.SetOrigin(0); } DataTable dtAllData = getTable(); //with 200 rows of data. int ipages = qp.NewPages(20); int totalPages = qp.PageCount(); int FirstRow = 1; int FirstColumn = 1; int LastRow = dtAllData.Rows.Count; int LastColumn = dtAllData.Columns.Count; int tableID = qp.CreateTable(LastRow, LastColumn); qp.SetTableBorderColor(tableID, 0, 1, 1, 1); qp.SetTableBorderWidth(tableID, 0, 0.1); qp.SetTableCellTextSize(tableID, FirstRow, FirstColumn, LastRow, LastColumn, 8); qp.SetTableCellBorderWidth(tableID, FirstRow, FirstColumn, LastRow, LastColumn, 0, 0); qp.SetTableRowHeight(tableID, FirstRow, LastRow, 0); QReport.RPTParam rptParam = new QReport.RPTParam(); for (int idx = 1; idx <= LastColumn; ++idx) { DataColumn dcc = dtAllData.Columns[idx - 1]; if (dcc != null) { Int32 iwidth = rptParam.GetColumnWidth(dcc); qp.SetTableColumnWidth(tableID, idx, idx, iwidth); } else { LogMessage("Create(DataTable dtAllData, List<DataRow> lrow): using DefaultReportColumnWidth:" + QReport.RPTParam.DefaultReportColumnWidth.ToString()); qp.SetTableColumnWidth(tableID, idx, idx, QReport.RPTParam.DefaultReportColumnWidth); } } qp.SetTableCellBackgroundColor(tableID, FirstRow, FirstColumn, FirstRow, LastColumn, 0.4, 0.4, 0.4); qp.SetTableCellTextColor(tableID, FirstRow, FirstColumn, 1, LastColumn, 1, 1, 1); qp.SetTableCellAlignment(tableID, FirstRow, FirstColumn, 1, LastColumn, 4); for (int idx = 1; idx <= LastColumn; ++idx) { DataColumn dcc = dtAllData.Columns[idx - 1]; Int32 iAllignID = rptParam.GetDataAlignment(dcc); qp.SetTableCellAlignment(tableID, 2, idx, LastRow, idx, iAllignID); } Func<DataRow, DataColumn, String> CDataType = delegate(DataRow drow, DataColumn dc) { { if (drow[dc].ToString().Trim().Length > 0) { if (dc.DataType == System.Type.GetType("System.DateTime")) { return Convert.ToDateTime(drow[dc]).ToShortDateString(); } else { return Convert.ToString(drow[dc]).Trim(); } } } return String.Empty; }; for (int idxr = 1; idxr <= LastRow; ++idxr) { if (idxr == 1) //column header { for (int idx = 1; idx <= dtAllData.Columns.Count; ++idx) //foreach (DataColumn column in thisTable.Columns) { DataColumn dcc = dtAllData.Columns[idx - 1]; qp.SetTableCellContent(tableID, 1, idx, dcc.ColumnName); } } else { //DataRow drow = lrow[idxr - 1]; DataRow drow = dtAllData.Rows[idxr - 1]; int trow = qp.AppendTableRows(tableID, idxr); LogMessage("QuickPDFRptTEST.PDFTest(): trow: " + trow.ToString()); if (trow == 0) { throw new NotImplementedException("Rows could not be added"); } for (int idx = 1; idx <= dtAllData.Columns.Count; ++idx) { DataColumn dcol = dtAllData.Columns[idx - 1]; String rdata = CDataType(drow, dcol); qp.SetTableCellContent(tableID, idxr, idx, rdata); } } } double totalheightofalltherows = qp.DrawTableRows(tableID, PDF_LEFT, PDF_TOP, PDF_HEIGHT, 1, 0); qp.SaveToFile(outputfile); |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3530 |
![]() ![]() ![]() ![]() ![]() |
Hi pdfinfo411!
What do you mean with data overrun? The text per row was cut or what? If this is the case you have to calculate by your own before using a string. What font height (pixel)? How many characters? ... to determine before how long a row should be for the string? Cheers and welcome here, Ingo BTW: I've deleted the other thread 'cause it's the same content ;-) |
|
![]() |
|
pdfinfo411 ![]() Beginner ![]() Joined: 14 May 11 Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
Hi, Overrun i mean as below.
lets say I have a structure of 200 rows of data. I like to display lets say 40 rows of data in page 1 - now content of each row is one line. also if the content of data increases to 8 lines per row, it display only first 20 rows and the remaining 21-40 will not be show. it will be cut off. Does not automatically display in next page. I tried using appendtablerows, but did not help. Is there a solution to this issue ? Thanks |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3530 |
![]() ![]() ![]() ![]() ![]() |
So you have to set up the initial page to be large enough
for 40 rows. Your pagesize "letter" together with fontsize 8 can't work! "Letter" doesn't mean the page of a letter but the envelope! Perhaps 50 rows with fontsize 8 and pagesize "A4" could be a success... Try a bigger pagesize and it will work. Cheers, Ingo |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store