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, sHost As String, sAttach As String
Dim oAttach As NotesEmbeddedObject
Set oDB = oSession.CurrentDatabase
Dim ServerName As New NotesName(oDB.Server)
If oSession.IsOnServer Then
sHost = "http://" & ServerName.Common & "/"
Else
sHost = "http://localhost/"
End If
Set oView = oDB.GetView("($All)")
Set oDoc = oView.GetFirstDocument
While Not oDoc Is Nothing
If oDoc.Form(0) = "Memo" Then
sURL = sHost & oDB.FileName & "/" & oView.Name & "/" & oDoc.UniversalID & "?OpenDocument"
sPDF = oDoc.UniversalID & ".pdf"
sAttach = ""
Forall i In oDoc.Items
If i.Type = Attachment Then
Set oAttach = oDoc.GetAttachment(i.Values(0))
Call oAttach.ExtractFile(oAttach.Name)
sAttach = sAttach & oAttach.Name & "*"
End If
End Forall
sAttach = Mid$(sAttach, 1, Len(sAttach) - 1)
sOptions = "LeftMargin=10;TopMargin=10;PageSize=A4;EmbedFiles=" & sAttach
Call DoPDF(sURL, sPDF, sOptions)
End If
Set oDoc = oView.GetNextDocument( oDoc )
Wend
End Sub