PDFsharp save to MemoryStream

前端 未结 5 665
星月不相逢
星月不相逢 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:54

    For MigraDoc (ver 1.30) I could save it with

    PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
    renderer.Document = report.m_Document;
    
    renderer.RenderDocument();
    
    
    using (MemoryStream stream = new MemoryStream())
    {
        renderer.PdfDocument.Save(stream, false);
        ... your code in here
    
    }
    

提交回复
热议问题