Tuesday, May 06, 2008

How to create PDF from Lotus Notes

I want to show you one of the way how we can create PDF documents from Lotus Notes
I propose to use this package com.lowagie.text
We can download it from next
http://prdownloads.sourceforge.net/itext/itext-1.3.jar
Description here:
http://itext.ugent.be/library/api/
http://www-128.ibm.com/developerworks/opensource/library/os-javapdf/


Here is an example that create PDF document.

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 "));
//if error
} catch (DocumentException de) {
System.err.println(de.getMessage()); }

document.close();

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

But as I know it does not work with Cyrilic, unfortunately for me ;-)

Here is an example
Post a Comment