String variable constraints

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

Here is the code;

I am getting 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);

      

// VSignature is null here

      public static void GetPageOneReadyToBeAltered(string PageNReader, string PageNStamper, string CertificateNo, string VSignature)
        {
        // prepare page one 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);
       }

      

thank

+3


source to share


2 answers


If you blew up the limits for string sizes, you would just get a null value back - you get an exception. You are most likely doing something wrong in your code, but you haven't shown it to us, so it's hard to tell what.



Basically, although there are limits (about a billion characters, IIRC), it is very unlikely that you will run into them.

+5


source


This is unlikely to be related to the image size (unless you are using huge images) and you should get an exception anyway, nut is zero ...



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

+1


source







All Articles