Export to PDF in ASP.NET not working

Export to PDF in ASP.NET not working i am getting an error.Specified argument was out of the range of valid values.
Parameter name: offset . Please help me.

thanks ,

If you’re not using .net framework v4, try upgrading. I think that fixed it for me.

Make sure that xml isn’t null, null value may cause this exception.
btw, you can use more explicit way to generate pdf, it may help in debugging

[code] public void ProcessRequest(HttpContext context)

        var writer = new PDFWriter();
        context.Response.ContentType = writer.ContentType;
        context.Response.HeaderEncoding = System.Text.Encoding.UTF8;
        context.Response.AppendHeader("Content-Disposition", "attachment;filename=grid.pdf");
        context.Response.AppendHeader("Cache-Control", "max-age=0");
        var xml = context.Request.Form["grid_xml"];
        xml = context.Server.UrlDecode(xml);
        var stream = writer.Generate(xml);