Hello!

I have a small problem in asp.net ... I wish to create a pdf file and write text entered into a textbox into it using asp.net. The following lines of code work properly for creating and opening pdf files

Dim fs As FileStream = File.Create(Server.MapPath("files/newfile.doc"))
        Dim sw As New StreamWriter(fs)
        sw.Write(TextBox1.Text)
        sw.Close()
        fs.Close()

The only problem is that one I navigate to the folder and open the pdf file, it displays a message saying that the file is corrupt. I am able to open it normally using notepad, but not using pdf.

Can anyone help me out?????

Thanks a lot in advance!

you are creating a file with a pdf extension, not an actual pdf file

you need to use a either a converter or a printer to create the file

i normally use pdf995.com

This article has been dead for over six months. Start a new discussion instead.