Search code examples
imagecrystal-reportsfile-handling

How put Image location dynamically Crystal report from byte array


My problem is simple but I don't find the solution. I know how modifiy dynamically a picture when I've the path. But In my project I collect signature of people. I don't want file (not secure enough) then I store it in database (I use signature_pad and server side I use

 Dim dataUri = MesDonnees.Img
 Dim encodedImage = dataUri.Split(",")(1)
 Bdd.field = Convert.FromBase64String(encodedImage)
 ...

But I don't solve how put it in footer of my document... I read some works but always it's from details section and I just have string type, number, boolean... not byte or something Thanks for your help

UPDATE I've an idea. Try to link this image to ashx file

 Dim IdAtt As Long = CLng(HelperParams.GetParamURL("IdAttach"))
        Dim Typ As Integer = CInt(HelperParams.GetParamURL("Typ"))

            Dim LesDatas As New MyEntities
            Dim Att As Attachement = GetMonAttachement(IdAtt, LesDatas)
            If Att IsNot Nothing Then
                context.Response.ContentType = "image/png"
                If Typ = 1 Then
                    context.Response.BinaryWrite(Att.SignCollaborateur)
                Else
                    If Att.SignClient Is Nothing Then
                        Dim Vid() As Byte = New Byte(0) {}
                        context.Response.BinaryWrite(Vid)
                    Else
                        context.Response.BinaryWrite(Att.SignClient)
                    End If
                End If
                context.Response.Flush()
                context.Response.End()
            End If

    Catch ex As Exception
    End Try

If I put in IE: http://localhost:63888/Signature.ashx?IdAttach=4&Typ=2 I've my picture

But I try to create SignClient parameter et assign it location (x-2)

           cryRpt.SetParameterValue("SignClient", "~/Signature.ashx?IdAttach=4&Typ=2")
        cryRpt.SetParameterValue("SignClient", HttpContext.Current.Server.MapPath("/Signature.ashx") & "?IdAttach=4&Typ=2")
        cryRpt.SetParameterValue("SignClient", "http://localhost:63888/Signature.ashx?IdAttach=4&Typ=2")

This 3 methods don't work.

I try to put directly : http://localhost:63888/Signature.ashx?IdAttach=4&Typ=2 in location (x-2) of image tabs : idem I put a break point to ashx, never reach. Then I open network tab developpement tool and my ashx never call.

I've an picture in header (logo) and I change picture location with a path file (e:/../logo.png) and it's good.

Someone have an idea?


Solution

  • Finally, after try and try, the only solution I find is 1/ to make subreport (my request return only 1 line) 2/ in subreport delete all section except details section 3/ Create a class with property Contenu as byte() 4/ Add datafield in subreport to this new class and drop the field in detail section

    For signaturepad, just put backgroundcolor : rgb(255,255,255) but penColor : (1,1,1) else (CR or acrobat) show black image.