Code Samples - Document Converter Pro

Example 3: How to convert an URL - 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(Request("myUrl"))<>"" Then
             Dim DC = New Neevia.docConverter
             Dim docID = DC.GUID & ".url"

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

             Dim rVal : rVal=DC.submitUrl(Trim(myUrl.Value),docID,"")
             If rVal<>0 Then Response.Redirect("error.aspx")
             Response.Redirect("checkStatus.aspx?docID="& docID)
           End If
         End Sub
      </SCRIPT>
   </HEAD>
   <BODY><CENTER>
   <FORM id="Form1" method="post" runat="server">
   Url to convert:
   <INPUT id="myUrl" type="text" name="myUrl" runat="server"><BR>
   <INPUT id="Submit1" type="submit" value="Convert URL" 
   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
   <%@ Page Language="C#" %>
   <%@ Assembly Name="docConverter" %>
   <%@ Import Namespace="Neevia" %>
   <HTML>
   <HEAD>
      <SCRIPT runat="server">
         void Button1_OnClick(object Source, EventArgs e)
         {
           if (myUrl.Value != "") {
              Neevia.docConverter DC = new Neevia.docConverter();
              string docID = DC.GUID() + ".url";

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

              int rVal;
              rVal = DC.submitURL(myUrl.Value,docID,"");
              if (rVal!=0) Response.Redirect("error.aspx?"+rVal);
              Response.Redirect("checkStatus.aspx?docid="+ docID);
           }
         }
      </SCRIPT>
   </HEAD>
   <BODY><CENTER>
   <FORM id="Form1" method="post" runat="server">
   Url to convert: <INPUT id="myUrl" type="text" name="myUrl" runat="server"><BR>
   <INPUT id="Submit1" type="submit" value="Convert Url" 
   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>