Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
dim path as string        
Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
 path=server.mappath("test.pdf")
        Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream("C:\sample.pdf", FileMode.Create))
 
i Alo Use these
        'PdfWriter.GetInstance(doc, New FileStream(path, FileMode.Create))

And I Also Used this 
'PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + "\sample.pdf", FileMode.Create))

       

        doc.Open()
        Dim table = New PdfPTable(2)
 
        Dim cell As New PdfPCell
 
        cell = New PdfPCell(New Phrase("THIS IS CONTACT INFORATION WHICH IS FIELD BY USER"))
        cell.Colspan = 2
 
        cell.HorizontalAlignment = 1
 

        table.AddCell(cell)
 
        table.AddCell("First Name:")
 
        table.AddCell(txtfname.Text)
 
        table.AddCell("Last Name: ")
        table.AddCell(txtlname.Text)
 
        table.AddCell("Address:")
        table.AddCell(txtaddress.Text)
 
        table.AddCell("Apt#:")
        table.AddCell(txtapt.Text)
 
        table.AddCell("Postal Code: ")
        table.AddCell(txtpostalcod.Text)
 
        table.AddCell("City: ")
        table.AddCell(txtcity.Text)
 
        table.AddCell("*Province:")
        table.AddCell(DropDownList1.Text)
 
        table.AddCell("Country: ")
        table.AddCell(DropDownList2.Text)
 
        table.AddCell("Phone: ")
        table.AddCell(txtphone.Text & vbNewLine & s)
 
        table.AddCell("E-mail Address:")
        table.AddCell(txtemail.Text)
 
        table.AddCell("Campus of Interest: ")
        table.AddCell(DropDownList3.Text)
 
        table.AddCell("Program of Interest:")
        table.AddCell(DropDownList4.Text)
 

        table.AddCell("How did you hear about us?: ")
        table.AddCell(DropDownList5.Text)
 
        table.AddCell("CONTACT FORM FIELD DATE AND TIME")
        table.AddCell(Date.Now)
 
        doc.Add(table)


but when i click so a error is access denied
Posted
Updated 11-Sep-11 9:05am
v2
Comments
Simon Bang Terkildsen 11-Sep-11 15:28pm    
AA problem? I though AA is the possible solution to a problem :P

You need to set necessary access permissions in your IIS configuration for your website.

Refer this for more info:

http://www.asp.net/learn/whitepapers/denied-access-to-iis-directories[^]

hope it helps :)
 
Share this answer
 
Comments
irfanansari 11-Sep-11 15:15pm    
You Told Me Very Good Ans Just Tell Me That How I Can These Setting On My Domain As I Puchared As www.etc.com
Simon Bang Terkildsen 11-Sep-11 15:33pm    
Have you read the page Uday link too?
Simon Bang Terkildsen 11-Sep-11 15:32pm    
+5 good link
This is working fine in Visual Studio but not in Localhost won't work. So first check the reason behind that, then you will also able to understand for your domain as well.
When your application is running from Visual Studio, your application having sufficient privilege to write of your hard drive, hence your application is running fine as it is able to create file.
Now when you are hosting the files in IIS, Application pool comes into the picture.
Application pool having 3 types of identity.
1. NetworkService<br />
2. Local Service<br />
3. Local System


"Network Service" is the default Identify. "defaultappPool" is also runs under the "Network Service" Identity
By default your application pool runs on "NetworkService" account which has very minimum access to your drive, only read. So, When your application trying to write a file on drive, its getting access denied.
The solution, is give the Application Pool with "LocalSystem" privilege or Run your application pool with the account who have write access on drive.
So, create a new Application Pool for your application, Change the Identity to "LocalSystem" or Run on High Privilege account.

To know more about "Application Pool and the Identity" Read this section from one of my article
Beginner's Guide : Exploring IIS 6.0 With ASP.NET [^][^]

In your hosting env, check the privilege to account on which your Application is running on.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900