Dear all,
I'm new to syncfusion PDF and i'm trying to create some complex PdfTables. Within a sinlge PDF Table Cell, i want to have text with different formatting like bold, underline, another font and fontsize, etc.. I read a lot of documentation and found that I should use the BeginCellLayout event. However, a lot a things remain unclear to me. It is not clear how i can draw multiple strings after one another with also wordwrapping etc. In the image bellow you can see an example I've created in word to demonstrate my need.
Thanks in advance for your help.
Hi Tom,
We have created a sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PDF_SAmple_GridWithMultiFonts312796388
to add multiple fonts text in a PDF
table cell. Kindly try it on your end and let us know the result.
Regards,
Surya V
Hi Surya,
First of all I would like to thank you for taking time to take a look at my issue I've adressed. I had a look at the provided sample and output and it is not exactly what I'm looking for.
Let me clarrify: the provided sample indeed shows me a cell with multi-formatted text, which is great. However, each text with it's own font/format is printed on a seperate line. What I'm looking for is continous text with different formatting like in the example above. it is unclear to me how I can achive that.
Hi Tom,
Kindly try with the below code snippet to achieve your requirement of multiple text format in a single Grid cell,
//Create PDF document PdfDocument doc = new PdfDocument();
//Add pages PdfPage page = doc.Pages.Add();
//Create PdfGrid PdfGrid grid = new PdfGrid();
//Add PdfGridRow PdfGridRow row = grid.Rows.Add();
//Add 2 column grid.Columns.Add(2);
row.Cells[0].Value = "1"; row.Cells[1].Value = "2";
row = grid.Rows.Add();
string longText = "<font color='#FF0000'>Essential PDF</font> is a <U>.NET</U>" +
"<I> library with the capability to produce Adobe PDF files</I>";
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 14);
//Create PdfHtmlTextElement PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(longText, font, PdfBrushes.Black); row.Cells[0].Value = "Hello World"; row.Cells[1].Value = richTextElement;
// Draw PdfGrid grid.Draw(page.Graphics, new PointF(0, 0));
//Creating the stream object
MemoryStream stream = new MemoryStream();
//Save the PDF document to stream
doc.Save(stream); |
Refer to the following link to get more details on this, https://www.syncfusion.com/kb/5831/how-to-add-formatted-html-tag-in-pdfgridcell
Regards,
Surya V