Monday, September 7, 2009

Agent to Export to PDF in Lotus Notes

A JAVA Agent which exports the values to a PDF file.

After you run the agent please check C drive for the PDF File.

Here is the JAVA code to export to PDF in Lotus Script:

import lotus.domino.*;
import java.io.FileOutputStream;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Chapter;
import com.lowagie.text.Font;
import com.lowagie.text.List;
import com.lowagie.text.Table;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfWriter;

public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
//create document's object
Document document = new Document();
try {
//create a document
PdfWriter.getInstance(document, new FileOutputStream("c:\\CreatePDFInlotus.pdf"));
//open doc for r/w
document.open();
//add text
document.add(new Paragraph ("Create PDF in Lotus "));
document.add(new Paragraph ("Create PDF in Lotus "));

//if error
} catch (DocumentException de) {
System.err.println(de.getMessage());
}

document.close();

} catch(Exception e) {
e.printStackTrace();
}
}
}


No comments:

Post a Comment

Search This Blog