0

hi all,

I need help or an idea in asp.net for

1.) Reading all the contents of a page against a url.

2.) Convert all these contents into a pdf file.

Thanks.

3
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by habib55
1

Hi there....,saw ur post and found that the same problem was faced by me too and the solution to such a problem is as follows...

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "cmd")
        {
            string filename=e.CommandArgument.ToString();
            string path=MapPath("~/PDF FOLDER IN WEBSITE/" + filename);
            byte []bts=System.IO.File.ReadAllBytes(path);

            Response.Clear();
            Response.ClearHeaders();

            Response.AddHeader("Content-Type", "Application/pdf");
            Response.AddHeader("Content-Length",bts.Length.ToString());
            Response.AddHeader("Content-Disposition","attachment; filename=" + filename);
            Response.BinaryWrite(bts);
            Response.Flush();
            Response.End();
        }
    }
0

hi KM, thanks for reply; this code works well and download the file from the specified location, but the downloaded file is not opened by adobe reader, it gives an error with the message...
"Adobe Reader could not open 'ASP.pdf' because it is either not a supported file or because the file has been damaged(for example, it was send as an email attachment and wasn't correctly decoded)."

0

yes dnanetwork,

you get me right. above code is working only for the files that are in my web directory....in fact I am searching for a solution that read all the contents against a url in the first step and then convert these contents in to a pdf file and download it into my local drive.

0

my problem has been solved using a third party tool html to pdf converter.

In this link

But I am looking for an open source solution.

0

yes your solution is more perfect. this is what I was looking for, thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.