Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. Document document = new Document();
  2. MemoryStream stream = new MemoryStream();
  3. try
  4. {
  5. PdfWriter pdfWriter = PdfWriter.GetInstance(document, stream);
  6. pdfWriter.CloseStream = false;
  7.  
  8. document.Open();
  9. document.Add(new Paragraph("Hello World"));
  10. }
  11. catch (DocumentException de)
  12. {
  13. Console.Error.WriteLine(de.Message);
  14. }
  15. catch (IOException ioe)
  16. {
  17. Console.Error.WriteLine(ioe.Message);
  18. }
  19. document.Close();
  20. stream.Flush();
  21. stream.Position = 0;
  22. return File(stream, "application/pdf", "DownloadName.pdf");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement