DominoPDF from Notes client sample

DominoPDF can be installed on a Domino server but still called from a Notes client.


– DominoPDF software installed on the Domino server

– The Domino HTTP task running on the Domino server

– The aforementioned sample database installed on the Domino server in the \Data directory.

– Sign the agents in the sample database with a Notes ID authorised to execute agents etc.


– An agent will run which executes another agent server side to convert the document to a PDF.

– Once the PDF is created it is attached to a document which is presented to the Notes client. The document has “launch first attachment” enabled so the attached PDF is automatically opened and presented.

How it works

– The “Convert PDF” action button on the Contact document runs 3 agents;

@PostedCommand([ToolsRunMacro]; “RunOnServer1”);
@PostedCommand([ToolsRunMacro]; “RunOnServer2”);
@PostedCommand([ToolsRunMacro]; “PDFRunOnServer”)

The 1st agent “RunOnServer1” simply tries to determine the HTTP domain automatically. In production you probably won’t need this step as you’ll know your domain.

The 2nd agent “RunOnServer2” prompts the user to confirm or update the HTTP domain. In production you probably won’t need this step as you’ll know your domain.

The 3rd agent “PDFRunOnServer” creates a NotesAgent variable in order to run a 4th agent named “DominoPDFAgent”;

Set agent = db.GetAgent(“DominoPDFAgent”)

The 3rd agent then creates a “dummy” document ready to hold the newly created PDF file. The Form used by the document is named “PDFView”.

Set oDoc = New NotesDocument(db) oDoc.Form = “PDFView”
Call oDoc.Save(True, False)

The NoteID of the document is stored so that it can be passed to the 4th agent which will run “server-side”.

paramid = oDoc.Noteid

The 4th agent is then run from the 3rd agent in order to generate the PDF.

If agent.RunOnServer(paramid) = 0 Then

Once the server-side agent has finished execution is returned and we display the document we created (hopefully with the PDF attached) to the user.

Set oDoc = Nothing Set oDoc = db.GetDocumentById(paramid)
Dim ws As New NotesUIWorkspace
If Not oDoc Is Nothing Then
Call ws.EditDocument(False, oDoc, False, “”)
End If

As mentioned above the Form named “PDFView” automatically launched the first attachment. If you don’t wish this to happen simply edit the form properties before running the action.

The server-side agent named “DominoPDFAgent” runs as a normal agent and contains the interface to DominoPDF. It simply buils a URL for the Notes document, passes it to DominoPDF for conversion to PDF and then attaches the PDF to the document which is returned to the user.

v = Evaluate(|@Unique|, oDoc)
sFile = s + “\” + v(0) + “.pdf”
sURL = sHost & sDBPath & |/Contacts/| & oDoc.UniversalID & |?OpenDocument|
Call v.DoPDF(sURL, sFile, “LeftMargin=20;RightMargin=20;TopMargin=20;BottomMargin=20”)
Set PDFDoc = oDB.GetDocumentById(NoteId)
If Not PDFDoc Is Nothing Then
‘Attach PDF to document…
Set rtItem = New NotesRichTextItem(PDFDoc, “Body”)
Call rtItem.embedObject(EMBED_ATTACHMENT,””, sFile)
Call PDFDoc.Save(True, False)
End If
Kill sFile


As you can see the power of Domino and LotusScript together with DominoPDF provides a flexible means of server AND client side PDF creation.

Comments are closed.