Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET PDF VB.NET Word
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
Posted 23-May-12 7:43am
Comments
Ed Nutting at 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,
Ed

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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%" >
     <p>&nsbp;</p>
     </iframe>
</div>
 

in .cs create following function:-
private void PdfFile(string FileNameWithPath)
{
IFrame1.Attributes["src"] = FileNameWithPath;
}
  Permalink  
Comments
jacobgold at 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
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 24 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100