Stream error

Hi,

I am evaluating Aspose.Pdf.Kit and require that the output pdf be put in the response stream when the user clicks a button. The code below is put in a button's click event handler method. However when I put a break point just after the Form.Save() method I see that the outstream MemoryStream has Length = 0 hence the outstream never gets the converted pdf. The strange part however is that when i give the output as a file name then the file is created and is filled with the appropriate data. Is this a bug with the library? Am I doing things right? How can I output the PDF to the response's outputstream when the user clicks a button?

Any help is appreciated

Thanks

Palak

MemoryStream outstream = new MemoryStream();

Aspose.Pdf.Kit.Form sf424Form = new Form(Server.MapPath("sf424_cover.pdf"),outstream);

foreach (string field in sf424Form.FieldsNames)

{

sf424Form.FillField(field, "HelloWorld");

}

Response.ClearContent();

Response.Buffer = true;

Response.AddHeader("content-disposition", "inline; filename=" + "output.pdf");

Response.ContentType = "application/pdf";

sf424Form.Save();

Response.BinaryWrite(outstream.GetBuffer());

outstream.Close();

Response.End();

This code is based on a sample code written by Tommy Wang in a similar thread in this section. By the way I am using .NET 2.0 but I don't think that should matter. Anyways I would appreciate it if you could solve this issue while I am evaluating the products.

Thanks again

Palak

Dear Palak,

1)Which version of .net are you using? I have tested the asp demo in .net Beta2.

2)This is the complete code in my demo, which you can also read in the demo directory.

Response.AddHeader(“content-disposition”,“inline; filename=” + “studentOut.pdf”);
Aspose.Pdf.Kit.Form sf424Form = new Form(Server.MapPath(“sf424_cover.pdf”),Response.OutputStream);

foreach (string field in sf424Form.FieldsNames)

{

sf424Form.FillField(field, “HelloWorld”);

}


Response.End();

Please check it and tell me the result.
Best regards.