# View to PDF package

Provided code sample collects all View documents in empty NotesDocumentCollection and convert's them to PDF:

```
 Dim s As New NotesSession
 Dim db As NotesDatabase
 Dim view As NotesView
 Dim dc As NotesDocumentCollection
 Dim doc As NotesDocument
 Dim swPDF As SwPDFCreator
 dim swPDFDoc As SwPDFDocument

 On Error GoTo Ooops
 
 Set db = s.CurrentDatabase
 ' Set the Notes view name here
 Set view = db.Getview("<YOUR VIEW>")
 
 Set swPDF = New SwPDFCreator()
 swPDF.Init("<PDF Converter License key>") 
 swPDF.PDFSettings.useLowLevelRenderer = True

 'Let's create empty notes document collection and fill it with all view documents (THIS WILL WORK ON Lotus Notes 8+)
 Set dc = db.CreateDocumentCollection
 Set doc = view.Getfirstdocument()
 
 While Not doc Is Nothing
 call dc.Adddocument(doc)
 Set doc = view.Getnextdocument(doc)
 Wend
 '-------------------------------------------------------------------------------
 
 'Init view conversion
 Set swPDFDoc = swPDF.ProcessDocCollection(dc, "<YOUR VIEW>")

 MsgBox "Doc processed"
 Call swPDFDoc.SaveToFile("C:\temp\Test.pdf")

 Exit function

Ooops:
 MsgBox "Error Code:" & CStr(Err()) & " on line " & Erl & " Description: " & Error
 Exit function
```

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.swingsoftware.com/pdf-converter-for-notes/for-developers/lotusscript-code-samples/view-to-pdf-package.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
