Hi, since I cannot set different padding settings for a PDFGrid, I tried to embed a PDFGrid into every cell of a parent PDFGrid to have various padding. This method works somehow but for long text the splitting of text seem broken. Here is the codes I used:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Grid;
using Syncfusion.Pdf.Graphics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
_createPDF("C:\\test.pdf");
}
private static void _createPDF(string filename)
{
var pdf = new PdfDocument();
var page = pdf.Pages.Add();
var table = new PdfGrid();
table.AllowRowBreakAcrossPages = true;
table.Style.CellPadding = new PdfPaddings(20f, 20f, 10f, 10f);
table.Columns.Add(2);
for (var i = 1; i <= 20; ++i)
{
var sb = new StringBuilder();
for (var j = 1; j <= i*10; ++j)
{
sb.Append("Line #");
sb.Append(j);
sb.Append("\n");
}
_addTestContent(table, sb.ToString());
}
table.Draw(page, new PointF(0f, 0f));
using (var f = new FileStream(filename, FileMode.Create))
{
pdf.Save(f);
}
}
private static PdfGrid _createTable(string value)
{
var table = new PdfGrid();
table.AllowRowBreakAcrossPages = true;
table.Style.CellPadding = new PdfPaddings(10f, 10f, 5f, 5f);
table.Style.CellSpacing = 0f;
table.Columns.Add();
var row = table.Rows.Add();
row.Cells[0].Value = value;
row.Cells[0].Style.Borders.All = PdfPens.Transparent;
return table;
}
private static PdfGridRow _addTestContent(PdfGrid table, string value)
{
var row = table.Rows.Add();
row.Cells[0].Value = table.Rows.Count().ToString();
row.Cells[1].Value = _createTable(value);
return row;
}
}
}