Domino 9 und frühere Versionen > ND6: Entwicklung
PDFs erstellen mit iText Java-Klasse
eknori:
pdf wird aber keins erzeugt; ok, muss ich mir mal weiter ansehen. Jetzt ist erst mal wieder Mathe angesagt ...
Due Debug console wirft übrigens ein gar nicht freundliches
Error loading Agent Base Class
aus
animate:
Da bin ich überfragt. Das müssen die Leute beantworten, die Notes mit Java nutzen. Ich kann gerne wieder bei der pdf-Bibliothek weiterhelfen.
eknori:
macht nix; vielen Dank für deine Unterstützung
btw, jetzt wirft die Debug Console folgenden Fehler raus
Error loading Agent Class: HelloWorld
java.lang.ClassNotFoundException: HelloWorld
at lotus.domino.AgentLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:494)
at lotus.domino.AgentLoader.runAgent(Unknown Source)
flaite:
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
--- Code: ---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();
}
}
}
--- Ende Code ---
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
animate:
--- Zitat von: eknori am 17.05.06 - 18:17:07 ---ich habe [...] den Agentencode von der Webseite in einen neuen Agenten kopiert.
--- Ende Zitat ---
Ach so, daran kanns natürlcih auch liegen. So ein NotesAgent muss von einer bestimmten Klasse abgeleitet sein, das ist bei dem iText-Beispiel nicht der Fall, das hat ja erstmal nichts mit Notes zu tun. Aber Axel hat ja mittlerweile ein laufendes Beispiel gebracht.
Navigation
[0] Themen-Index
[#] Nächste Seite
[*] Vorherige Sete
Zur normalen Ansicht wechseln