Code Samples - Document Converter Pro

Example 1: How to convert a file (submitFile method) - ASP

Copy the following ASP scripts (main.asp, checkstatus.asp, error.asp and done.asp) into your web site root.
Download, unzip and copy freeaspupload.asp into your web site root as well.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
   <%@ Language=VBScript %>
   <% 
     option explicit 
     Response.Expires = -1
     Server.ScriptTimeout = 600
   %>
   <!-- #include file="freeaspupload.asp" -->
   <%
   
   ' ****************************************************
   ' Change the value of the variable below to the pathname
   ' of a directory with write permissions, for example "C:\Inetpub\wwwroot"
     Dim uploadsDirVar
     uploadsDirVar = "c:\inetpub\wwwroot\tempUploads"
   ' ****************************************************

     if Request.ServerVariables("REQUEST_METHOD") = "POST" then

       Dim Upload : Set Upload = New FreeASPUpload
       Upload.Save(uploadsDirVar)

       Dim fileKey, fileToConvertT, fileToConvert
       for each fileKey in Upload.UploadedFiles.keys
         fileToConvertT = Upload.UploadedFiles(fileKey).FileName
       next

       Dim DC : Set DC = Server.CreateObject("Neevia.docConverter")

       fileToConvert = uploadsDirVar &"\"& DC.GUID & DC.getExtensionName( fileToConvertT )
       DC.fileCopy uploadsDirVar &"\"& fileToConvertT, fileToConvert
       DC.fileDelete uploadsDirVar &"\"& fileToConvertT

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

       Dim rVal : rVal=DC.SubmitFile(fileToConvert,"")
       DC.fileDelete fileToConvert
       Set DC=Nothing

       If rVal<>0 Then Response.Redirect "error.asp"
       Response.Redirect "checkStatus.asp?docID="& Replace(fileToConvert," ","%20")
     End If

   %>
   <HTML>
   <HEAD>
     <TITLE>Neevia Document Converter Pro sample file</TITLE>
   </HEAD>
   <BODY><CENTER>
   <FORM action="main.asp" method="post" enctype="multipart/form-data">
   Select File: <INPUT type="file" name="myFile"><BR>
   <INPUT type="submit" name="submit" value="Convert">
   </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>