Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sat May 01, 2021 3:36 am

Hi
I write bellow code to show text in a line
Code: Select all
textAndStyle.Text = " \n"+ "Contact Name : " + shippingdetails.Con_Contactname + ", Contact No : " + shippingdetails.Con_Contactno;

How can I make variable texts bold ?

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Mon May 03, 2021 5:23 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
Please refer to the following code to meet your needs. If you have any other questions, please feel free to contact us.
Code: Select all
            textAndStyle.Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 8f, FontStyle.Bold), true);



Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon May 03, 2021 5:40 am

Thanks for reply,

But your code make bold full line,how can I make bold only shippingdetails.Con_Contactname

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Mon May 03, 2021 7:34 am

Hello,

Thanks for your feedback.
Please refer to the modified code as shown below. If you have any other questions, please feel free to contact us.
Code: Select all
            PdfGridCellContent textAndStyle = new PdfGridCellContent();
            textAndStyle.Text = textAndStyle.Text = " \n" + "Contact Name : ";
            textAndStyle.Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 8f, FontStyle.Regular), true);
            textAndStyle.Brush = PdfBrushes.Black;
            textAndStyle.StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle);

            PdfGridCellContent textAndStyle2 = new PdfGridCellContent();
            textAndStyle2.Text = shippingdetails.Con_Contactname;
            textAndStyle2.Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 8f, FontStyle.Bold), true);
            textAndStyle2.Brush = PdfBrushes.Black;
            textAndStyle2.StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle2);

            PdfGridCellContent textAndStyle3 = new PdfGridCellContent();
            textAndStyle3.Text = ", Contact No : " + shippingdetails.Con_Contactno;
            textAndStyle3.Font = new PdfTrueTypeFont(new System.Drawing.Font("Arial", 8f, FontStyle.Regular), true);
            textAndStyle3.Brush = PdfBrushes.Black;
            textAndStyle3.StringFormat = new PdfStringFormat { Alignment = PdfTextAlignment.Left };
            lst.List.Add(textAndStyle3);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Sat May 08, 2021 7:26 am

Hello,

Greetings from E-iceblue!
Did the code we provided work for you? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Sun May 09, 2021 3:39 pm

Hello
Sorry for delayed reply,Due to some other work not able to check the code yet .I will let you know after check.
Thanks

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Mon May 10, 2021 1:13 am

Thanks for your response.
I am looking forward to your test result. If you encounter any questions during your test, just feel free to contact us.

Sincerely
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF