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 764397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:43:09+00:00 2026-05-14T16:43:09+00:00

I was wondering what would be the best approach for creating tables in a

  • 0

I was wondering what would be the best approach for creating tables in a pdf that have rounded corners using the iTextSharp 5.x+ library.

  • 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-14T16:43:09+00:00Added an answer on May 14, 2026 at 4:43 pm

    If you have iTextSharp source code, add the following to PdfContentByte class:

    /// <summary>
            /// Enumuration for defining corners you want rounded.
            /// </summary>
            [Flags()]
            public enum Corners {None = 0,All=15,Top=3,Bottom=12, TopLeft = 1, TopRight=2, BottomLeft=4, BottomRight=8};
    
            /// <summary>
            /// Adds a round rectangle to the current path, with rounded conrners as specified by roundCorners.
            /// </summary>
            /// <param name="x"></param>
            /// <param name="y"></param>
            /// <param name="w"></param>
            /// <param name="h"></param>
            /// <param name="r"></param>
            /// <param name="roundCorners"></param>
            public void RoundRectangle(float x, float y, float w, float h, float r,Corners roundCorners)
            {
                if (w < 0)
                {
                    x += w;
                    w = -w;
                }
                if (h < 0)
                {
                    y += h;
                    h = -h;
                }
                if (r < 0)
                    r = -r;
                float b = 0.4477f;
                if((roundCorners & Corners.BottomLeft) == Corners.BottomLeft)
                    MoveTo(x + r, y);
                else
                    MoveTo(x, y);
    
                if ((roundCorners & Corners.BottomRight) == Corners.BottomRight)
                {
                    LineTo(x + w - r, y);
                    CurveTo(x + w - r * b, y, x + w, y + r * b, x + w, y + r);
                }
                else
                    LineTo(x + w, y);
    
                if ((roundCorners & Corners.TopRight ) == Corners.TopRight)
                {
                    LineTo(x + w, y + h - r);
                    CurveTo(x + w, y + h - r * b, x + w - r * b, y + h, x + w - r, y + h);
                }
                else
                    LineTo(x + w, y + h);
    
                if ((roundCorners & Corners.TopLeft)  == Corners.TopLeft)
                {
                    LineTo(x + r, y + h);
                    CurveTo(x + r * b, y + h, x, y + h - r * b, x, y + h - r);
                }
                else
                    LineTo(x , y + h);
    
                if ((roundCorners & Corners.BottomLeft) == Corners.BottomLeft)
                {
                    LineTo(x, y + r);
                    CurveTo(x, y + r * b, x + r * b, y, x + r, y);
                }else
                    LineTo(x, y);
            }        
    

    Next step is to implment IPdfPCellEvent interface:

    public class myCellEvent : IPdfPCellEvent
        {
            #region members
            PdfContentByte.Corners _roundedCorners;
            float _roundness;
            #endregion
    
            #region ctor
            public myCellEvent()
                :this( PdfContentByte.Corners.All,2f)
            {
    
            }
    
            public myCellEvent(PdfContentByte.Corners roundedCorners)
                : this(roundedCorners, 2f)
            {
    
            }
    
            public myCellEvent(PdfContentByte.Corners roundedCorners,float roundness)
            {
                _roundedCorners = roundedCorners;
                _roundness = roundness;
    
            } 
            #endregion
    
            #region IPdfPCellEvent Members
            public void CellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases)
            {
                PdfContentByte cb = canvases[PdfPTable.LINECANVAS];
                cb.RoundRectangle(position.Left, position.Bottom, position.Right - position.Left, position.Top - position.Bottom, this._roundness, this._roundedCorners);
                cb.SetColorStroke(new BaseColor(System.Drawing.Color.Black));
                cb.SetColorFill(new BaseColor(System.Drawing.Color.Beige));            
                cb.FillStroke();
                cb.Stroke();
            }
            #endregion
        }
    

    Then you round what ever corners you want to produce the rounded table of choice:

    PdfPTable table = new PdfPTable(1);
    
    
                    PdfPCell cell = new PdfPCell(new Phrase(10, atext, f2));
                    cell.Border = 0;
                    cell.Padding = 5f;
                    cell.CellEvent = new myCellEvent(PdfContentByte.Corners.Top,2f);
                    table.AddCell(cell);
    

    If you like the answer … give it a vote 🙂

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

Sidebar

Related Questions

Was just wondering what the best approach is when creating a multi-lingual website that
I am wondering what would be the best approach to store, for let's say
I'm wondering what would be best to do. Right now I have running a
Hey im just wondering what would be the best collection to use when creating
I'm wondering what would be the best approach to render vector objects (e.g. box,
I was wondering how one would best approach the task of deciding upon the
I was wondering what would be the best approach towards finding the index of
I was wondering what the best approach would be to the following problem. Say
I am wondering what the best approach would be to check whether or not
I am wondering what would be the best approach in a WPF (possibly MVVM)

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.