iNotes to PDF with DominoPDF

Lotus iNotes is a rich Web client for Lotus Domino e-mail, calendar, and collaboration applications.

As iNotes is web based and makes heavy use of frames and JavaScript certain considerations have to be made when using DominoPDF for PDF conversion via an iNotes implementation.

DominoPDF is iNotes Browser Compatible

iNotes only works with certified browsers and will return a "Lotus iNotes has not been certified to work with this browser." error message if a browser is unrecognised.

iNotes identifies a browser by its User-Agent and an accepted User-Agent can be specified for DominoPDF by using the UserAgent= setting.

For example;

Call DoPDF(sURL, sPDF, "UserAgent=Mozilla/4.0 (compatible* MSIE 7.0* Windows NT 5.2*
.NET CLR 1.1.4322* .NET CLR 2.0.50727*
.NET CLR 3.0.04506.30* .NET CLR 3.0.04506.648* .NET CLR 3.0.4506.2152* .NET CLR 3.5.30729)")

Note: as DominoPDF uses semi-colons (;) for option delimiters the semi-colons in a user agent string can be replaced with asterisks (*) and DominoPDF will substitute semi-colons accordingly.

Now that we've ensured iNotes recognises DominoPDF as a valid browser we need to retrieve the content we want converted to PDF

iFrame, Framesets and JavaScript

As iNotes makes heavy use of framesets, iframes and javascript, we need to access the required content directly.

We could try referencing an ?OpenDocument URL directly, however iNotes will by default wrap any requests in the iNotes framed interface.

Therefore when using the URL interface of DominoPDF all URLs should have the &ui=webmail argument appended to the end.

The &ui=webmail argument tells iNotes to output content in the original Domino webmail UI and provides HTML / DominoPDF compatible output.

For example;

http://localhost/mail/prime.nsf/0/102CE45A2C0C92B5C12576790034301F/?OpenDocument&ui=webmail

In this manner we can return HTML without the iframe, frameset, javascript, etc.

Web Proxies and Authentication

Depending on your iNotes installation and configuration it may be necessary to connect via a Web Proxy.

Fortunately, DominoPDF allows a Proxy Server and authentication to be specified by using the WebProxyServer, WebProxyPort, WebProxyUsername and WebProxyPassword options.

See the sample code below for usage.

iNotes to PDF in Action

Below is a sample LotusScript agent demonstrating how to convert iNotes content to PDF. All Notes documents in a view are converted to a separate PDF file and saved to disk, using the document Universal ID for the filename.

The source code for the agent demonstrated in this tutorial can be downloaded here.

Option Public
Option Declare

Declare Function DoPDF Lib "DOMINOPDF.DLL" (ByVal szInput As String,
ByVal szOutput As String, ByVal szOptions As String) As Long Sub Initialize() Dim oSession As New NotesSession Dim oDB As NotesDatabase Dim oView As NotesView Dim oDoc As NotesDocument Dim sURL As String, sPDF As String, sOptions As String Dim WebProxyServer As String, WebProxyPort As String, WebProxyUser As String,
WebProxyPass As String Dim UserAgent As String Set oDB = oSession.CurrentDatabase Set oView = oDB.GetView("($All)") WebProxyServer = "www3.dominopdf.local" WebProxyPort = "3128" WebProxyUser = "dominopdf\_service_conversion" WebProxyPass = "SECRET" UserAgent="Mozilla/4.0 (compatible* MSIE 7.0* Windows NT 5.2* .NET CLR 1.1.4322*
.NET CLR 2.0.50727* .NET CLR 3.0.04506.30* .NET CLR 3.0.04506.648* .NET CLR 3.0.4506.2152*
.NET CLR 3.5.30729)" sOptions = "WebUsername=Dillon Prime;" sOptions = sOptions & "WebPassword=SECRET;" sOptions = sOptions & "WebProxyServer=" & WebProxyServer & ";" sOptions = sOptions & "WebProxyPort=" & WebProxyPort & ";" sOptions = sOptions & "WebProxyUsername=" & WebProxyUser & ";" sOptions = sOptions & "WebProxyPassword=" & WebProxyPass & ";" sOptions = sOptions & "UserAgent=" & UserAgent & ";" sOptions = sOptions & "LeftMargin=10;TopMargin=10;RightMargin=10;BottomMargin=10;
PageSize=A4;" sOptions = sOptions & "HTMLHeader=<center><strong>" & oDB.Title &
"</strong></center><br/>;" sOptions = sOptions & "HTMLFooter=<center>Page {$PAGE} of {$PAGECOUNT}</center><br/>;" Set oDoc = oView.GetFirstDocument While Not oDoc Is Nothing if oDoc.Form(0) = "Memo" Then sURL = |http://notes.dominopdf.com/mail/prime_d.nsf/0/|
& oDoc.UniversalID & "?OpenDocument&ui=webmail" sPDF = "c:\temp\" + oDoc.UniversalID & ".pdf" Call DoPDF(sURL, sPDF, sOptions) End If Set oDoc = oView.GetNextDocument( oDoc ) Wend End Sub

JoomShaper