Unicode characters in PdfLightTable when using a PdfLightTableBuiltinStyle
I am creating a PDF document in a WinForms app that has to support Polish. I am using a PdfLightTable with a PdfLightTableBuiltInStyle. I don't seem to be able to change the font to a TrueType font in order to print Polish. Is it possible to override the style in a PdfLightTableBuiltInStyle?
This is how I am setting the font:
private void PdfLightTable_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)
{
pdfLightTable.Style.DefaultStyle.Font = new PdfTrueTypeFont(new Font("Arial", 10, FontStyle.Regular), true);
}
Thanks.
SIGN IN To post a reply.
2 Replies
1 reply marked as answer
SL
Sowmiya Loganathan
Syncfusion Team
August 28, 2020 12:50 PM UTC
Hi Joe,
Thank you for contacting Syncfusion support.
We have analyzed your requirement. While setting the font to PdfLightTable default style, it does not override the style ofPdfLightTableBuiltInStyle. So please use the default style to set the font in PdfLightTable and refer the below code snippet for your reference,
|
//Create a new PDF document
PdfDocument doc = new PdfDocument();
//Add a page
PdfPage page = doc.Pages.Add();
//Create a PdfLightTable
PdfLightTable pdfLightTable = new PdfLightTable();
//Create a DataTable
DataTable dataTable = new DataTable();
//Add columns to the DataTable
dataTable.Columns.Add("ID");
dataTable.Columns.Add("Name");
//Add rows to the DataTable
dataTable.Rows.Add(new object[] { "E01", "Clay" });
dataTable.Rows.Add(new object[] { "E02", "Thomas" });
dataTable.Rows.Add(new object[] { "E03", "George" });
dataTable.Rows.Add(new object[] { "E04", "Stefan" });
dataTable.Rows.Add(new object[] { "E05", "Witaj świecie"});
//Assign data source
pdfLightTable.DataSource = dataTable;
//Declare and define the header style.
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 14, FontStyle.Regular), true);
PdfCellStyle headerStyle = new PdfCellStyle(font, PdfBrushes.White, PdfPens.Orange);
headerStyle.BackgroundBrush = PdfBrushes.Orange;
pdfLightTable.Style.HeaderStyle = headerStyle;
//Default style
font = new PdfTrueTypeFont(new Font("Arial", 10, FontStyle.Regular), true);
PdfCellStyle defaultStyle = new PdfCellStyle(font, PdfBrushes.Black, PdfPens.Orange);
defaultStyle.BackgroundBrush = PdfBrushes.White;
pdfLightTable.Style.DefaultStyle = defaultStyle;
//Show header in the table
pdfLightTable.Style.ShowHeader = true;
//Draw grid to the page of PDF document.
pdfLightTable.Draw(page, new PointF(10, 10)); |
Output document:
UG documentation: https://help.syncfusion.com/file-formats/pdf/working-with-tables#cell-customization-in-pdflighttable
Please try the above solution in your end and let us know the result.
Regards,
Sowmiya Loganathan
Marked as answer
JC
Joe Crowley
August 29, 2020 03:56 AM UTC
That works. I had to set both the pdfLightTable.Style.HeaderStyle and pdfLightTable.Style.DefaultStyle.
Thanks.
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
- Marked answer
-
JC Joe Crowley
- Aug 27, 2020 05:49 AM UTC
- Aug 29, 2020 03:56 AM UTC