unable to add text heading in provided example

Hi,

https://support.syncfusion.com/kb/article/8583/how-to-convert-csv-to-pdf-table-using-c-and-vb-net?isInternalRefresh=False


I am using above example code & that one is working fine.


I tried to add heading with in above code with following code but after creating pdf, heading not appearing.


https://help.syncfusion.com/document-processing/pdf/pdf-library/net/working-with-text?cs-save-lang=1&cs-lang=vb



Can some one help to sort out.


3 Replies

JT Jeyalakshmi Thangamarippandian Syncfusion Team August 14, 2024 11:02 AM UTC

Hi Roshan,

To draw text in a layout, we can use PdfTextElement to draw the text and determine the end positions using PdfLayoutResult and then draw the grid. We have created a sample that meets the requirements of adding a text heading to the PDF document before creating the table, and we have attached it for your reference. Please try it on your end and let us know if you require any further assistance.

Code snippet:

//Apply built-in style

pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable5DarkAccent6);

 

//Create a text element with the text and font

PdfTextElement textElement = new PdfTextElement("Heading", new PdfStandardFont(PdfFontFamily.TimesRoman, 12));

//Draws the element on the page with the specified page and location

PdfLayoutResult result = textElement.Draw(page, PointF.Empty);

//Draw the PdfGrid

pdfGrid.Draw(page, new PointF(0,result.Bounds.Bottom+10));

 

Sample:

https://www.syncfusion.com/downloads/support/directtrac/general/ze/CSVToPDF-11307241

Kindly use the following UG link for reference, 

Working with Text | Syncfusion


Regards,

Jeyalakshmi T



RO Roshan August 14, 2024 01:07 PM UTC

Thanks for replay & code.


Sorry but your provided code is in c#.


i am using vb.net & i am new , unable to convert your code C# to vb.


Please share vb.net code.


Thanks


Roshan




JT Jeyalakshmi Thangamarippandian Syncfusion Team August 15, 2024 12:15 PM UTC

Hi Roshan,

We have created a sample in VB.NET that meets our requirements, and we have attached it for your reference. Please try it on your end and let us know if you require any further assistance.

Code snippet:

'Create a text element with the text And font

Dim textElement As New PdfTextElement("Heading", New PdfStandardFont(PdfFontFamily.TimesRoman, 12))

' Draws the element on the page with the specified page and location

Dim result As PdfLayoutResult = textElement.Draw(page, PointF.Empty)

'Draw the PdfGrid

pdfGrid.Draw(page, New PointF(0, result.Bounds.Bottom + 10))

 

Sample:

https://www.syncfusion.com/downloads/support/directtrac/general/ze/CSVtoPDF_Sample-1853590553


Regards,

Jeyalakshmi T


Loader.
Up arrow icon