0

I have a function that creates a PDF with iTextSharp,

It will get each date in the datagridview, with the associated data that is connected to it, and put it in a PDF.

However, you cannot see that the dates are supposed to be headers, so my question is;

How can I make the dates bold or change the font size to a bit higher size, so you will see them as headers.

My code if it isn´t clear enough for you;

//I am using a stringbuilder, this is the place where I declare it
StringBuilder pdfData = new Stringbuilder();

//Here I go through each datetime, from point a (datetimePicker 1), to point b(datetimePicker 2)
for (DateTime dt = dtDateVanaf.Value; dt <= dtDateTot.Value; dt = dt.AddDays(1))
{
    //This is supposed to be a header text, I want this part to be bold or a larger font size
    pdfData.Append(dt.ToString("dddd dd MMM yyyy"));
    pdfData.Append("\n\n");

    //This is the part that I check the datagridview for the associated data foreach date time
    foreach (DataGridViewRow row in dataGridView1.Rows)
    {
        //And so on...
    }
}
Jongware
  • 21,058
  • 8
  • 43
  • 86
  • Helpful link http://stackoverflow.com/questions/8002687/how-to-make-a-part-of-stringbuilder-content-bold – Sybren Dec 01 '14 at 09:14
  • Does this mean iTextSharp does not come with any manual or any kind of documentation at all? – Jongware Dec 01 '14 at 13:20

1 Answers1

2

Text isn't just "bold" or "italic", you are actually seeing a different, although related, font when you are seeing these things (although faux bold and faux italic does technically exist).

So when you want to bold something, you need switch to a bold font. If you are controlling your fonts explicitly then you can do that manually which will give you the most control. If you aren't specifying actual fonts and are leaving it up to system defaults then you can generate very simple HTML and let the system take care of things for you.

Community
  • 1
  • 1
Chris Haas
  • 47,821
  • 10
  • 127
  • 248