Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, December 25, 2013 12:05 AM
Need to change the columnwidth around a bit.
Total width is 700f
In Visual Studio I can only pick "AbsoluteWidths", but what is the proper syntax?
var table = new PdfPTable(columns.Count) {
TotalWidth = 700f,
AbsoluteWidths = ("45", 45f, 78f, 30f, 45f, 78f, 78f, 151f, 150f), ???
LockedWidth = true
};
All replies (4)
Wednesday, December 25, 2013 12:30 AM ✅Answered
- Please refer:
- how to set width for PdfPCell in ItextSharp
- How to set the cell width in itextsharp pdf creation
- C# iTextSharp AutoAdjust column widths
Wednesday, December 25, 2013 12:42 AM ✅Answered
Check out below example:
//Create a OrderNo table
PdfPTable firstTable = new PdfPTable(4);
//set overall width
firstTable.WidthPercentage = 90f;
//set column widths
int[] firstTablecellwidth ={ 25, 25, 18, 32 };
firstTable.SetWidths(firstTablecellwidth);
Wednesday, December 25, 2013 12:37 AM
Does not work either.
float[] widths = new float[] {45, 45, 78, 30, 45, 78, 78, 151, 150},
SetWidths (widths),
Wednesday, December 25, 2013 11:42 AM
This is what I ended up with that works"
float[] widths = new float[] {45, 45, 78, 30, 45, 78, 78, 151, 150};
var doc = new Document();
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.SetPageSize(PageSize.LETTER.Rotate());
var arial = FontFactory.GetFont("Arial", 8, Color.BLACK);
var arialBold = FontFactory.GetFont("Arial", 10, Font.BOLD, Color.BLACK);
doc.Open();
var table = new PdfPTable(columns.Count) {
TotalWidth = 700f,
LockedWidth = true
};
table.SetWidths(widths);
Thanks all for pointing me in the right direction.