VB Crystal Report >> Printing Report Groups Programmatically

by dwoodward » Wed, 08 Oct 2003 03:44:24 GMT

I get a series of .rpt files sent to me periodically (once a day) that
contains a saved copy of the data for the report at the time the
report was generated. Each report generated contains multiple invoices
that can each span multiple printed pages. What I would like to do is
to programmatically print each invoice out separately as a pdf file
with the pdf file named 1234.pdf where 1234 is the invoice number.
I've tried a number of things to accomplish this but in each case I'm
prompted to login to the original database (which is no longer
available) rather than simply using the snapshot data that is embedded
within the report. I'm currently using the builtin .NET version of
Crystal Reports. Any ideas?

Don ...


Similar Threads

1. printing rdlc reports programmatically

2. Generate reports programmatically with reporting services & SQL server 2005 - VB.Net

3. Crystal Reports : PDF exported report differs from direct printed report

Hello,

I made a short VB program that allow to print a report directly to a
printer and to export a report into PDF. For the same report, I
noticed that the PDF version differs from the "direct" print version :
the PDF version has a smaller font and bigger margins than the printed
version. I tried to make the same operation from the Crystal Reports
Designer, but it gave me the same result. I also tried to create the
PDF, not with the Crystal Reports export function but by printing the
report to a virtual PDF printer. Here again, i had the same result.
Does anyone know about this problem and how can a solve it please?

Thanks.

Riadh.

4. Crystal reports: group summary in report footer - VB Crystal Report

5. Programmatically adding member to a GAL group

I would like to create a macro to programmatically add members to Global
Address List group. My intention is to automate an admin task for users
requesting accessing to GAL group. The admin would recieve the email request
and the macro would be part of rule that would add the user to the GAL group

Thanks
G


6. Hiding groups and/or Detail lines programmatically - VB Crystal Report

7. Print Report without ReportViewer, footer does not print

Printing out the report without the ReportViewer is working except the footer 
will not print.

However, when I print the report out using the reportViewer, the footer 
prints out correctly.  

Is this a known problem, or am I doing something wrong with my code?


  Private Sub RenderReport()

        Dim deviceInfo As String = _
          "<DeviceInfo>" + _
          "  <OutputFormat>emf</OutputFormat>" + _
          "  <PageWidth>8.5in</PageWidth>" + _
          "  <PageHeight>11in</PageHeight>" + _
          "  <MarginTop>0.0in</MarginTop>" + _
          "  <MarginLeft>0.0in</MarginLeft>" + _
          "  <MarginRight>0.0in</MarginRight>" + _
          "  <MarginBottom>0.0in</MarginBottom>" + _
          "</DeviceInfo>"

        Dim warnings() As Warning = Nothing
        Dim stream As Stream

        _streams = New List(Of Stream)()
        Me.ReportViewer1.LocalReport.Render("IMAGE", deviceInfo, _
              AddressOf CreateStream, warnings)

        For Each stream In _streams
            stream.Position = 0
        Next

        _currentPageIndex = 0

    End Sub

    Private Function CreateStream( _
        ByVal name As String, _
        ByVal fileNameExtension As String, _
        ByVal encoding As Encoding, _
        ByVal mimeType As String, _
        ByVal willSeek As Boolean) As Stream

        Dim stream As MemoryStream

        stream = New MemoryStream()
        _streams.Add(stream)

        Return stream

    End Function

    Private Sub Print()

        Dim printerName As String
        Dim printDoc As New PrintDocument()

        printerName = "\\FILE01\Lexmark T622"

        If _streams Is Nothing Or _streams.Count = 0 Then

            Return

        End If

        printDoc.PrinterSettings.PrinterName = printerName

        If Not printDoc.PrinterSettings.IsValid Then

            Dim msg As String = String.Format( _
                 "Can't find printer ""{0}"".", printerName)
            Console.WriteLine(msg)

            Return

        End If

        AddHandler printDoc.PrintPage, AddressOf PrintPage

        printDoc.Print()

    End Sub

    Private Sub PrintPage( _
        ByVal sender As Object, _
        ByVal ev As PrintPageEventArgs)

        Dim pageImage As New Metafile(_streams(_currentPageIndex))
        ev.Graphics.DrawImage(pageImage, ev.PageBounds)

        _currentPageIndex += 1
        ev.HasMorePages = (_currentPageIndex < _streams.Count)

        If Not (ev.HasMorePages) Then

            If Not (_streams Is Nothing) Then

                Dim stream As Stream

                For Each stream In _streams
                    stream.Close()
                    stream.Dispose()
                Next

                _streams = Nothing

            End If

        End If

    End Sub


Thanks,

            Marc

8. Printing a crystal report out of VB.Net is not printing properly - VB Crystal Report