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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Dynamic row add
  FAQ FAQ  Forum Search   Register Register  Login Login

Dynamic row add

 Post Reply Post Reply
Author
Message
pdfinfo411 View Drop Down
Beginner
Beginner


Joined: 14 May 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdfinfo411 Quote  Post ReplyReply Direct Link To This Post Topic: Dynamic row add
    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);
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 15 May 11 at 4:17PM
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 ;-)

Back to Top
pdfinfo411 View Drop Down
Beginner
Beginner


Joined: 14 May 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdfinfo411 Quote  Post ReplyReply Direct Link To This Post Posted: 15 May 11 at 10:51PM
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

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 15 May 11 at 11:01PM
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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store