Click here to Skip to main content
15,746,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm working on a website in which a user enters a name and then presses a button that prompts the server to create a pdf file according to the information provided, and then sends the file to the user.

I'm testing the website on my laptop without IIS.

I needed the pdf to be hebrew and couldn't find a pdfwrite with vb on hebrew; instead, I create a MS Word document and then convert it to pdf using the code below.

This works fine on Firefox, Chrome, and Safari, but on Internet Explorer the page disconnects before the download. It disconnects when the create word statement is executed.

Can anyone help me?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles      Button1.Click
      Dim strname As String
      strname = TextBox1.Text.Trim

      Dim oword As New word.Application
      Dim odoc As New word.Document
      oword = CreateObject("word.Application")

      odoc = oword.Documents.Add("C:\documents\tamp.dotx")

      odoc.Bookmarks.Item("name1").Range.Text = strname
      odoc.Bookmarks.Item("name2").Range.Text = strname
      odoc.Bookmarks.Item("name3").Range.Text = strname
      odoc.Bookmarks.Item("name4").Range.Text = strname
      odoc.Bookmarks.Item("name5").Range.Text = strname
      odoc.Bookmarks.Item("name6").Range.Text = strname

      odoc.ExportAsFixedFormat(Server.MapPath("\neshume.pdf"), 17)
      end sub
Ed Nutting 23-May-12 14:03pm    
Given that your server side code cannot possibly be interacting directly with IE and telling it to close, I would suggest that your server code is fine, as it works with other browsers. The issue may be that Internet Explorer (possibly) uses a shorter request time-out? If so you will need to investigate how to check what the time-out is and how to change it - I'm pretty sure you can. Either way your server side code is not able to effect IE directly so if it works in one browser and not in another then it's not your file creation code that's going wrong.

Hope this helps,

1 solution

you redirect to on which page which have iframe control. after that on this page you set iframe source the pdf file path.

in aspx page:-
<div >
     <iframe id="IFrame1" runat="server" frameborder="1" height="500" scrolling="auto"  width="100%" >

in .cs create following function:-
private void PdfFile(string FileNameWithPath)
IFrame1.Attributes["src"] = FileNameWithPath;
Share this answer
jacobgold 24-May-12 12:40pm    
thanks for your help but if possible can you write the code with vb i'm not familiar with c

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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