PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
MigraDoc to MemoryStream https://forum.pdfsharp.net/viewtopic.php?f=2&t=2443 |
Page 1 of 1 |
Author: | maria.bonet [ Mon May 13, 2013 4:04 pm ] |
Post subject: | MigraDoc to MemoryStream |
Hello, I'm new in this theme. I have created a MigraDoc.Document to print a list of movements for my WebSite in a PDF file, implemented with MVC C#. And I would like to return a "new FileStreamResult(new MemoryStream(), "application/pdf");" So, I would like to know how can i convert a MigraDoc.Document to a MemoryStream. I tried to do like some examples that I found on internet. But, when I save the document in my computer and I try to open it, it have some errors and then the irregulars characters appears with a strange format and the image of the header don't appears. Which is the best way to do? Think, that I don't want to save the document in the server because this could be a problem with security. So, I must to try to convert in a MemoryStream to send to the browser like a file download. Can anyone help me? Thanks in advance Maria |
Author: | Thomas Hoevel [ Mon May 13, 2013 4:47 pm ] |
Post subject: | Re: MigraDoc to MemoryStream |
Hi! Simply render the document to PDF and specify the MemoryStream instead of a file name when calling Save (add "false" to keep the MemoryStream open). See also: http://www.pdfsharp.net/wiki/Clock-sample.ashx You may have to reset the MemoryStream to position 0 if you use the stream (and not the byte[] as shown in the example). |
Author: | maria.bonet [ Tue May 14, 2013 7:22 am ] |
Post subject: | Re: MigraDoc to MemoryStream |
Thanks for the answer, I used a MigraDoc.Document not a PDFDocument because I do the same example as Invoice http://www.pdfsharp.net/wiki/Invoice-sample.ashx If I cannot do the render with document, how can I do this? Is any way to implement a migradoc into a pdfdocument? thanks in advance Maria |
Author: | Thomas Hoevel [ Tue May 14, 2013 8:03 am ] |
Post subject: | Re: MigraDoc to MemoryStream |
The MigraDoc PdfRenderer offers the same Save methods (it uses a PdfDocument inside and the Save commands are routed through). |
Author: | maria.bonet [ Tue May 14, 2013 10:36 am ] |
Post subject: | Re: MigraDoc to MemoryStream |
Ok!! Thanks for the answer, I will try what you said. best regards Maria |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |