I use the following code to create a cover page.
public static byte[] CreatePageHeader(List<string> texts) { var stream = new MemoryStream(); Document doc = null; try { doc = new Document(); PdfWriter.GetInstance(doc, stream); doc.SetMargins(50, 50, 50, 50); doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width, iTextSharp.text.PageSize.LETTER.Height)); Font font = new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL); doc.Open(); Paragraph para = null; foreach (string text in texts) { para = new Paragraph(text, font); doc.Add(para); } } catch (Exception ex) { throw ex; } finally { doc.Close(); } return stream.ToArray(); }
this works fine, but it shows the text at the top of the page. But I want it to be in the middle of the page.
How do I change this code?
source share