Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 17-03-2009
Member
 
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.
Reply With Quote
  #2  
Old 17-03-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
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
Reply With Quote
  #3  
Old 18-03-2009
Member
 
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.
Reply With Quote
  #4  
Old 18-03-2009
Member
 
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"));
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 12:44 PM.