PDFsharp save to MemoryStream

前端 未结 5 660
星月不相逢
星月不相逢 2021-01-31 15:12

I want to save a PdfSharp.Pdf.PdfDocument by its Save method to a Stream, but it doesn\'t attach the PDF header settings to it. So when I read back the Stream and return it to t

5条回答
  •  再見小時候
    2021-01-31 15:57

    I found simpler solution:

    byte[] fileContents = null; 
    using(MemoryStream stream = new MemoryStream()) 
    { 
        pdfDoc.Save(stream, true); 
        fileContents = stream.ToArray(); 
    }
    

    Source: http://usefulaspandcsharp.wordpress.com/2010/03/09/save-a-pdf-to-a-byte-array-using-pdf-sharpmigradoc/

提交回复
热议问题