-1

i am working with itext shapf for some pdf stuff. i have added a table like this:-

     PdfPTable tabler1Top = new PdfPTable(1);
                        tabler1Top.TotalWidth = 450f;
                        tabler1Top.LockedWidth = true;
                        //int[] intTblWidth1 = { 20, 50, 20, 40 };
                        //tabler1Top.SetWidths(intTblWidth1);
                        tabler1Top.SpacingBefore = 20f;
                        tabler1Top.HorizontalAlignment = Element.ALIGN_LEFT;
                        PdfPCell Order_Nbr = new PdfPCell(new Phrase("Order Nbr: " + _orderNumber + "                            Order Status:" + _order_Status + "                       Order Taker: " + _orderTakenBy, bodyFont));
                        //Order_Nbr.Border = Rectangle.NO_BORDER;
                        Order_Nbr.HorizontalAlignment = 0;
tabler1Top.AddCell(Order_Nbr);
                        PdfPCell Order_date = new PdfPCell(new Phrase("Orderedr: " + _orderDate + "            " + _orderTime + "                    Received: " + _recivedDate + "     " + _recivedTime + "      ***Paper Work Required***", bodyFont));
                        tabler1Top.AddCell(Order_date );
                        doc.Add(tabler1Top);

and its showing the output like:-

Orderedr: 09-Jan-14 12:00 AM Received: 09-Jan-14 1:22 AM ***Paper Work Required***

now i want to bold the headings like Orderedr: it should be bold Received: like this

i have seen an example here

i have tried like this :-

PdfPCell Order_Nbr = new PdfPCell(new Phrase("<b>Order Nbr: </b>" + _orderNumber + "                            Order Status:" + _order_Status + "                       Order Taker: " + _orderTakenBy));

but its showing the output like :-

<b>Order Nbr: </b>14MA09A8936 Order Status:AD
Order Taker: sbornstein

this example belongs to paragraph but i am working with cell here like PdfPCell Order_date = new PdfPCell(new Phrase("Orderedr: " + etc. i have a string in new new Phrase("Orderedr: " so is there any way to bold the heading. any suggestion will be appreciated, i will mark you answer if it work for me. thanks in advance happy coding :)

Community
  • 1
  • 1
R K Sharma
  • 845
  • 8
  • 23
  • 42
  • why -1, is my question is not clear to you, i can explain more tell me which point i have to explore more? – R K Sharma Jan 12 '14 at 09:11
  • 1
    See this for using chunks inside of phrases to use different fonts: http://stackoverflow.com/a/10213836/231316 – Chris Haas Jan 13 '14 at 15:41

2 Answers2

3

First you need to make two Phrase one normal and one bold.

Phrase p1 = new Phrase("Actividad Económica: ", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.NORMAL, new Color(0, 0, 0)));
Phrase p2 = new Phrase(" Actividad ", FontFactory.GetFont(FontFactory.HELVETICA, 11, Font.BOLD, new Color(0, 0, 0)));

then you have to make a Paragraph and add the phrases

Paragraph paraDec = new Paragraph();
paraDec.Add(p1);
paraDec.Add(p2);

and then you just have to add the paragraph to the cell

PdfPCell cPrueba = new PdfPCell(paraDec);
Giorgos Betsos
  • 71,379
  • 9
  • 63
  • 98
2

May be this hint of code will help you.

PdfPCell cell = PhraseCell(new Phrase("Orderedr", FontFactory.GetFont("Arial", 15, Font.UNDERLINE, BaseColor.BLACK)));
Shreyas Achar
  • 1,407
  • 5
  • 36
  • 63