Neevia Technology Sites:   www.neevia.com  |  docuPub.com  |  www.neeviaPDF.com
:: Home :: Products :: Technical Support :: About Us :: Contact Us
Technical support > Neevia Document Converter Pro code samples
Example 1: How to convert a file (submitFile method) from ASP  Print Example 
Note: Copy these 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;

Main.asp
<%@ 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
<%
    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
<HTML>
<BODY><BR><BR><CENTER>
<H1>THERE WAS AN ERROR CONVERTING THE DOCUMENT</H1>
</BODY>
</HTML>
done.asp
<HTML>
<BODY topMargin="0" leftMargin="0" scroll="no">
<EMBED src="<%= Request("docID") & ".pdf"%>" width="100%" height="100%" fullscreen="yes">
</BODY>
</HTML>



Copyright © 1999-2016 Neevia Technology. All Rights Reserved. Home | Products | Technical Support | About Us | Contact Us