I am trying to return a PDF with simple text, but getting the following error when downloading the document: Failed to load PDF document. Any ideas on how to resolve this is appreciated.
MemoryStream ms = new MemoryStream(); PdfWriter writer = new PdfWriter(ms); PdfDocument pdfDocument = new PdfDocument(writer); Document document = new Document(pdfDocument); document.Add(new Paragraph("Hello World")); //document.Close(); //writer.Close(); ms.Position = 0; string pdfName = $"IP-Report-{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.pdf"; return File(ms, "application/pdf", pdfName);