Vikas Rao

Vikas Rao

  • NA
  • 69
  • 3.4k

How can i Add Font size in pdf.

Jan 9 2020 5:18 AM
public ActionResult DownloadProductCartProposalPDF()
{
try
{
var cartProposalText = System.IO.File.ReadAllText("E:/Skype/ProposalContractInvoice_old.html");
Byte[] bytes;
StringReader sr = new StringReader(cartProposalText.ToString());
//Document pdfDoc = new Document(PageSize.A4.Rotate(), 0, 0, 15, 5);
Document pdfDoc = new Document();
pdfDoc.SetPageSize(iTextSharp.text.PageSize.LEGAL_LANDSCAPE.Rotate());
pdfDoc.SetMargins(5, 5, 20, 10);
Font NormalFont = FontFactory.GetFont("Arial", 8, Font.NORMAL);
pdfDoc.Add(NormalFont);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
using (MemoryStream memoryStream = new MemoryStream())
{
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
bytes = memoryStream.ToArray();
memoryStream.Close();
}
return File(bytes, "application/pdf", "ProductContract.pdf");
}
catch (Exception ex)
{
return Redirect("/Content/inPersonConferences");
}
}

Answers (5)