Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 条形码隐藏在reporting services中_Vb.net_Reporting Services_Reporting_Barcode - Fatal编程技术网

Vb.net 条形码隐藏在reporting services中

Vb.net 条形码隐藏在reporting services中,vb.net,reporting-services,reporting,barcode,Vb.net,Reporting Services,Reporting,Barcode,我有一份带有条形码的报告,在进行Visual Studio预览时,它看起来非常完美,但在发布到服务器reporting services(WEB)时,不会像隐藏一样向我显示条形码 这是我在报告中使用的代码: Public Shared Function Code39(ByVal stringText As String) As Byte() Dim result As Byte() = Nothing Try result = Gener

我有一份带有条形码的报告,在进行
Visual Studio
预览时,它看起来非常完美,但在发布到服务器reporting services(WEB)时,不会像隐藏一样向我显示条形码

这是我在报告中使用的代码:

Public Shared Function Code39(ByVal stringText As String) As Byte()
        Dim result As Byte() = Nothing

        Try
            result = GenerateImage("Code 3 de 9", StringToBarcode39String(stringText))
        Catch ex As Exception
        End Try

        Return result
    End Function

    Public Shared Function Code128(ByVal stringText As String) As Byte()
        Dim result As Byte() = Nothing

        Try
            result = GenerateImage("Code 128", StringToBarcode128String(stringText))
        Catch ex As Exception
        End Try

        Return result
    End Function

    Public Shared Function GenerateImage(ByVal fontName As String, ByVal stringText As String) As Byte()
        Dim oGraphics As System.Drawing.Graphics
        Dim barcodeSize As System.Drawing.SizeF
        Dim ms As System.IO.MemoryStream

        Using font As New System.Drawing.Font(New System.Drawing.FontFamily(fontName), 36)
            Using tmpBitmap As New System.Drawing.Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                oGraphics = System.Drawing.Graphics.FromImage(tmpBitmap)
                oGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel
                barcodeSize = oGraphics.MeasureString(stringText, font)
                oGraphics.Dispose()
            End Using

            Using newBitmap As New System.Drawing.Bitmap(barcodeSize.Width, barcodeSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                oGraphics = System.Drawing.Graphics.FromImage(newBitmap)
                oGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel

                Using oSolidBrushWhite As New System.Drawing.SolidBrush(System.Drawing.Color.White)
                    Using oSolidBrushBlack As New System.Drawing.SolidBrush(System.Drawing.Color.Black)
                        oGraphics.FillRectangle(oSolidBrushWhite, New System.Drawing.Rectangle(0, 0, barcodeSize.Width, barcodeSize.Height))
                        oGraphics.DrawString(stringText, font, oSolidBrushBlack, 0, 0)
                    End Using

                End Using

                ms = New System.IO.MemoryStream()
                newBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
            End Using
        End Using

        Return ms.ToArray()
    End Function

    Public Shared Function StringToBarcode128String(ByVal value As String) As String
        ' Parameters : a string
        ' Return     : a string which give the bar code when it is dispayed with CODE128.TTF font
        '            : an empty string if the supplied parameter is no good
        Dim charPos As Integer, minCharPos As Integer
        Dim currentChar As Integer, checksum As Integer
        Dim isTableB As Boolean = True, isValid As Boolean = True
        Dim returnValue As String = String.Empty

        If value.Length > 0 Then

            ' Check for valid characters
            For charCount As Integer = 0 To value.Length - 1
                'currentChar = char.GetNumericValue(value, charPos);
                currentChar = AscW(Char.Parse(value.Substring(charCount, 1)))
                If Not (currentChar >= 32 AndAlso currentChar <= 126) Then
                    isValid = False
                    Exit For
                End If
            Next

            ' Barcode is full of ascii characters, we can now process it
            If isValid Then
                charPos = 0
                While charPos < value.Length
                    If isTableB Then
                        ' See if interesting to switch to table C
                        ' yes for 4 digits at start or end, else if 6 digits
                        If charPos = 0 OrElse charPos + 4 = value.Length Then
                            minCharPos = 4
                        Else
                            minCharPos = 6
                        End If


                        minCharPos = IsNumber(value, charPos, minCharPos)

                        If minCharPos < 0 Then
                            ' Choice table C
                            If charPos = 0 Then
                                ' Starting with table C
                                ' char.ConvertFromUtf32(210);
                                returnValue = (ChrW(210)).ToString()
                            Else
                                ' Switch to table C
                                returnValue = returnValue & (ChrW(204)).ToString()
                            End If
                            isTableB = False
                        Else
                            If charPos = 0 Then
                                ' Starting with table B
                                ' char.ConvertFromUtf32(209);
                                returnValue = (ChrW(209)).ToString()

                            End If
                        End If
                    End If

                    If Not isTableB Then
                        ' We are on table C, try to process 2 digits
                        minCharPos = 2
                        minCharPos = IsNumber(value, charPos, minCharPos)
                        If minCharPos < 0 Then
                            ' OK for 2 digits, process it
                            currentChar = Integer.Parse(value.Substring(charPos, 2))
                            currentChar = IIf(currentChar < 95, currentChar + 32, currentChar + 105) ''
                            returnValue = returnValue & (ChrW(currentChar)).ToString()
                            charPos += 2
                        Else
                            ' We haven't 2 digits, switch to table B
                            returnValue = returnValue & (ChrW(205)).ToString()
                            isTableB = True
                        End If
                    End If
                    If isTableB Then
                        ' Process 1 digit with table B
                        returnValue = returnValue & value.Substring(charPos, 1)
                        charPos += 1
                    End If
                End While

                ' Calculation of the checksum
                checksum = 0
                For [loop] As Integer = 0 To returnValue.Length - 1
                    currentChar = AscW(Char.Parse(returnValue.Substring([loop], 1)))
                    currentChar = IIf(currentChar < 127, currentChar - 32, currentChar - 105)
                    If [loop] = 0 Then
                        checksum = currentChar
                    Else
                        checksum = (checksum + ([loop] * currentChar)) Mod 103
                    End If
                Next

                ' Calculation of the checksum ASCII code
                checksum = IIf(checksum < 95, checksum + 32, checksum + 105)
                ' Add the checksum and the STOP
                returnValue = returnValue & (ChrW(checksum)).ToString() & (ChrW(211)).ToString()
            End If
        End If

        Return returnValue
    End Function


    Private Shared Function IsNumber(ByVal InputValue As String, ByVal CharPos As Integer, ByVal MinCharPos As Integer) As Integer
        ' if the MinCharPos characters from CharPos are numeric, then MinCharPos = -1
        MinCharPos -= 1
        If CharPos + MinCharPos < InputValue.Length Then
            While MinCharPos >= 0
                If AscW(Char.Parse(InputValue.Substring(CharPos + MinCharPos, 1))) < 48 OrElse AscW(Char.Parse(InputValue.Substring(CharPos + MinCharPos, 1))) > 57 Then
                    Exit While
                End If
                MinCharPos -= 1
            End While
        End If
        Return MinCharPos
    End Function

    Public Shared Function StringToBarcode39String(ByVal value As String, Optional ByVal addChecksum As Boolean = False) As String
        ' Parameters : a string
        ' Return     : a string which give the bar code when it is dispayed with CODE128.TTF font
        '            : an empty string if the supplied parameter is no good
        Dim isValid As Boolean = True
        Dim currentChar As Char
        Dim returnValue As String = String.Empty
        Dim checksum As Integer = 0
        If value.Length > 0 Then

            'Check for valid characters
            For CharPos As Integer = 0 To value.Length - 1
                currentChar = Char.Parse(value.Substring(CharPos, 1))
                If Not ((currentChar >= "0"c AndAlso currentChar <= "9"c) OrElse (currentChar >= "A"c AndAlso currentChar <= "Z"c) OrElse currentChar = " "c OrElse currentChar = "-"c OrElse currentChar = "."c OrElse currentChar = "$"c OrElse currentChar = "/"c OrElse currentChar = "+"c OrElse currentChar = "%"c) Then
                    isValid = False
                    Exit For
                End If
            Next
            If isValid Then
                ' Add start char
                returnValue = "*"
                ' Add other chars, and calc checksum
                For CharPos As Integer = 0 To value.Length - 1
                    currentChar = Char.Parse(value.Substring(CharPos, 1))
                    returnValue += currentChar.ToString()
                    If currentChar >= "0"c AndAlso currentChar <= "9"c Then
                        checksum = checksum + AscW(currentChar) - 48
                    ElseIf currentChar >= "A"c AndAlso currentChar <= "Z"c Then
                        checksum = checksum + AscW(currentChar) - 55
                    Else
                        Select Case currentChar
                            Case "-"c
                                checksum = checksum + AscW(currentChar) - 9
                                Exit Select
                            Case "."c
                                checksum = checksum + AscW(currentChar) - 9
                                Exit Select
                            Case "$"c
                                checksum = checksum + AscW(currentChar) + 3
                                Exit Select
                            Case "/"c
                                checksum = checksum + AscW(currentChar) - 7
                                Exit Select
                            Case "+"c
                                checksum = checksum + AscW(currentChar) - 2
                                Exit Select
                            Case "%"c
                                checksum = checksum + AscW(currentChar) + 5
                                Exit Select
                            Case " "c
                                checksum = checksum + AscW(currentChar) + 6
                                Exit Select
                        End Select
                    End If
                Next
                ' Calculation of the checksum ASCII code
                If addChecksum Then
                    checksum = checksum Mod 43
                    If checksum >= 0 AndAlso checksum <= 9 Then
                        returnValue += (ChrW(checksum + 48)).ToString()
                    ElseIf checksum >= 10 AndAlso checksum <= 35 Then
                        returnValue += (ChrW(checksum + 55)).ToString()
                    Else
                        Select Case checksum
                            Case 36
                                returnValue += "-"
                                Exit Select
                            Case 37
                                returnValue += "."
                                Exit Select
                            Case 38
                                returnValue += " "
                                Exit Select
                            Case 39
                                returnValue += "$"
                                Exit Select
                            Case 40
                                returnValue += "/"
                                Exit Select
                            Case 41
                                returnValue += "+"
                                Exit Select
                            Case 42
                                returnValue += "%"
                                Exit Select
                        End Select
                    End If
                End If
                ' Add stop char
                returnValue += "*"
            End If
        End If
        Return returnValue
    End Function
公共共享函数Code39(ByVal stringText作为字符串)作为字节()
将结果设置为字节()=无
尝试
结果=生成图像(“代码3 de 9”,StringToBarcode39String(stringText))
特例
结束尝试
返回结果
端函数
公共共享函数代码128(ByVal stringText作为字符串)作为字节()
将结果设置为字节()=无
尝试
结果=生成图像(“代码128”,StringToBarcode128String(stringText))
特例
结束尝试
返回结果
端函数
公共共享函数GenerateImage(ByVal fontName作为字符串,ByVal stringText作为字符串)作为字节()
作为系统、图纸、图形的Dim Graphics
尺寸条形码尺寸为System.Drawing.SizeF
将ms变暗为System.IO.MemoryStream
将字体用作新的System.Drawing.font(新的System.Drawing.FontFamily(fontName),36)
使用tmpBitmap作为新的System.Drawing.Bitmap(1,1,System.Drawing.Imaging.PixelFormat.Format32bppArgb)
oGraphics=系统.Drawing.Graphics.FromImage(tmpBitmap)
oGraphics.TextRenderingHint=System.Drawing.Text.TextRenderingHint.SingleBitPerPixel
barcodeSize=oGraphics.MeasureString(stringText,字体)
graphics.Dispose()
终端使用
将newBitmap用作新的System.Drawing.Bitmap(barcodeSize.Width、barcodeSize.Height、System.Drawing.Imaging.PixelFormat.Format32bppArgb)
oGraphics=系统.绘图.图形.FromImage(newBitmap)
oGraphics.TextRenderingHint=System.Drawing.Text.TextRenderingHint.SingleBitPerPixel
使用oSolidBrushWhite作为新的System.Drawing.SolidBrush(System.Drawing.Color.White)
使用oSolidBrushBlack作为新的System.Drawing.SolidBrush(System.Drawing.Color.Black)
图形学.圆角矩形(白色,新系统.绘图.矩形(0,0,条形码大小.宽度,条形码大小.高度))
Graphics.DrawString(stringText、字体、黑色、0、0)
终端使用
终端使用
ms=新系统.IO.MemoryStream()
保存(ms,System.Drawing.Imaging.ImageFormat.Png)
终端使用
终端使用
返回ToArray女士()
端函数
公共共享函数StringToBarcode128String(ByVal值作为字符串)作为字符串
'参数:字符串
'返回:使用CODE128.TTF字体显示条形码时给出条形码的字符串
“:如果提供的参数不好,则为空字符串
Dim charPos为整数,minCharPos为整数
Dim currentChar为整数,校验和为整数
Dim IsTable为布尔值=True,isValid为布尔值=True
Dim returnValue为String=String.Empty
如果value.Length>0,则
'检查有效字符
对于charCount As Integer=0到value.Length-1
'currentChar=char.GetNumericValue(值,charPos);
currentChar=AscW(Char.Parse(value.Substring(charCount,1)))
如果不是(currentChar>=32,并且currentChar=0
如果AscW(Char.Parse(InputValue.Substring(CharPos+MinCharPos,1)))<48或LSE AscW(Char.Parse(InputValue.Substring(CharPos+MinCharPos,1))>57,则
退出时
如果结束
MinCharPos-=1
结束时
如果结束
返回MinCharPos
端函数
公共共享函数StringToBarcode39String(ByVal值为String,可选ByVal addChecksum为Boolean=False)为String
'参数:字符串
'返回:使用CODE128.TTF字体显示条形码时给出条形码的字符串
“:如果提供的参数不好,则为空字符串
Dim的有效值为Boolean=True
Dim currentChar作为Char
Dim returnValue为String=String.Empty
整数形式的Dim校验和=0
如果value.Length>0,则
'检查有效字符
对于CharPos,整数=0到值。长度-1
currentChar=Char.Parse(value.Substring(CharPos,1))

如果不是((currentChar>=“0”c AndAlso currentChar=“A”c AndAlso currentChar=“0”c AndAlso currentChar=“A”c AndAlso currentChar=“A”c AndAlso currentChar)可能是服务器上缺少条形码字体吗