Code Samples - Document Converter Pro

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

  • Copy the Document Converter Pro .NET assembly from the c:\program files (x86)\neevia.com\docConverterPro\.Net\ folder into your web site bin folder;
  • Copy the following ASPX scripts (main.aspx, checkstatus.aspx, error.aspx and done.aspx) into your web site root.

Scroll down for the C# samples

Visual Basic


main.aspx 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
   <%@ Page Language="VB" %>
   <HTML>
   <HEAD>
     <SCRIPT runat="server">
       Sub Button1_OnClick(Source As Object, e As EventArgs)
         if Trim(myFile.PostedFile.FileName)<>"" then
           Dim DC = New Neevia.docConverter
           Dim docID = DC.GUID
           Dim tempFile = docID & System.IO.Path.GetExtension(myFile.PostedFile.FileName)
           myFile.PostedFile.SaveAs(Server.MapPath(".") &"\"& tempFile)

           DC.setParameter("DocumentOutputFolder", Server.MapPath("."))
           Dim rVal = DC.submitFile(Server.MapPath(".") &"\"& tempFile,"")
           System.IO.File.Delete(Server.MapPath(".") &"\"& tempFile)
           If rVal<>0 Then Response.Redirect("error.aspx")
           Response.Redirect("checkStatus.aspx?docID="& tempFile)
         End If
       End Sub
     </SCRIPT>
   </HEAD>
   <BODY><CENTER>
   <BR><BR><BR>
   <FORM id="Form1" enctype="multipart/form-data" method="post" runat="server">
   Select File: <INPUT id="myFile" type="file" name="myFile" runat="server"><BR>
   <INPUT id="Submit1" type="submit" value="Upload & Convert" 
   OnServerClick="Button1_OnClick" name="Submit1" runat="server">
   </FORM>
   </BODY>
   </HTML>

checkstatus.aspx Copy 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
   <%@ Page Language="VB" %>
   <HTML>
   <HEAD>
     <SCRIPT runat="server">
        Sub Page_Load(Source As Object, e As EventArgs)
          Dim DC = New Neevia.docConverter
          DC.setParameter("DocumentOutputFolder", Server.MapPath("."))
          Dim docID : docID=Request("docID")
          Dim rVal : rVal=DC.checkStatus(docID,"")
          If rVal=0 Then 
            Response.Redirect("done.aspx?docID=" & System.IO.Path.ChangeExtension(docID,".pdf"))
          End If    
          If rVal<>2 Then Response.Redirect("error.aspx")
        End Sub
     </SCRIPT>
     <TITLE>Neevia.com</TITLE>
     <META HTTP-EQUIV="refresh" CONTENT="2">
   </HEAD>
   <BODY><BR><BR><CENTER>
   <H1>CONVERTING - PLEASE WAIT!!!</H1>
   </BODY>
   </HTML>

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

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

VC#


main.aspx 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
   <%@ Page Language="C#" %>
   <%@ Assembly Name = "docConverter" %>
   <%@ Import Namespace = "Neevia" %>
   <HTML>
   <HEAD>
      <SCRIPT runat="server">
         void Button1_OnClick(object Source, EventArgs e)
         {
           if (myFile.PostedFile != null)
           {
             Neevia.docConverter DC = new Neevia.docConverter();
             string docID = DC.GUID();
             string tempFile = docID + System.IO.Path.GetExtension(myFile.PostedFile.FileName);
             myFile.PostedFile.SaveAs(Server.MapPath(".") +"\\"+ tempFile);
             DC.setParameter("DocumentOutputFolder", Server.MapPath("."));
             int rVal;
             rVal=DC.submitFile(Server.MapPath(".") +"\\"+ tempFile,"");
             System.IO.File.Delete(Server.MapPath(".") +"\\"+ tempFile);
             if (rVal!=0) Response.Redirect("error.aspx?"+rVal);
             Response.Redirect("checkStatus.aspx?docid="+ tempFile);
           }
         }
      </SCRIPT>
   </HEAD>
   <BODY><CENTER>
   <BR><BR><BR>
   <FORM id="Form1" enctype="multipart/form-data" method="post" runat="server">
   Select File: <INPUT id="myFile" type="file" name="myFile" runat="server"><BR>
   <INPUT id="Submit1" type="submit" value="Upload & Convert" 
   OnServerClick="Button1_OnClick" name="Submit1" runat="server">
   </FORM>
   </BODY>
   </HTML>

checkstatus.aspx 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
   <%@ Page Language="C#" %>
   <%@ Assembly Name = "docConverter" %>
   <%@ Import Namespace = "Neevia" %>
   <HTML>
   <HEAD>
     <SCRIPT runat="server">
        void Page_Load(object Source, EventArgs e)
        {
          Neevia.docConverter DC = new Neevia.docConverter();
          DC.setParameter("DocumentOutputFolder", Server.MapPath("."));
          string docID = Request.QueryString.Get("docid");
          int rVal = DC.checkStatus(docID,"");
          if (rVal==0){
            Response.Redirect("done.aspx?docID=" + System.IO.Path.ChangeExtension(docID,".pdf"));
          }
          if (rVal !=2 ) Response.Redirect("error.aspx?"+docID);
        }
     </SCRIPT>
     <TITLE>Neevia.com</TITLE>
     <META HTTP-EQUIV="refresh" CONTENT="2">
   </HEAD>
   <BODY><BR><BR><CENTER>
   <H1>CONVERTING - PLEASE WAIT!!!</H1>
   </BODY>
   </HTML>

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

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