I am trying to create a PDF using iText 7 in my Asp.Net application. Unfortunately whenever I try to open the PDF it tells me that the file is broken and can't be opened. I have no idea why because my code seems fine to me. This is what I have:
public ActionResult CreateLieferschein()
{
MemoryStream stream = new MemoryStream();
PdfWriter writer = new PdfWriter(stream);
var pdf = new PdfDocument(writer);
var document = new Document(pdf);
document.Add(new Paragraph("Hello World!"));
return File(stream, "application/pdf", "test.pdf");
}