Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5935887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:19:10+00:00 2026-05-22T15:19:10+00:00

I’m trying to create a pdf report using iTextSharp and I’m stumped as to

  • 0

I’m trying to create a pdf report using iTextSharp and I’m stumped as to why it’s not correctly going to the next row to add the cells.

Here’s the code:

    public class Centralizador
    {
        public void PrintCentralizador(int gradeParaleloId, string gradeName, string paraleloName, string courseName)
        {
            var studentRepo = new StudentRepository();
            var students = studentRepo.FindAllStudentsFromGradeParalelo(gradeParaleloId).OrderBy(s => s.LastNameFather);
            int rowHeight = 13;
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\Centralizador.pdf";

            try
            {
                Document document = new Document(PageSize.LETTER);
                //Landscape the document.
                document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
                BaseFont baseFont = BaseFont.CreateFont(BaseFont.COURIER, BaseFont.CP1250, BaseFont.EMBEDDED);
                Font font = new Font(baseFont, 8);

                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePath, FileMode.Create));
                document.Open();

                GradeParaleloRepository paraRep = new GradeParaleloRepository();
                var gra = paraRep.FindGradeParalelo(gradeParaleloId);
                Paragraph p = new Paragraph(new Phrase("Centralizador - Gestion " + DateTime.Now.Year + " \n " + courseName + " " + gra.Grade.Name + " " + gra.Name + "\n Colegio Madre Vicenta Uboldi \n " + DateTime.Now, font));
                document.Add(p);

                PdfPTable table = new PdfPTable(36); //36 Column table.
                table.TotalWidth = 800f;
                table.LockedWidth = true;
                float[] widths = new float[] { 0.13f, 1.4f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f, 0.13f };
                table.SetWidths(widths);

                PdfPCell blankCell = new PdfPCell(new Phrase("", font));
                blankCell.FixedHeight = 25;

                PdfPCell blankCellB = new PdfPCell(new Phrase("", font));
                blankCellB.FixedHeight = 25;

                table.AddCell(blankCell);
                table.AddCell(blankCellB);

                PdfPCell mat = new PdfPCell(new Phrase("MAT", font));
                mat.Colspan = 3;
                mat.HorizontalAlignment = 1;
                table.AddCell(mat);

                PdfPCell len = new PdfPCell(new Phrase("LEN", font));
                len.HorizontalAlignment = 1;
                len.Colspan = 3;
                table.AddCell(len);

                PdfPCell psi = new PdfPCell(new Phrase("PSI", font));
                psi.Colspan = 3;
                psi.HorizontalAlignment = 1;
                table.AddCell(psi);

                PdfPCell cna = new PdfPCell(new Phrase("CNA", font));
                cna.Colspan = 3;
                cna.HorizontalAlignment = 1;
                table.AddCell(cna);

                PdfPCell soc = new PdfPCell(new Phrase("SOC", font));
                soc.Colspan = 3;
                soc.HorizontalAlignment = 1;
                table.AddCell(soc);

                PdfPCell ing = new PdfPCell(new Phrase("ING", font));
                ing.Colspan = 3;
                ing.HorizontalAlignment = 1;
                table.AddCell(ing);

                PdfPCell efi = new PdfPCell(new Phrase("EFI", font));
                efi.Colspan = 3;
                efi.HorizontalAlignment = 1;
                table.AddCell(efi);

                PdfPCell mus = new PdfPCell(new Phrase("MUS", font));
                mus.Colspan = 3;
                mus.HorizontalAlignment = 1;
                table.AddCell(mus);

                PdfPCell apl = new PdfPCell(new Phrase("APL", font));
                apl.Colspan = 3;
                apl.HorizontalAlignment = 1;
                table.AddCell(apl);

                PdfPCell rel = new PdfPCell(new Phrase("REL", font));
                rel.Colspan = 3;
                rel.HorizontalAlignment = 1;
                table.AddCell(rel);

                PdfPCell com = new PdfPCell(new Phrase("COM", font));
                com.Colspan = 3;
                com.HorizontalAlignment = 1;
                table.AddCell(com);

                PdfPCell blankCellC = new PdfPCell(new Phrase("", font));
                blankCellC.FixedHeight = 25;
                table.AddCell(blankCellC);

                //This is supposed tobe on a new row. But isn't. It seems
                //everything below this comment doesn't even get added.
                PdfPCell numero = new PdfPCell(new Phrase("No.", font));
                numero.FixedHeight = rowHeight;
                numero.HorizontalAlignment = 0;
                table.AddCell(numero);                

                PdfPCell nombres = new PdfPCell(new Phrase("Apellidos y Nombres", font));
                nombres.FixedHeight = rowHeight;
                nombres.HorizontalAlignment = 0;
                table.AddCell(nombres);

                for (int i = 0; i < 2; i++)
                {
                    PdfPCell pa = new PdfPCell(new Phrase("PA.", font));
                    table.AddCell(pa);

                    PdfPCell re = new PdfPCell(new Phrase("RE.", font));
                    table.AddCell(re);

                    PdfPCell nf = new PdfPCell(new Phrase("NF.", font));
                    table.AddCell(nf);
                }

                PdfPCell obs = new PdfPCell(new Phrase("OBS.", font));

                table.SpacingBefore = 20f;
                table.SpacingAfter = 20f;

                document.Add(table);
                document.Close();
            }
            catch (DocumentException de)
            {
                Debug.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Debug.WriteLine(ioe.Message);
            }
        }
    }

Here’s a picture of how it ends up: So it add the last column com correctly, also adds the blank padding cell, then it doesn’t add what comes next. It just doesn’t display. Any suggestions?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:19:10+00:00Added an answer on May 22, 2026 at 3:19 pm

    You need to add exact number of columns for each row to have it shown.

    See my answer for your other question PdfTable isn't added to my document

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.