Code Samples - Document Converter Pro

Example 3: How to convert an URL - ASP

Copy the following ASP scripts (main.asp, checkstatus.asp, error.asp and done.asp) into your web site root.

main.asp Copy 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
   <%
     IF Trim(Request("urlToConvert"))<>"" Then
       Dim DC : Set DC = Server.CreateObject("Neevia.docConverter")

       DC.setParameter "DocumentOutputFormat", "PDF"
       DC.setParameter "DocumentOutputFolder", Server.MapPath(".")
       DC.setParameter "PDFAutoRotatePage", "All"

       Dim docID : docID = DC.GUID & ".url"
       Dim rVal : rVal=DC.submitURL(Trim(Request("urlToConvert")),docID,"")
       Set DC=Nothing
       If rVal<>0 Then Response.Redirect "error.asp"
       Response.Redirect "checkStatus.asp?docID="& docID
     End If
   %>
   <HTML>
   <HEAD>
    <TITLE>Neevia Document Converter Pro sample file</TITLE>
   </HEAD>
   <BODY><CENTER>
   <FORM action="main.asp">
   URL to convert:
   <INPUT type="input" name="urlToConvert" value="http://neevia.com"><BR>
   <INPUT type="submit" name="submit" value="Convert URL">
   </FORM>
   </BODY>
   </HTML>

checkstatus.asp Copy 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
   <%
       Dim DC : Set DC = Server.CreateObject("Neevia.docConverter")

       DC.setParameter "DocumentOutputFormat", "PDF"
       DC.setParameter "DocumentOutputFolder", Server.MapPath(".")

       Dim rVal : rVal=DC.checkStatus(Request("docID"),"")
       Set DC=Nothing

       If rVal=0 Then 
         Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
         Dim docID : docID=fso.GetBaseName(Request("docID"))
         docID=Replace(docID," ","%20")
         Response.Redirect "done.asp?docID="& docID
       End If    

       If rVal<>2 Then Response.Redirect "error.asp"
   %>
   <HTML>
   <HEAD>
    <TITLE>Neevia.com</TITLE>
    <META HTTP-EQUIV="refresh" CONTENT="2">
   </HEAD>
   <BODY><BR><BR><CENTER>
   <H1>CONVERTING - PLEASE WAIT!!!</H1>
   </BODY>
   </HTML>

error.asp Copy 

1
2
3
4
5
   <HTML>
   <BODY><BR><BR><CENTER>
   <H1>THERE WAS AN ERROR CONVERTING THE DOCUMENT</H1>
   </BODY>
   </HTML>

done.asp Copy 

1
2
3
4
5
   <HTML>
   <BODY topMargin="0" leftMargin="0" scroll="no">
   <EMBED src="<%= Request("docID") & ".pdf"%>" width="100%" height="100%" fullscreen="yes">
   </BODY>
   </HTML>