- Code: Select all
// Get reference to cell that will hold company information.
PdfGridCell infoCell = companyRow.Cells[1];
// Set font style.
infoCell.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f), true);
// Set spacing between the lines of text.
infoCell.Style.StringFormat = new PdfStringFormat
{
LineSpacing = infoCell.Style.Font.Size * 2f
};
// Create collection that will hold all cell assets.
PdfGridCellTextAndStyleList infoCellTextAndStyleList = new PdfGridCellTextAndStyleList();
// Break company information text to multiple lines.
string[] infoTextLines = company.Information.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string infoTextLine in infoTextLines)
{
// Create one asset.
PdfGridCellTextAndStyle infoCellTextAndStyle = new PdfGridCellTextAndStyle
{
Font = new PdfTrueTypeFont(new Font("Arial", 10f), true),
Text = $"\n{infoTextLine}"
};
// Add asset to collection.
infoCellTextAndStyleList.List.Add(infoCellTextAndStyle);
}
// Assign asset collection to cell.
infoCell.Value = infoCellTextAndStyleList;
This is the code snippet we are using to draw multiline text in a single cell.
We have set LineSpacing property on PdfStringFormat, however text lines continue to be without spacing.
Are we missing something?