Link to home
Start Free TrialLog in
Avatar of solution1368
solution1368

asked on

asp.net, itextshape format

I have the following code working fine to create table with itextsharp,
my question is i will have more tables like table1, table2 for something.
How can i make default format for all of the table?
like I want all of the table has totalwidth = 540f?

Thanks


PdfPTable table = new PdfPTable(2); //Table with 2 columns
            //========================================================
            //table format
            table.TotalWidth = 540f;
            table.LockedWidth = true;
            var titleFont = FontFactory.GetFont("Arial", 18, Font.BOLD);
            var subTitleFont = FontFactory.GetFont("Arial", 14, Font.BOLD);
            var boldTableFont = FontFactory.GetFont("Arial", 12, Font.BOLD);
            var endingMessageFont = FontFactory.GetFont("Arial", 10, Font.ITALIC);
            var bodyFont = FontFactory.GetFont("Arial",8, Font.NORMAL);
            table.HorizontalAlignment = 0;
            table.SpacingBefore = 10;
            table.SpacingAfter = 10;
            table.DefaultCell.Border = 1;
            //table.SetWidths(new int[] { 1, 4 });
            //========================================================
ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of solution1368
solution1368

ASKER

so if we have 100 tables(PdfPTable table = new PdfPTable(2)) to be created.

do we have any options to set master settings like

            table.SpacingBefore = 10;
            table.SpacingAfter = 10;
            table.DefaultCell.Border = 1;

If yes, how to do that? Thanks