Problem with code after switching machines RRS feed

  • Question

  • I wrote a program that prints labels on a brother QL-570 label printer.  The code worked fine when I was running windows server 2003 32-bit.  I have build another machine that is win 7 pro 64-bit.  The program uses a local report to create the label.  The problem is that even though I have the label size set up correctly in the report, when the image is generated on this new machine, it is very large and seems to totally disregard any effort to get it sized correctly.  I've tried all of the image formatting options to no avail.  I've pasted my code and my repair.xml for your reference.  Any advice is greatly appreciated.

    Private Sub pHandler(ByVal oPrn As System.Object, ByVal e As PrintPageEventArgs)
            Dim oGfx As System.Drawing.Graphics = e.Graphics

            oGfx.DrawImage(oImage, New PointF(0, 0))
        End Sub

        Private Sub PrintReport()
            Dim iPrinterIndex As Integer = -1
            Dim iPrinterResolutionIndex As ePrintResolutions = ePrintResolutions.Repair
            Dim iPaperSizeIndex As ePaperSizes = ePaperSizes.None
            Dim oWarnings(100) As Microsoft.Reporting.WinForms.Warning
            Dim sXML As String = ""
            Dim sMimeType As String = ""
            Dim sEncoding As String = ""
            Dim sExtension As String = ""
            Dim asStreams(100) As String

            Dim asPrinters As PrinterSettings.StringCollection
            Dim oRpt As New LocalReport
            Dim oPd As New PrintDocument()
            Dim oPsz As PrinterSettings.PaperSizeCollection

            AddHandler oPd.PrintPage, AddressOf Phandler
            asPrinters = PrinterSettings.InstalledPrinters

            oRpt.ReportPath = System.IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Resources\Price.rdlc")
            Dim oReader As New System.IO.StreamReader(System.IO.Path.Combine(My.Computer.FileSystem.CurrentDirectory, "Resources\Repair.xml"))
            sXML = oReader.ReadToEnd
            oPd.DocumentName = "Price Label"
            oPd.PrinterSettings.PrinterName = asPrinters(My.Settings.RepairPrinterIndex)
            oPsz = oPd.PrinterSettings.PaperSizes
            oPd.DefaultPageSettings.PaperSize = oPsz(ePaperSizes.Repair)

            Dim pCol As New System.Collections.Generic.List(Of ReportParameter)
            pCol.Add(New ReportParameter("ItemName", Me.TextBoxItemName.Text))
            pCol.Add(New ReportParameter("ItemDesc", Me.TextBoxDescription.Text))
            pCol.Add(New ReportParameter("ItemPrice", CType(Me.TextBoxPrice.Text, Double)))


                Dim bOutBytes() As Byte = oRpt.Render("IMAGE", sXML, sMimeType, sEncoding, sExtension, asStreams, oWarnings)
                Dim oFs As New System.IO.FileStream(IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData, "Report.bmp"), IO.FileMode.Create)
                oFs.Write(bOutBytes, 0, bOutBytes.Length)

                oImage = System.Drawing.Image.FromFile(IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData, "Report.bmp"))
            Catch ex As Exception
                Call oUtil.SetStatusMessage(String.Format("Render Error: {0}", ex.InnerException.Message))
                asPrinters = Nothing
                pCol = Nothing
                oPsz = Nothing
                Exit Sub
            End Try

            oPd.DefaultPageSettings.Color = False
            oPd.DefaultPageSettings.Margins.Bottom = 0
            oPd.DefaultPageSettings.Margins.Top = 0
            oPd.DefaultPageSettings.Margins.Left = 0
            oPd.DefaultPageSettings.Margins.Right = 0

            Dim oPres As PrinterSettings.PrinterResolutionCollection = oPd.PrinterSettings.PrinterResolutions
            oPd.PrinterSettings.DefaultPageSettings.PrinterResolution = oPres(iPrinterResolutionIndex)

            For iCtr As Integer = 1 To Me.nudCopies.Value

            pCol = Nothing
            oPsz = Nothing
            asPrinters = Nothing

                IO.File.Delete(IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData, "report.bmp"))
            Catch ex As Exception

            End Try
        End Sub


    <?xml version='1.0' encoding='UTF-8'?>
    <!-- This document was created with Syntext Serna Free. -->

    NumbLock Et Al
    There are only 10 kinds of people in the world. Those who understand binary and those who don't

    • Moved by Mike Feng Monday, February 13, 2012 9:17 AM Report (From:Visual Basic General)
    Saturday, February 11, 2012 5:35 PM

All replies

  • Hi,

    Welcome to the MSDN Forum.

    I have moved this thread to a dedicated forum for better support.

    Best regards,

    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 13, 2012 9:16 AM