0

I am developing a web application in which the clients wants to generate a pdf of the current page.
I google a lot about this but didn't find any suitable solution to the problem.

Many dlls and classes are available but no one is working.

The main problem is that the page for which I want to generate PDF is secure and when I give the URL of the page, it will generate the PDF of Login page. Please sort out my problem.

With Regards,
Mandeep Singh

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by mandeep.laha
0

Thanks for your kind reply.

Detailed Info:
There is a Membership Security on each page as if any body make a direct request to the Secure Pages it will be redirected to the Login Page.

CODE SNIPPET

protected void btnCreatePDF_Click(object sender, ImageClickEventArgs e)
        {
            Document doc1 = new Document();

            string path = Server.MapPath("PDF");
            PdfWriter.GetInstance(doc1, new FileStream(path + "/Doc3.pdf", FileMode.Create));

            doc1.Open();

            doc1.Add(new Paragraph(GetHtmlPage()));

            doc1.Close();
}

private string GetHtmlPage()
        {

            String strResult;
            WebResponse objResponse;
            WebRequest objRequest = HttpWebRequest.Create(Request.Url.AbsoluteUri);
            objResponse = objRequest.GetResponse();
            using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
            {
                strResult = sr.ReadToEnd();
                sr.Close();
            }
      }

Edited by mike_2000_17: Fixed formatting

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.