Search code examples
abcpdf

ABCpdf Table Help


First time poster so please bear with me. Basically I have a pdf document that I am creating on the fly using ABCpdf (via C# project) however the table rows seem to be rendering on top of each other. I have looked at all the documentation etc and searched for an answer but have not found anything relating to this.

I referred to the examples on creating tables which got me to the point I am at now but I cannot understand what is causing this issue. Below is an example of how I am constructing my table. Any help offered would be greatly appreciated. I have created a wrapper for ABCpdf to make it quicker and more code efficient to use but cannot see this causing the issue as it simply calls the same code as it would if I wrote it all out line by line.

        PdfTable pdfTable = new PdfTable(_abcPdfWrapper.PdfDocument, 5, 3)   {HorizontalAlignment = 1};

        pdfTable.NextRow();
        pdfTable.NextCell();
        pdfTable.AddText(firstStageReference);

        pdfTable.NextCell();
        pdfTable.AddText(String.Format("{0:#,0.000}", materialWeight) + " Kg");
        pdfTable.NextRow();
        pdfTable.AddText(weighDepartmentMaterial.sMaterialCode ?? String.Empty);

        pdfTable.NextCell();
        pdfTable.AddText(weighDepartmentMaterial.sMaterialName ?? String.Empty);

        pdfTable.NextCell();
        pdfTable.AddText(String.Format("{0:#,0.000}", materialWeight) + " Kg");

        pdfTable.NextCell();
        pdfTable.AddText(weighDepartmentMaterial.Scale ?? String.Empty);

        pdfTable.NextCell();
        pdfTable.AddText(weighDepartmentMaterial.AddGroup ?? String.Empty);

There is other code in between these lines but they bear no significance to the construction of the table other than a loop in which the lines from number 2 down are contained to loop through a series of raw materials and create a row for each.


Solution

  • I solved this issue in the end by simply adding these two functions into my wrapper class and then calling them before and after using the table object.

            public void PdfTableBegin()
        {
            PdfDocument.TopDown = false;
        }
    
    
        public void PdfTableEnd()
        {
            PdfDocument.TopDown = true;
        }