Can I generate a PDF file in c # without needing a database?

1

I am about to carry out a project which has a report form, my client asks me to export it as PDF with the simple fact of clicking on the save button, I want to know if it is possible to do it without needing a database .

    
asked by Saul 01.02.2018 в 02:44
source

1 answer

0

If I personally use a very simple API called ItextSharp that if you use VS2013 or higher you can download it free from nuget and if you want here I give you a small example of how to use it:

   Document document = new Document(PageSize.A4, 25, 25, 30, 30);
   PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("NombreDeTuArchivo.pdf", FileMode.Create, FileAccess.Write, FileShare.None));
   document.Open();
   document.Add(new Paragraph("Hello World"));
   document.Close();
   writer.Close();
   Response.ContentType = "pdf/application";
   Response.AddHeader("content-disposition", 
   "attachment;filename=First PDF document.pdf");
   Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
    
answered by 01.02.2018 в 21:55