Solved

Rewrite simple JScript code to VB.NET

Posted on 2007-11-20
6
424 Views
Last Modified: 2011-10-03
Can someone please re-write for me this simple JScript code to VB.NET.
The code is basically generate a PDF file and display it in client's web browser.

Thanks

<%@ LANGUAGE=JScript %>
<%
//create the pdf
shl = Server.CreateObject("WScript.Shell")
argument = "\"c:\\omniformat\\html2pdf995.exe\" "
//argument = argument + "\"c:\\pdf995\\readme.html\" "
argument = argument + "\"www.epad995.com\" "
argument = argument + "\"c:\\inetpub\\wwwroot\\out.pdf\""
//run html2pdf995 and wait for it to return
shl .Run(argument, 0 , 1 )

//display the pdf
Response.ClearContent
Response.ContentType = "application/pdf"
Response.Redirect ("http://localhost/out.pdf")
%>

0
Comment
Question by:Terrace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20325965
In .NET you use the Process and ProcessStartInfo classes to run a program.

Clearing the content and setting the content type before calling Response.Redirect has no effect at all. That's what you do if you send the data back in the same response using Response.BinaryWrite or Response.WriteFile.
Dim program As String = "c:\omniformat\html2pdf995.exe"
Dim argument As String = """c:\pdf995\readme.html"" ""www.epad995.com"" ""c:\inetpub\wwwroot\out.pdf"""
 
Dim process As New System.Diagnostics.Process
process.StartInfo = New System.Diagnostics.ProcessStartInfo(program, argument)
process.Start()
process.WaitForExit()
 
Response.Redirect("http://localhost/out.pdf")

Open in new window

0
 

Author Comment

by:Terrace
ID: 20328666
Thank you very much.
I played with this code and made some modifications to accomodate paths and other stuff.
This is all new to me, but hopefully will make it work.
As a test, I created a button on my web form and inserted your code such as

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim program As String = "c:\ProgramFiles\omniformat\html2pdf995.exe"
        Dim argument As String = """c:\ProgramFiles\pdf995\readme.html"" ""c:\TestWebLock\PDF\30222.pdf"" ""c:\TestWebLock\PDF\out.pdf"""
        Dim process As New System.Diagnostics.Process
        process.StartInfo = New System.Diagnostics.ProcessStartInfo(program, argument)
        process.Start()
        process.WaitForExit()
       Response.Redirect("http://192.24.251.26:8081/PDF/out.pdf")
    End Sub

When I click on the button, I expect to have the out.pdf file displayed in browser window.

I know this is out of scope of this question, but maybe you have some idea or can help me troubleshoot it.

P.S. you already deserved the points, so this is just your good will.

Thanks. Happy Thanksgiving
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20331672
Perhaps I can help you troubleshoot it if you tell me what the trouble is...
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20452826
Checking back... you never answered what the the trouble was?
0
 

Author Comment

by:Terrace
ID: 20495205
I got too busy with this project.
Your code helped me to get started, so I thank you for that.
0
 

Author Comment

by:Terrace
ID: 20495220
This is how this code looks like in VB.NET
Dim program As String = "C:\Program Files\omniformat\omniformat.exe"
 
Dim argument As String = Chr(34) & "C:\TestWebLock\Rates\" + strTransID & Chr(34) & " " & Chr(34) & "PDF" & Chr(34)
 
Dim process As New System.Diagnostics.Process
process.StartInfo = New System.Diagnostics.ProcessStartInfo(program, argument)
process.Start()
process.WaitForExit()

Open in new window

0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question