Results 1 to 4 of 4

Thread: How to convert .aspx to pdf

  1. #1
    Join Date
    Dec 2008
    Posts
    165

    How to convert .aspx to pdf

    Hi friends,

    I have a .aspx page where user enter all his details,On runtime all the information of a user (personal info, service info, business info....) loaded in the page. But i want to see those information in pdf file format.i don't know the code for that can anyone tell me the code please.It would be great for me.I try to find it over internet but of no use.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to convert .aspx to pdf

    Try to use this code hope it will work for you.

    HTML Code:
     Private Sub function1()
    
            Dim mydoc As iTextSharp.text.Document
    
            Dim str As String
    
            Dim a As PdfWriter
    
            Dim ms As FileStream
    
           
            cmdSave.Visible = False
    
            str = Server.MapPath("bin\1.pdf")
    
            mydoc = New iTextSharp.text.Document
    
            If File.Exists(str) Then File.Delete(str)
    
            ms = New FileStream(str, FileMode.OpenOrCreate)
    
            mydoc.Open()
    
            mydoc.Add(New Paragraph("123"))
    
            mydoc.Add(New Paragraph("123"))
    
            mydoc.Add(New iTextSharp.text.Jpeg(Server.MapPath("images\Usergallery\1\1_3_2_Ash_ap.jpg")))
    
            mydoc.Add(New Annotation("123", "123"))
    
            mydoc.Close()
    
        End Sub

  3. #3
    Join Date
    Dec 2008
    Posts
    165

    Re: How to convert .aspx to pdf

    Thanks for replying me i try to do it but it's not working for me.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to convert .aspx to pdf

    Try to use TextSharp .Following are the codes for it.

    HTML Code:
    protected void btn_PDF_Click(object sender, EventArgs e)
    {
    Uri strurl = Request.Url;
    string url = strurl.ToString();
    string text = GetPageText(url);
    string filepath = Server.MapPath("image\\test.htm"); //"c:\\test.htm";
    StreamWriter writer = new StreamWriter(filepath);
    writer.Write(text);
    writer.Close();
    
    htmltopdf();
    }
    
    public string GetPageText(string url)
    {
    string htmlText = string.Empty;
    string FILE_NAME = Server.MapPath("image\\test.xml"); //"c:\\test.xml";
    
    try
    {
    
    HttpWebRequest requestIP = (HttpWebRequest)WebRequest.Create(url);
    requestIP.Timeout = 10000;
    using (HttpWebResponse responseIP = (HttpWebResponse)requestIP.GetResponse())
    {
    using (Stream streamIP = responseIP.GetResponseStream())
    {
    using (StreamReader readerText = new StreamReader(streamIP))
    {
    htmlText = readerText.ReadToEnd();
    string text = htmlText;
    
    StreamWriter writer = new StreamWriter( FILE_NAME);
    writer.Write(text);
    writer.Close();
    }
    }
    }
    }
    finally
    {
    }
    return htmlText;
    }
    
    
    public void htmltopdf()
    {
    Document doc = new Document();
    PdfWriter.GetInstance(doc, new FileStream(Server.MapPath("image\\test.pdf"), System.IO.FileMode.Create));
    
    HtmlParser.Parse(doc, Server.MapPath("image\\test.htm"));
    
    
    if (File.Exists(Server.MapPath("image\\test.htm")))
    File.Delete(Server.MapPath("image\\test.htm"));
    if (File.Exists(Server.MapPath("image\\test.xml")))
    File.Delete(Server.MapPath("image\\test.xml"));
    }

Similar Threads

  1. What do you mean by track.aspx on Apple Safari?
    By Ro-Man in forum Technology & Internet
    Replies: 5
    Last Post: 17-06-2011, 10:33 AM
  2. Can Any one Help me to Publish a aspx code to website
    By aska121 in forum Technology & Internet
    Replies: 1
    Last Post: 18-11-2010, 05:07 PM
  3. Can’t delete trojan aspx.js.win32
    By Mohegan in forum Networking & Security
    Replies: 3
    Last Post: 20-07-2010, 06:22 AM
  4. How to open file with extension ASPX
    By Centaurs in forum Software Development
    Replies: 5
    Last Post: 01-04-2010, 09:01 AM
  5. Developing .cs from .aspx
    By Balamohan in forum Software Development
    Replies: 3
    Last Post: 04-12-2009, 06:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,846,024.08166 seconds with 16 queries