Reputation: 395
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
Upvotes: 3
Views: 376
Reputation: 8166
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?
Upvotes: 1
Reputation: 1499730
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.
Upvotes: 5