private static void SetPreferredWidthSettings(string dataDir)
{
// ExStart:SetPreferredWidthSettings
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a table row made up of three cells which have different preferred widths.
Table table = builder.StartTable();
// Insert an absolute sized cell.
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightYellow;
builder.Writeln("Cell at 40 points width");
// Insert a relative (percent) sized cell.
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
builder.Writeln("Cell at 20% width");
// Insert a auto sized cell.
builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.Auto;
builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGreen;
builder.Writeln("Cell automatically sized. The size of this cell is calculated from the table preferred width.");
builder.Writeln("In this case the cell will fill up the rest of the available space.");
dataDir = dataDir + "Table.CellPreferredWidths_out.doc";
// Save the document to disk.
doc.Save(dataDir);
// ExEnd:SetPreferredWidthSettings
Console.WriteLine("\nDifferent preferred width settings set successfully.\nFile saved at " + dataDir);
}
/// <summary>