2.4.4. Notes Document Collection conversion to folder

Here is a sample that shows how to create separate PDF files from a document collection and save the to a folder. Each PDF represents a single notes document from the collection.
 

/** SWING Software

 * http:// www.swingsoftware.com

 *

 * This example demonstrates how you can convert a notes document collection, using SWING PDF Converter JAVA API,

 * to a set of single PDF documents. Each generated PDF file represents a conversion of a notes document from collection 

 */

package com.swsoftware.pdfc.api.samples;

 

import java.io.File;

 

import com.swsoftware.pdfc.api.*;

import lotus.domino.*;

 

public class DocCollectionConvertToFolder {

      public static void main(String[] args) {

            Session s;

            String server, dbPath, viewName ;

            DocumentCollection ndc = null;

           

            try {

                  NotesThread.sinitThread();

                  // Your notes ID password so a session can be created

                  s = NotesFactory.createSessionWithFullAccess("<YOUR PASSWORD>"); 
                  // the name of the server at which the database that contains the notes document collection being converted resides

                  server = "sw01"
                  //database path to notes database that contains notes document collection

                  dbPath = "Project\\PDF Converter\\Ver 2\\PDFConverter.nsf" ;
                  // Name of the Notes view that we will be used to build a document collection

                  viewName = "Samples"
                  // folder to save generated PDF files

                  File folderPath = new File("C:\\temp");

 

                  SwPDFCreator pdfc = new SwPDFCreator(s);

                 

                  ndc = s.getDatabase(server, dbPath).getView(viewName).getAllDocumentsByKey("");  

                 

                  if (pdfc.init("<LICENSE KEY>")) { // if the license key is valid

 

                        pdfc.processDocCollection(ndc, folderPath);

                        System.out.println("Files saved to: " + folderPath.getPath() );

                  }

                 

                  //Cleanup

                  if (ndc != null) ndc.recycle();

                  ndc = null;

     

                  if (s != null) s.recycle();

                  s = null;

                  pdfc = null;

                 

                 

            } catch (NotesException e) {

                  e.printStackTrace();

            } catch (Exception e) {

                  e.printStackTrace();

            } finally{

                  NotesThread.stermThread();

            }

 

      }

}

 

 
Comments