Solution to convert old Reports to PDF

Posted by: neerpds on 4 August 2017, 5:39 am EST

  • Posted 4 August 2017, 5:39 am EST

    In our system we have old reports that print direclty to printers from a telnet session, well we want to allow them to print to a pdf. Right now I have captured the text into a array broken up by Pagebreaks.

    Anyone know how to send in an array into an RPX file? I see you code using the ActiveReport form.. but since I'm sending this straight to PDF I dont need the AR form.



    if anyone has any ideas or a better solution, please let me know!

    Thanks



    Neer

  • Posted 4 August 2017, 5:39 am EST

    If you can still use ActiveReports, you may consider exporting the report to PDF:

    http://www.datadynamics.com/Help/AR2/AR2Exports/HX_Using_The_Export_Filters.html



    I’m not sure exactly what you mean by sending an array into an RPX file.  The closest I can think of is using unbound mode through script or a passed-in class (with AddNamedItem).

  • Posted 4 August 2017, 5:39 am EST

    What do you mean by “AddNamedItem” ? you have an example?

  • Posted 4 August 2017, 5:39 am EST

    sweet, I feel like I’m getting somewhere now!!



    on problem, I get a type mismatch error:





      Dim rpt As ActiveReport



        Set rpt = New ActiveReport



        Dim arrStr() As String



        (Populate array…)



        rpt.LoadLayout AppPath & “\Reports\tmp.rpx”

        rpt.AddNamedItem “arr”, arrStr()

        rpt.Run

        dlgReport.Filter = “Portable Document Format (.pdf)|.pdf”

        dlgReport.ShowSave

      

       If dlgReport.FileName <> “” Then

        Dim ARexport As New ARExportPDF 'create instance of export object

        ARexport.FileName = dlgReport.FileName

        rpt.Export ARexport 'create document

       End If

  • Posted 4 August 2017, 5:39 am EST

    Thanks for the article links, wsmith.



    The second argument of AddNamedItem needs to be a class that you pass into the report.  The class would then contain any objects you want to refer to from your script code.



    I have attached a zip that contains an example of AddNamedItem (PrintProgressScript) and an alternate solution that shows how to use VB6’s WithEvents to fire events on reports loaded from RPX without having to use script.



    2005/06/FiringEventsOnRpxReports.zip

  • Posted 4 August 2017, 5:39 am EST

    ok after long confused hours of programming I've decided to use a designer to create this report.. but I have a new problem now.. here is my designer code :



    Private Arr() As String

    Private iRow As Integer

    Private Sub ARRPTWriter_DataInitialize()

        Fields.Add "txtBox"

        iRow = 1

    End Sub

    Private Sub ActiveReport_FetchData(eof As Boolean)

        If iRow > UBound(Arr) Then

            eof = True

            Exit Sub

        End If

        Fields("txtBox") = "1 " & Arr(iRow)

       

        eof = False

        iRow = iRow + 1

    End Sub



    Public Property Let GetData(ByRef tmpArr() As String)

    ReDim Arr(UBound(tmpArr))

    Dim x As Integer

    For x = 1 To UBound(tmpArr)

    Arr(x) = tmpArr(x)

    Next x

    End Property



    I couldn't make 'Arr()' public cause it came back as a constraint.. so I made a Let Property.. it works and set the Arr = tmpArr but FetchData function doesn't get called.. anyone have any ideas how to run it?

  • Posted 4 August 2017, 5:39 am EST

    I am not sure how you generated this code.  Normally, the name before the event is the object firing the event.  In your DataInitialize, it appears your report object is of type ARRPTWriter, but then in your FetchData, it is ActiveReport.  These two event handlers should have the same name before the underscore.

  • Posted 4 August 2017, 5:39 am EST

    ok, corrected it and I get this error



    Error 5800 : Scripting Error. 

     [ Extended Info:Source: Report , Event: Line number: 1  Description:Expected end of statement]

  • Posted 4 August 2017, 5:39 am EST

    I was able to help you resolve this over the phone.  We determined that there were some stray characters in your script, and actually looking at the script for each object appeared to flush the stray characters out.

  • Posted 16 July 2018, 4:43 pm EST

    Here The Solution to convert old Reports to PDF!!!

    I would recommend to check https://zetpdf.com/

    library

Need extra support?

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

Learn More

Forum Channels