Brief Description: The HCL Notes Client natively supports exporting only a single open document to PDF at a time. This article introduces a custom LotusScript-based solution that enables batch exporting of multiple Notes documents from a view into individual PDF files. It includes a working code sample, key implementation notes, and links to enhancement requests for future improvements.
Overview : By default, the HCL Notes Client allows exporting only one document at a time to PDF. This is typically done through the File → Export option in the client interface. However, exporting multiple Notes documents from a view or folder directly to PDF is not supported natively. This limitation often poses challenges for users who need to archive or share multiple documents efficiently. To address this, we’ve developed and tested a custom LotusScript solution that automates batch export to PDF using Microsoft Word integration.
Native PDF Export – Current Functionality
To export a single document to PDF manually:
-
Open the desired document.
-
Go to File → Export.
-
In the dialog box, choose the appropriate export options.
-
Select PDF Document as the file type.
-
Enter a filename, choose a location, and click Export.
This method works well for single documents but does not support multi-document export.
Custom Solution for Batch PDF Export
LotusScript-based approach enables exporting multiple documents from a Notes view into PDF files automatically. Each document is converted into an RTF format and then rendered as a PDF using Microsoft Word’s export functionality.
This script can serve as a foundation for your organization’s development teams to customize and enhance further based on business requirements.
Sample LotusScript Code: Batch Export to PDF
’ Constants and API Declarations
Const APIModule = “NNOTES”
Const wdExportFormatPDF = 17
Declare Function MailGetMessageBodyComposite Lib APIModule Alias “MailGetMessageBodyComposite” _
(ByVal hNT As Long, ByVal N As String, ByVal D As String, nD As Long) As Integer
Declare Function ExportRTF Lib “nxrtf” Alias “ExportRTF” _
(ByVal sTempFile As String, ByVal flags As Long, hmod As Long, ByVal altlibrary As String, \_
ByVal sRTFFile As String) As Integer
’ Initialization
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim filePath As String
Dim objWord As Variant
Set objWord = CreateObject("Word.Application")
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
If collection.Count = 0 Then Exit Sub
Set doc = collection.GetFirstDocument()
While Not doc Is Nothing
filePath = "C:\\\\Temp\\\\" & doc.UniversalID
Call ConvertDocumentToPdf(doc, objWord, filePath)
Set doc = collection.GetNextDocument(doc)
Wend
End Sub
’ Convert Notes Document to PDF
Public Sub ConvertDocumentToPdf(doc As NotesDocument, word As Variant, filePath As String)
Dim wordDoc As Variant
Call ConvertDocToRtfFile(doc, filePath & ".rtf")
Set wordDoc = word.Documents.Open(filePath & ".rtf", False, True, False)
Call wordDoc.ExportAsFixedFormat(filePath, wdExportFormatPDF, False, 0, 0, 0, 9999999, 0, \True, True, 1, True, True, True, Nothing)
Call wordDoc.Close(0)
Kill filePath & ".rtf"
End Sub
’ Convert RichText to RTF File
Public Sub ConvertItemToRtfFile(item As NotesRichTextItem, filePath As String)
Dim fileSize As Long
Dim doc As NotesDocument
Set doc = item.Parent
Call MailGetMessageBodyComposite(doc.Handle, "Body", filePath & ".cd", fileSize)
Call ExportRTF(filePath & ".cd", 0, 0, "", filePath)
Kill filePath & ".cd"
End Sub
’ Render Notes Document to RTF File
Public Sub ConvertDocToRtfFile(doc As NotesDocument, filePath As String)
Dim tempDoc As NotesDocument
Dim tempRti As NotesRichTextItem
Set tempDoc = doc.ParentDatabase.CreateDocument()
Set tempRti = tempDoc.CreateRichTextItem("Body")
Call doc.RenderToRTItem(tempRti)
Call ConvertItemToRtfFile(tempRti, filePath)
End Sub
Disclaimer
This script is provided as a sample only and must be adapted for your organization’s environment and requirements. It has been tested in a controlled test setup. Always validate and review it with your Quality Assurance and Development teams before deploying it in production.
Enhancement Requests
To improve Notes Client’s built-in PDF export capabilities, enhancement requests have been submitted to HCL. You can view and support these ideas on the HCL Domino Ideas Portal:
-
Allow export to PDF batch of documents
NTS-I-2202 -
LotusScript method for export document as PDF
DOMINO-I-1222
Conclusion : While the current HCL Notes Client supports only single-document PDF export, the custom LotusScript solution described above provides a workable and extensible workaround for batch exporting Notes documents to PDF.
This approach can save time, improve consistency, and streamline workflows for teams that frequently handle document exports.
We encourage users and developers to contribute feedback or vote for the enhancement requests on the Domino Ideas Portal to help shape future product improvements.