使用vb中的itextsharp在pdf中添加qr代码时出错

时间:2015-09-21 18:51:51

标签: vb.net itextsharp

当我尝试在itextsharp中从方法(qr代码)添加图片结果生成时返回下一个错误:

无法将system.drawing.bitmap转换为system.itextsharp.text.image

iTextSharp.text.Image=iTextSharp.text.Image.GetInstance(picture2().GetHbitmap)

方法

Public Function picture2() As System.Drawing.Bitmap
        Dim generarCodigoQR As QRCodeEncoder = New QRCodeEncoder
        generarCodigoQR.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE
        generarCodigoQR.QRCodeScale = Int32.Parse(4)

        generarCodigoQR.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H

        generarCodigoQR.QRCodeVersion = 0

        Try
            If opForzarUTF.Checked Then

                imgQR.Image = generarCodigoQR.Encode("http://www.ajpdsoft.com", _
                                    System.Text.Encoding.UTF8)
            Else
                imgQR.Image = generarCodigoQR.Encode("http://www.ajpdsoft.com")
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly)
        End Try

        Return generarCodigoQR.Encode("http://www.ajpdsoft.com")
    End Function

0 个答案:

没有答案