C1FlexReport RenderToStream

Posted by: abeavis on 27 September 2017, 9:11 pm EST

    • Post Options:
    • Link

    Posted 27 September 2017, 9:11 pm EST

    Hi,

    I’m trying to migrate an application from using C1Report to C1FlexReport. One feature of C1Report frequently used by the application is the rendering of the report output as a Pdf to a memory stream (subsequently consumed through a service call to a mail server).

    The C1FlexReport samples I’ve viewed to achieve a similar result render the file to disk with an export filter (RenderToFilter()). The application generates hundreds of reports in payment/statement runs and this would be inefficient resulting in high disk IO.

    Redacted function code

    [vb]Friend Function CreatePdfAttachment(attachmentName As String, report As C1Report) As MemoryStreamAttachment

    Dim reportStream As MemoryStream = New MemoryStream()

    report.RenderToStream(reportStream, FileFormatEnum.PDFEmbedFonts)

    Return New MemoryStreamAttachment(reportStream, MediaTypeNames.Application.Pdf, attachmentName)

    End Function[/vb]

    Is it possible to achieve the same outcome with C1FlexReport without writing the output to disk?

    Regards.

  • Posted 27 September 2017, 9:11 pm EST

    Hi,

    for achieving the same, you need to specify the Stream property in PdfFilter without any file name as:

    [vb]

    'Render the C1FlexReport as stream

    Dim ms As New MemoryStream()

    Dim pdf As New PdfFilter()

    pdf.Stream = ms

    c1FlexReport1.RenderToFilter(pdf)

    ms.Position = 0

    ’ if you want to save in disk

    Dim fs As New FileStream(“flex.pdf”, FileMode.Create)

    ms.WriteTo(fs)

    fs.Close()

    [/vb]

    Hope, it will work for you.

    Thanks,

    Sonu

  • Posted 27 September 2017, 9:11 pm EST

    Hi Sonu,

    I have refactored the code as you suggested and can confirm that this solution works.

    Thanks for your assistance.

    Kind Regards,

    Andrew

  • Posted 20 February 2019, 5:07 pm EST

    Unfortunately this doesnt work for a htmlfilter?

    What do I have to do that this example works with a htmlfilter?

    Thank you.

  • Posted 20 February 2025, 5:34 am EST

    am trying to convert C1Componenet to c1flexcompoennet reportCtl.RenderToStream(pdfStream, C1.C1Report.FileFormatEnum.PDFEmbedFonts);

    pdfStreams.Add(new MemoryStream(pdfStream.ToArray()));

    this code i need to convert for Flexcompoenent

    please help me.

  • Posted 21 February 2025, 6:46 am EST

    Hi,

    The following documentation link shows you how to render your c1flexreport via different export Filters: https://developer.mescius.com/componentone/docs/reporting/online-flexreport/winexportreport.html

    @Andreas, you can find the following section helpful to you: https://developer.mescius.com/componentone/docs/reporting/online-flexreport/winexportreport.html#i-heading-render-flexreport-using-htmlfilter-class

    @kavana, you can use EmbedFonts property of the PdfFilter class as referred in the link: https://developer.mescius.com/componentone/docs/reporting/online-flexreport/winexportreport.html#:~:text=Description-,EmbedFonts,-Used%20to%20embed

    Hope this helps you!

    Thanks & regards,

    Aastha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels