Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6853913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:34:08+00:00 2026-05-27T01:34:08+00:00

I’ve been looking everywhere… I can only find how to print a LocalReport, not

  • 0

I’ve been looking everywhere… I can only find how to print a LocalReport, not a ServerReport.

I do not want a print dialogue or anything, I just want it to print.

I have managed to get as far as printing the first page, but I cannot work out how to get the extra pages?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:34:08+00:00Added an answer on May 27, 2026 at 1:34 am

    This VB.Net (2005) class will print a SSRS 2003 report. I suppose it MAY be able to handle any SSRS version as reports are passed as arrays of byte arrays, but unfortunately I cannot yet connect to (leave alone render!) SSRS 2005 or SSRS 2008 services to test it.

    You should call the PrintReport function passing it the Report bytes (rendered as IMAGE), and the target printer name.

    Ok, here’s the code (be warned, it’s one of my first attempts, and adapted from sample C code, don’t remember where in the ‘Net):

    Imports System
    Imports System.Drawing
    Imports System.Drawing.Imaging
    Imports System.Drawing.Printing
    Imports System.IO
    Imports System.Runtime.InteropServices
    
    Public Class clsReportPrinting
    
    Private byaPagesToPrint()() As Byte = Nothing, _
            m_oMetafile As Metafile = Nothing, _
            m_iNumberOfPages As Int32 = 0, _
            m_iCurrentPrintingPage As Int32 = 0, _
            m_iLastPrintingPage As Int32 = 0, _
            m_oCurrentPageStream As MemoryStream = Nothing, _
            m_oDelegate As Graphics.EnumerateMetafileProc = Nothing
    
    Public Function PrinterExists(ByVal PrinterName As String) As Boolean
    
        'Returns TRUE if the named printer is amongst installed printers, FALSE otherwise
        Try
    
            PrinterName = PrinterName.Trim.ToUpper
    
            For Each sPrinter As String In PrinterSettings.InstalledPrinters
    
                'Printers may have UNC names, so we use .EndsWith to deal with \\Server\SharedPrinter
                'if we pass "SharedPrinter" as PrinterName
                If sPrinter.Trim.ToUpper.EndsWith(PrinterName) Then
                    Return True
                End If
    
            Next
    
            Return False
    
        Catch oEx As Exception
    
            'Report error
            glb_oLog.Log(oEx.ToString, clsLogger.enuSeverity.sev_01_Error)
            Return False
    
        End Try
    
    End Function
    
    Public Function MetafileCallback(ByVal oRecType As EmfPlusRecordType, _
                                      ByVal iFlags As Int32, _
                                      ByVal iDataSize As Int32, _
                                      ByVal dpData As IntPtr, _
                                      ByVal oCallbackData As PlayRecordCallback _
                                     ) As Boolean
    
        Dim byaDataArray() As Byte = Nothing
    
        If dpData <> IntPtr.Zero Then
    
            'Copy unmanaged data to managed array for PlayRecord call
            Array.Resize(Of Byte)(byaDataArray, iDataSize)
            Marshal.Copy(dpData, byaDataArray, 0, iDataSize)
    
        End If
    
        'Play the record
        m_oMetafile.PlayRecord(oRecType, iFlags, iDataSize, byaDataArray)
    
        'Return value
        Return True
    
    End Function
    
    Private Function MoveToPage(ByVal lPage As Int32) As Boolean
    
        'Check current page does exist
        If Me.byaPagesToPrint(m_iCurrentPrintingPage - 1) Is Nothing Then
            Return False
        End If
    
        'Set current page stream to desired rendered page
        m_oCurrentPageStream = New MemoryStream(Me.byaPagesToPrint(m_iCurrentPrintingPage - 1))
        'Set curernt stream position to its start
        m_oCurrentPageStream.Position = 0
    
        'Get rid of any former metafile
        If Not m_oMetafile Is Nothing Then
            m_oMetafile.Dispose()
            m_oMetafile = Nothing
        End If
    
        'Set local metafile to page
        m_oMetafile = New Metafile(m_oCurrentPageStream)
    
        'Must always return TRUE
        Return True
    
    End Function
    
    Public Sub pd_PrintPage(ByVal oSender As Object, _
                             ByVal oEV As PrintPageEventArgs)
    
        oEV.HasMorePages = False
    
        If (m_iCurrentPrintingPage <= m_iLastPrintingPage) And _
           (MoveToPage(m_iCurrentPrintingPage)) Then
    
            'Draw the page
            DrawPage(oEV.Graphics)
    
            'Point to next page
            m_iCurrentPrintingPage += 1
    
            'If there are more pages, flag so.
            oEV.HasMorePages = (m_iCurrentPrintingPage <= m_iLastPrintingPage)
    
        End If
    
    End Sub
    
    'This draws the current selected stream into a metafile
    Public Sub DrawPage(ByVal oGrx As Graphics)
    
        If m_oCurrentPageStream Is Nothing Or _
           m_oCurrentPageStream.Length = 0 Or _
           m_oMetafile Is Nothing Then
    
            Return
    
        End If
    
        'Critical section follows (no more than one thread a time)
        SyncLock Me
    
            Dim iWidth As Int32 = m_oMetafile.Width, _
                iHeight As Int32 = m_oMetafile.Height, _
                oDestPoint As Point = Nothing
    
            'Prepare metafile delegate
            m_oDelegate = New Graphics.EnumerateMetafileProc(AddressOf MetafileCallback)
    
            'Draw in the rectangle
            oDestPoint = New Point(0, 0)
            oGrx.EnumerateMetafile(m_oMetafile, oDestPoint, m_oDelegate)
    
            'Clean up
            m_oDelegate = Nothing
    
        End SyncLock
    
    End Sub
    
    Public Function PrintReport(ByVal byaReport()() As Byte, _
                                ByVal sPrinterName As String _
                               ) As Boolean
    
        'Report data is an array of pages. Each page in turn is another byte array.
        Me.byaPagesToPrint = byaReport
        m_iNumberOfPages = Me.byaPagesToPrint.Length
    
        Try
    
            Dim oPS As PrinterSettings = New PrinterSettings
            oPS.MaximumPage = m_iNumberOfPages
            oPS.MinimumPage = 1
            oPS.PrintRange = PrintRange.SomePages
            oPS.FromPage = 1
            oPS.ToPage = m_iNumberOfPages
            oPS.PrinterName = sPrinterName
    
            Dim oPD As PrintDocument = New PrintDocument
            m_iCurrentPrintingPage = 1
            m_iLastPrintingPage = m_iNumberOfPages
            oPD.PrinterSettings = oPS
    
            'Do print the report
            AddHandler oPD.PrintPage, AddressOf Me.pd_PrintPage
            oPD.Print()
    
            Return True
    
        Catch oEx As Exception
    
            'Report error
            glb_oLog.Log(oEx.ToString, clsLogger.enuSeverity.sev_01_Error, , True)
    
        End Try
    
    End Function
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.