Jacob Goldhirsch
Jacob Goldhirsch

Reputation: 136

How to generate download .pdf for Internet Explorer?

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)
      Response.Redirect(Server.MapPath("\neshume.pdf"))
      end sub

Upvotes: 2

Views: 444

Answers (2)

Jacob Goldhirsch
Jacob Goldhirsch

Reputation: 136

turns out the problem was not in the code something was wrong with my machine i tested it on a different computer and it worked perfectly

Upvotes: 1

IvanH
IvanH

Reputation: 5139

Replace

Response.Redirect(Server.MapPath("\neshume.pdf"))

with

 Response.Redirect("neshume.pdf")

You can't redirect to full path (Maybe it was accepted by ff because it is running on the same computer).

Upvotes: 0

Related Questions