CONTACT Grundprinzip Suchen

+49 661 25100-0support & infohotline
Our Customer
Schwäbisch Hall
Hamburger Sparkasse
Geberit Group
Bischof + Klein
NAeS Consulting S.r.l.
+49 661 25100-0support & infohotline
More Products
Our Partners
Oracle Gold Partner

Basic technical concept

This document describes the basic technical principle of n2pdf Client or n2pdf Server Agent, which is based on an integration via programming.

The technological principle of n2pdf Archive is based on the configuration of Notes documents and works without programming.

The following basic structure and operational sequence defines the procedure that must be taken into account for every PDF creation. This basic principle applies to the integration via LotusScript and Java for n2pdf Client and n2pdf Server Agent.

Note: In the text that follows you will see parentheses with numbers (written in red), which provide a reference to the LotusScript codes listed further on below.

Besides integrating n2pdf using the "n2pdfDef.SCR" file (1), the following steps must also be performed when creating a PDF:

1. Initialize a new PDF File

You have to start a "job" in the main memory of the computer in order to create a PDF file with n2pdf. This is done using the command N2PDFInit (2). This command gives you an ID (Job ID) for the PDF file and generates the needed structures in the computer's memory. You should check this ID for validity (3) (see N2PDFInit), because it makes no sense to continue with the steps to create a PDF if it is not valid. Content and settings for the PDF file can only be defined after this first step has been completed.

2. Determine the PDF file settings

In this next step you should make all the settings (4) for the PDF file using N2PDFSetOption and N2PDFSetGlobalOption. These could include, for example, the security settings for the PDF file, as well as the configurations for automatically launching the viewer or generating the table of contents. Since some settings have a direct impact on the PDF file's content, you should always have made the settings before adding the initial content, e. g. using N2PDFAddContent.

3. Search for Notes content

Script programming must be used to find data for the PDF because n2pdf does not have its own mechanism for doing so. Using "standard" script programming, you will have to search for the documents or fields that you want to add to the PDF file as the main text, header/footer, variable or fields. Normally this will be a loop (5) cycling through various Notes documents, whose content or individual fields you want to depict in a PDF. You can also work cross-database or even with external data sources. The only requirement is that the data can be read out using script commands. Once you have completed this data selection, you can insert the relevant n2pdf commands here as the next step and, in doing so, transfer the data into the PDF file.

4. Add content to the PDF

After you have found the Notes content in the preceding step, you can then use n2pdf commands to add the Notes documents or the individual fields to the PDF document. You can transfer unformatted fields (such as TEXT or NUMBER) or static texts into the PDF file (6), as well as RichText fields and even entire documents. The first step is to define the headers and footers (6) (e. g. N2PDFAddContent) to be used in the PDF file. Then you should define the variables (7) (e. g. N2PDFAddVariable) and finally the PDF file's main text (8) (e. g. N2PDFAddRTContent), such as in a loop through all the documents.

5. Create a PDF file

The last step is the creation of the PDF file (9), i. e. to generate a physical file from the PDF file located in the memory. In this step n2pdf executes all the settings that were made, formats the PDF according to your wishes, applies the structures (e. g. table of contents) to the PDF file and then writes the file from the memory into a physical file. When activating the function N2PDFProcess, you must then specify a file name (10) to be used when the PDF file is created. This concludes the PDF creation and you can then send or e-mail the PDF file, show it with the viewer or file it as a new Notes document. All of LotusScript's features are now available to you, should you want to do any further processing. 
The simple scripts that follow, illustrate all the steps needed to create a PDF file that were just described above. The information enclosed in parentheses in red are references to the individual steps.

6. Script


Sub CreatePDF

Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim view As NotesView

Dim JobID As Long
Dim PDFFilesName As String
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
JobID = N2PDFInit ( 0 ) ' (2) 

If ( JobID >= 0 ) Then ' (3)

      Call N2PDFSetOption ( JobID, N2PDFOPTION_SYSTEM_LAUNCH_VIEWER, "1","") ' (4)
      Call N2PDFAddContent ( JobID, _ ' (6)
      "Plain text header" )
      Call N2PDFAddVariable ( JobID, 0, "CITY", "FULDA" ) ' (7)

      Set doc = collection.GetFirstDocument ' (5) 
      While ( Not ( doc Is Nothing ) ) ' (5)
            Call N2PDFAddRTContent ( JobID, _ ' (8)
            db.Server, _
            db.FilePath, _
            doc.UniversalID, _

            Set doc = collection.GetNextDocument ( doc ) ' (5)
      Wend ' (5)
      PDFFilesName = "C:\Temp\MyPdf.PDF" ' (10)
      Call N2PDFProcess ( JobID, PDFFilesName, 0 ) ' (9)

End if

End Sub