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.NET  Print Example 
  • Copy the Document Converter Pro .NET assembly from the c:\program files\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.
Note: Scroll down for the C# samples.

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



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