A pdf document is empty, because you did put nothing into it.
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
To be able to write something, you have to use
Add()
method. Below piece of code adds a table with custom font style:
BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, false);
Font bf = new Font(bfTimes, 11);
Font headerf = new Font(bfTimes, 9, Font.ITALIC | Font.BOLD, BaseColor.WHITE);
Font sf = new Font(bfTimes, 9, Font.NORMAL);
colcount = 3;
table = new PdfPTable(colcount);
widths = new float[] { 1f, 1f, 1f };
table.SetWidths(widths);
table.HorizontalAlignment = 0;
for(int c=1; c<=colcount;c++)
{
s = $"Header {c}";
PdfPCell header = new PdfPCell(new Phrase(s, headerf));
header.HorizontalAlignment = 1;
header.BackgroundColor = BaseColor.DARK_GRAY;
table.AddCell(header);
}
for(int r=1; r<=5; r++)
{
for(int c=1; c<=colcount;c++)
{
s = $"Col {c} Row {r}";
cell = new PdfPCell(new Phrase(s, sf));
cell.BackgroundColor = r % 2 == 0 ? BaseColor.WHITE : BaseColor.LIGHT_GRAY;
table.AddCell(cell);
}
}
pdfdoc.Add(table);