Printing all documents is relatively straightforward: I use the GetFirstDocument and GetNextDocument methods of the NotesView class combined with a Do Loop to cycle through all documents in the view.
Whether printing all or selected documents, the agent builds and returns an HTML table containing the view column data of the documents. It uses the NotesViewColumn Title property to build a row of column titles (getColumnTitles function) and the NotesDocument ColumnValues property to populate subsequent rows of the table (getColumnValues function).
The code below is based on a scenario in which a user can print a view that has been embedded on a page.
Although the code here is set to print a single view, it would not take many revisions to make it possible for the user to select the view they wanted to print.