I started my jar now with cmd. It throws following exceptption
Exception in thread "AWT-EventQueue-0" ExceptionConverter:
java.io.IOException:
The document has no pages.
at com.lowagie.text.pdf.PdfPages.writePageTree(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)
at com.lowagie.text.Document.close(Unknown Source)
at GUI.PDF.CreatePDF.create(CreatePDF.java:82)
at
GUI.KalkulationView.jButton3ActionPerformed(KalkulationView.java:177
)
at GUI.KalkulationView.access$1200(KalkulationView.java:29)
at GUI.KalkulationView$13.actionPerformed(KalkulationView.java:1620)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown
Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown
Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown
Sou
ce)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
This is my class
package GUI.PDF;
import GUI.KalkulationView;
import com.lowagie.text.Element;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import javax.swing.JFileChooser;
public class CreatePDF {
KalkulationView einKalkulationView;
private FileOutputStream fs;
public void create(File file,KalkulationView einKalkulationView){
// step 1: creation of a document-object
this.einKalkulationView = einKalkulationView;
Document document = new Document();
float[] widths = new float[3];
try {
fs = new FileOutputStream(file);
PdfWriter.getInstance(document,fs);
// step 3: we open the document
document.open();
Image jpg = Image.getInstance("src/Sonstiges/muskator.gif");
jpg.setAlignment(Image.MIDDLE);
document.add(jpg);
Paragraph p1 = new Paragraph("Rationsberechnung fuer
Schweine",FontFactory.getFont(FontFactory.HELVETICA, 30));
p1.setAlignment(Paragraph.ALIGN_CENTER);
document.add(p1);
Paragraph p2 = new
Paragraph("\n",FontFactory.getFont(FontFactory.HELVETICA, 12));
document.add(p2);
PdfPTable table = new PdfPTable(3);
PdfPTable table1 = new PdfPTable(1);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.getDefaultCell().setBorder(0);
table.setTotalWidth(100f);
PdfPCell cell = new PdfPCell(new Paragraph("Berater"));
widths[0] = 20f;
widths[1] = 60f;
widths[2] = 30f;
table.setWidths(widths);
table.addCell(cell);
table.addCell(new Paragraph("Dr. Juergen
Hittel",FontFactory.getFont(FontFactory.HELVETICA, 10)));
table.addCell("Test2");
table.addCell("");
table.addCell("Weizenmuehlenstrasse 11");
table.addCell("Test2");
table.addCell("");
table.addCell("40221 Düsseldorf");
table.addCell("Test2");
table1.addCell(table);
document.add(table);
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
try {
fs.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}}
Do you see the error ??
Thanks
David
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bruno
Lowagie (iText)
Sent: Monday, June 25, 2007 3:39 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Build Project jar but iText not working
David Hittel wrote:
> Any suggestions?
I fear this question can only be answered by someone
sitting next to you, or, as Paulo would say, by somebody
with a crystal ball.
My guess is that if you add a System.out to every other
line, saying "I'm here 1", "I'm here 2", "I'm here 3",...
You will see that not all those lines will be reached.
The line where you create the FileOutputStream is
obviously reached, but I guess that an exception is
thrown somewhere after that line.
Of course, we can't guess which kind of exception.
If you can get iText working on NetBeans, it isn't
an iText problem.
br,
Bruno
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/