[Retep-PDF] (no subject)
Status: Beta
Brought to you by:
petermount
|
From: Howard, J. <Jef...@wi...> - 2004-09-09 03:23:34
|
Hi,
I've been attempting to use retep-pdf (v2.4.1) as a print service under =
Java 1.4.2 and I've run into a bit of a problem.
For what I'm doing with this program I need to be able to represent a =
hierarchy of objects (using a JTree in the GUI). I've extended the =
JTree to make it printable and it prints beautifully to a real printer =
so I'm confident that my code is correct.=20
Things turn sour very quickly as soon as I try to use retep-pdf to =
generate a PDF of the report. I get a NullPointerException from =
retep-pdf. I've included the stack trace below.
This may or may not be relevant, but the JTree I'm using is rather =
heavily modified so that the leaves of the tree are actually JPanels =
containing a number of other SWING components (JLabels, Icons, progress =
bars, and a dynamic spacer) instead of the simple JLabels used by =
default in the JTree.
Here's the code snippet that launches the print action:
PrintRequestAttributeSet pras =3D new =
HashPrintRequestAttributeSet();
DocFlavor flavor =3D DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintService[] ps =3D =
PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService dps =3D =
PrintServiceLookup.lookupDefaultPrintService();
PrintService svc =3D ServiceUI.printDialog(null, 200, 200, =
ps, dps, flavor, pras);
if (svc!=3D null){
DocPrintJob job =3D svc.createPrintJob();
DocAttributeSet das =3D new HashDocAttributeSet();
Doc doc =3D new SimpleDoc(this,flavor,das);
=20
try{
job.print(doc,pras);
}catch (PrintException pe){
System.out.println("Exception while printing: =
"+pe.getMessage());
pe.printStackTrace();
}
}
Any help would be greatly appreciated :-)
Thanks!
Jeff Howard
Oh yeah... Here's the stack trace mentioned above:
java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:61)
at java.io.InputStreamReader.<init>(InputStreamReader.java:55)
at uk.org.retep.pdf.util.afm.AFM.<init>(AFM.java:92)
at =
uk.org.retep.pdf.util.afm.BaseMetrics.getFont(BaseMetrics.java:100)
at =
uk.org.retep.pdf.core.GraphicsImpl.getFontMetrics(GraphicsImpl.java:999)
at =
uk.org.retep.pdf.core.GraphicsImpl.getFontMetrics(GraphicsImpl.java:983)
at =
javax.swing.plaf.basic.BasicLabelUI.paint(BasicLabelUI.java:137)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at =
javax.swing.CellRendererPane.paintComponent(CellRendererPane.java:134)
at =
javax.swing.plaf.basic.BasicTreeUI.paintRow(BasicTreeUI.java:1380)
at =
javax.swing.plaf.basic.BasicTreeUI.paint(BasicTreeUI.java:1171)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at com.wiltel.swing.PrintableJTree.print(PrintableJTree.java:64)
at =
uk.org.retep.pdf.print.service.PrintUtils.printPage(PrintUtils.java:313)
at =
uk.org.retep.pdf.print.service.PrintUtils.print(PrintUtils.java:365)
at =
uk.org.retep.pdf.print.service.PDFServiceJob.printImpl(PDFServiceJob.java=
:186)
at =
uk.org.retep.pdf.print.service.PDFServiceJob.print(PDFServiceJob.java:154=
)
at =
com.wiltel.swing.PrintableJTree.TreeChassisMouseClicked(PrintableJTree.ja=
va:126)
at =
com.wiltel.swing.PrintableJTree$2.mouseClicked(PrintableJTree.java:89)
at =
java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:212)
at =
java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:211)
at java.awt.Component.processMouseEvent(Component.java:5103)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at =
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at =
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3207)
at =
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at =
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread=
java:201)
at =
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.j=
ava:151)
at =
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at =
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at =
java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
|