Export a embedded rdlx report whitout show it

Posted by: josemiguel.alcalde on 13 November 2020, 1:45 am EST

  • Posted 13 November 2020, 1:45 am EST

    Hello

    I'm loading a embedded report in a form, and it works fine, when it's shown in a form, but now, I also need to export it from a background proccess, whitout showing the form.

    I have tried to export from the viewer, but if I don't show the form, the pdf is empty. If I show it, the pdf is fine. How can I do this?

    Thank in advance

    This is how I load de the report

        Public Sub LoadReport(reporte As String, ensamblado As String, parametro As String(,))
    Dim asm As Assembly
    asm = Assembly.LoadFrom(ensamblado)
    Dim stream As Stream = asm.GetManifestResourceStream(reporte)

    UcVisualizadorReportes1.LoadDocument(stream, GrapeCity.Viewer.Common.DocumentFormat.Rdlx)

    Dim parametros As GrapeCity.Viewer.Common.IParameter

    Dim pc As IList(Of GrapeCity.Viewer.Common.IParameter) = New List(Of GrapeCity.Viewer.Common.IParameter)()
    For i As Integer = 0 To parametro.GetLength(0) - 1
    Dim param As GrapeCity.ActiveReports.Viewer.Win.ReportParameter = New GrapeCity.ActiveReports.Viewer.Win.ReportParameter(parametro(i, 0), parametro(i, 1))
    pc.Insert(i, param)
    Next i

    UcVisualizadorReportes1.SetParametersValues(pc)

    End Sub


    And this is how I export the report to pdf when the form is shown

    Dim p As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport
    p.NeverEmbedFonts = ""
    p.ImageQuality = GrapeCity.ActiveReports.Export.Pdf.Section.ImageQuality.Highest
    Me.Export(p, New FileInfo(dialogSave.FileName))
    MessageBox.Show(dialogSave.FileName + " " + My.Resources.ExportCompleteString)
  • Replied 16 November 2020, 7:39 pm EST

    Hello,

    Can you try with the following code:
    Dim rptPath As New IO.FileInfo("..\..\PageReport1.rdlx")
    Dim pageReport As New GrapeCity.ActiveReports.PageReport(rptPath)

    ' Create an output directory.
    Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyPDF")
    outputDirectory.Create()

    ' Provide settings for your rendering output.
    Dim pdfSetting As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings()

    ' Set the rendering extension and render the report.
    Dim pdfRenderingExtension As New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension()
    Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))

    ' Overwrite output file if it already exists
    outputProvider.OverwriteOutputFile = True

    pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting)


    Also, you can use the TextReader to load the report from stream in PageReport. Please refer to following code:
    MemoryStream ms = new MemoryStream();

    ms.Position = 0;

    TextReader tr = new StreamReader(ms);

    PageReport rpt = new PageReport(tr)


    Thanks,
    Mohit
Need extra support?

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

Learn More

Forum Channels