SWAMY YT

SWAMY YT

  • 1.1k
  • 643
  • 30.4k

Generate a PDF programatically

Oct 21 2018 8:10 AM
Hai, 
i have a requirement like generate a  PDF programatically, and i tried with the code the problem is the code is excecutedcurrectly but the pdf is not getting generated.  here is my code
 
public void GeneratePrint()
{
try {
var document = new Document(PageSize.A4, 50, 50, 25, 25);
var output = new FileStream(Server.MapPath("MyFirstPDF.pdf"), FileMode.Create);
var writer = PdfWriter.GetInstance(document, output);
document.Open();
var welcomeParagraph = new Paragraph("Hello, World!");
document.Add(welcomeParagraph);
document.Close();
}
catch (Exception Ex) {
Console.Write("While Printing Caught an Error");
}
}
 

Answers (2)