tags:

views:

14

answers:

0

Hi , I want to show data on pdf format , The source ( base64 format ) is a parameter , not a file , and my code is :

    byte[] bytes = System.Convert.FromBase64String(source);
    MemoryStream fs = new MemoryStream(bytes, 0, bytes.Length);
    fs.Position = 0;
    fs.Seek(0, SeekOrigin.Begin);
    fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
    HttpContext.Current.Response.Buffer = false;
    HttpContext.Current.Response.ContentType = "application/pdf";
    HttpContext.Current.Response.OutputStream.Write(fs.ToArray(), 0, Convert.ToInt32(fs.Length));
    HttpContext.Current.Response.Flush();
    HttpContext.Current.Response.End();
    fs.Dispose();
    fs.Close();

the result is : the acrobat reader is open and on the file i've got the message :

" ERROR in closing this document. Possible cause: the document has no pages. "

what is the problem ? the source ?

thanks in advance ,

poli