Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Rewrite simple JScript code to VB.NET

Posted on 2007-11-20
6
Medium Priority
?
429 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 2000 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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 …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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