2.4.3. Notes Document Collection conversion from file

This example shows how to load a collection of notes documents from a text file and convert it to PDF package.
 

/** SWING Software 2010

 * http://www.swingsoftware.com

 *

 * This sample demonstrates how you can use SWING PDF Converter JAVA API

 * to convert a Lotus Notes Document collection specified by a file resource to a single PDF file called PDF Package or PDF portfolio.

 * The resource file is a simple file which has noteId of each document written to a new line.

 */

 

package com.swsoftware.pdfc.api.samples;

 

import com.swsoftware.pdfc.api.*;

import lotus.domino.*;

 

public class DocCollectionConvertFromFile {

 

      public static void main(String[] args) {

           

            Session s;

            String server, dbPath, viewName ;

           

            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 document collection being converted resides

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

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

                  viewName = "Samples"
                  //a path to the file that contains notes ID's of documents being converted. Each note id is in a separate line

                  String filePath = "C:\\test.txt" ;

 

                  SwPDFCreator pdfc = new SwPDFCreator(s);

                  SwPDFDocument pdfDoc ;

                 

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

                              pdfDoc =  pdfc.processDocCollectionFromFile(filePath, server, dbPath, viewName);

                              System.out.println("File saved to: " + pdfDoc.SaveToFile("C:\\result.pdf"));

                  }

                 

                  //Cleanup

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

                  s = null;

                  pdfc = null;

                  pdfDoc = null;

                 

            } catch (NotesException e) {

                  e.printStackTrace();

            } catch (Exception e) {

                  e.printStackTrace();

            } finally{

                  NotesThread.stermThread();

            }

      }

}

 

 
 
 
Comments