refer2pdf.aspx using VB.NET
We kept the following code of the file refer2pdf.aspx (VB.NET) as simple as possible.
You may use this code without any limitations. If you write it in other languages please
let us know so we can provide the code to other customers for download.
Please note: The Parameter Print=1 is just an example and may be different for your
application or is even not required.
<%@ Page Language ="VB" Debug="true" %>
<script runat="Server" Language ="VB">
' Be sure to set debug to false when useres start using the service
Sub Page_Load()
' Defining Variables
' ------------------------------------------------
Dim strReferer As String = Request.ServerVariables("HTTP_REFERER")
Dim strGeneratorURL As String = "http://html2pdf.adfinis.com/render.php?URL="
Dim strGeneratorURLParameters As String
'Build the URL with Parameters to call the renderer
' ------------------------------------------------
If Instr(strReferer,"?") = 0 then
If right(strReferer,1) = "/" then
strGeneratorURLParameters = strReferer & "?Print=1"
Else
strGeneratorURLParameters = strReferer & "/?Print=1"
End if
Else
strGeneratorURLParameters = strReferer & "&Print=1"
End if
' Encode the Parameters to prevent errors
strGeneratorURLParameters = Server.URLEncode(strGeneratorURLParameters)
' If Parameters are o.k. redirect to the renderer
' -----------------------------------------------
If Instr(strReferer,"http") = 0 Then
response.write("Sorry, no valid referer was provided.")
Else
response.redirect(strGeneratorURL & strGeneratorURLParameters)
End if
End Sub
</script>
This article was contributed by Markus Schneider and he can be reached
at schneider@mms.ch
Back to Article list