Quantcast
Channel: Martin Dráb's Activities
Viewing all articles
Browse latest Browse all 17532

Sending SSRS report as encrypted pdf document via email not working in production environment

$
0
0

We are trying to send an SSRS report as encrypted pdf document via email. Below code is working fine in dev environment - But while moving the same code to production environment its not working and throwing error as "Cannot access a closed stream".

Binary binaryData;
container binData;
System.Int32 netIndex=1,netCount=1;
int bytecount = 0 ;
System.IO.MemoryStream mstream = new System.IO.MemoryStream();

while(bytecount < reportBytes.Length)
{
mstream.WriteByte(reportBytes.GetValue(bytecount));
bytecount++;
}
mstream.Position = 0 ;
pdfreader = new iText.Kernel.Pdf.PdfReader(mstream);
writeproperties.SetStandardEncryption(System.Text.Encoding::UTF8.GetBytes(pwd),System.Text.Encoding::UTF8.GetBytes(pwd),4+2048,2|8);
pdfwriter = new iText.Kernel.Pdf.PdfWriter(mstream,writeproperties);
pdfdocumentation = new iText.Kernel.Pdf.PdfDocument(pdfreader,pdfwriter);
pdfdocumentation.Close();
pdfEncryption = mstream.GetBuffer();

int bytecountEncryp = 0 ;
System.IO.MemoryStream encryptedstream = new System.IO.MemoryStream();
while(bytecountEncryp < pdfEncryption.Length)
{
encryptedstream.WriteByte(pdfEncryption.GetValue(bytecountEncryp));
bytecountEncryp++;
}
encryptedstream.Position = 0;
binaryData = Binary::constructFromMemoryStream(encryptedstream);

if(binaryData)
{
binData = binaryData.getContainer();

}


Viewing all articles
Browse latest Browse all 17532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>