Das als Agent:
Funktioniert so nur auf Windows (Ginge auch anders, ich schlag später mal nach).
Das PDF landet in:
C:\\temp\\HelloWorld.pdf
Lokaler Java Agent mit Notes7.
Agent--> Auswahl im Menü Aktionen, Ziel: keines
import lotus.domino.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import java.io.FileOutputStream;
import java.io.IOException;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
System.out.println("Hello World");
// step 1: creation of a document-object
// NAMESPACE MUSS EXPLIZIT ANGEGEBEN WERDEN.
com.lowagie.text.Document document = new com.lowagie.text.Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
// WINDOWS ONLY. ICH BIN MÜDE
PdfWriter.getInstance(document,
new FileOutputStream("C:\\temp\\HelloWorld.pdf"));
// step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
// (Fügen Sie Ihren Code hier ein)
} catch(Exception e) {
e.printStackTrace();
}
}
}
Klar geht das eleganter. Hab aber hier einfach nur den Code des Beispiels in den Agenten kopiert. Als separate Klasse kann ich später mal posten. Ich bin müde.
Gruß Axel
Gerne:
package com.lowagie.examples.general;
import lotus.domino.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import java.io.FileOutputStream;
import java.io.IOException;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
System.out.println("Hello World");
// step 1: creation of a document-object
// NAMESPACE MUSS EXPLIZIT ANGEGEBEN WERDEN.
com.lowagie.text.Document document = new com.lowagie.text.Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
// WINDOWS ONLY. ICH BIN MÜDE
PdfWriter.getInstance(document,
new FileOutputStream("C:\\temp\\HelloWorld.pdf"));
// step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
// (Fügen Sie Ihren Code hier ein)
} catch(Exception e) {
e.printStackTrace();
}
}
}
Ohne die zeile erzeugt er mir kein PDF, aber mit. ???
Ohne diese Zeile wirft der Debugger folgendes aus:
Error loading Agent Class: com.lowagie.examples.general.JavaAgent
java.lang.ClassNotFoundException: com.lowagie.examples.general.JavaAgent
at lotus.domino.AgentLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:494)
at lotus.domino.AgentLoader.runAgent(Unknown Source)