3

I have a Base64 jpeg image string which is a simple signature image. I can store the string in SQL Server and retreive it, but when I try to pass it to a method or save in a Session variable I get null value. Is there a limit to the string you can pass to a method or save in a session var?

Here is the code;

I get the string from db,

      string VSignature = ds.Tables[0].Rows[0]["SignatureB64"];

// VSignature gets valued ok
// then passed to a class with method to handle image,

      Write.GetPageOneReadyToBeAltered(f_older + "\\FDD.PDF", f_older + @"\N.PDF", 
            CertID, VSignature);

//here VSignature is null

      public static void GetPageOneReadyToBeAltered(string PageNReader, string PageNStamper, string CertificateNo, string VSignature)
        {
        // prepare page one's copy to be altered by user  

        PdfReader pdfreader = new PdfReader(PageNReader);
        PdfStamper pdfStamper = new PdfStamper(pdfreader, new FileStream(PageNStamper, FileMode.Create));
            /*
             some pdf stuff done here, irrelevant
            */
            var pdfContentByte = pdfStamper.GetOverContent(1);

             byte[] bytSig1 = Convert.FromBase64String(VSignature);

            MemoryStream msSig1 = new MemoryStream(bytSig1);
            iTextSharp.text.Image sig1 = iTextSharp.text.Image.GetInstance(msSig1);
            sig1.SetAbsolutePosition(23, 76);
            sig1.ScaleToFit(60f, 60f);
            pdfContentByte.AddImage(sig1);
       }

thanks

Karaman
  • 395
  • 1
  • 7
  • 19
  • 1
    'Passing to a method' should always work. Your problem is not where you think it is. – H H Mar 26 '12 at 07:41
  • 3
    There's always a limit for a session variable, your server's memory. But apart from that, show us your code where you get the string and where you store/read the session variable. – Tim Schmelter Mar 26 '12 at 07:41
  • And the relation between VSignature and VetSignature is ... > – H H Mar 26 '12 at 08:44
  • just missed it when removing irrelevant code, I know it is not an issue. thanks for the heads up though :) – Karaman Mar 26 '12 at 08:47
  • Thanks everyone for their time, I think this is something unique to the way my app moves between different aspx pages, so I will keep all the inputs in mind. Thanks again. – Karaman Mar 26 '12 at 11:13

2 Answers2

5

If you blew the limits for string sizes, you wouldn't just get a null value back - you'd get an exception. It's far more likely that you're doing something wrong in your code, but you haven't shown it to us so it's hard to say what.

Basically, while there are limitations (around a billion characters, IIRC) it's very unlikely that you're running into them.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
1

This is unlikely to be related to the image size (unless you're using huge images), and anyway you should receive an Exception, nut a null value...

see also here: What is the maximum possible length of a .NET string?

Community
  • 1
  • 1
mamoo
  • 8,156
  • 2
  • 28
  • 38