Navigation:  DominoPDF > Sample Code > Calculating URL's >

DominoPDF - Calculating Server Host

Previous pageReturn to chapter overviewNext page

Many times the URL which is passed to DominoPDF needs to be "built" in LotusScript code.

The examples below demonstrate techniques for meeting this requirement.

Calculating server host

The host for the URL usually refers to the local Domino server where DominoPDF is installed. Therefore localhost or the server name / IP address can simply be referenced in the LotusScript code.

Alternatively the NotesSession.IsOnServer property can be used to determine where the agent is running and build the host accordingly. The NotesName class is also used to return the common name of the server.

For example;

Dim session as New NotesSession

Dim oDB as NotesDatabase

Set oDB = session.CurrentDatabase

Dim ServerName As New NotesName(oDB.Server)

If session.IsOnServer Then

sHost = "http://" & ServerName.Common & "/"

Else

sHost = "http://localhost/"

End If

If DominoPDF is executed as a result of an agent POST then the HTTP_REFERER query value can be used to obtain the exact host address.

If oDoc.HTTP_REFERER(0) <> "" Then

sHost = oDoc.HTTP_REFERER(0)

sHost = ReplaceSubString(sHost, |/MainWeb?openform|, "") 'Replace any parameters

Else

If session.IsOnServer Then

sHost = "http://" & ServerName.Common & "/"

Else

sHost = "http://localhost/"

End If

End If