You can't use PSGraphics2D like that. PSGraphics2D is for use in an
externally set up PS document. What you need is PSDocumentGraphics2D.
There is also an EPSDocumentGraphics2D which can be used to create EPS
files. For that, an example exists:
http://svn.apache.org/viewcvs.cgi/xmlgraphics/commons/trunk/examples/java/java2d/ps/EPSExample1.java?view=markup

You can simply replace EPSDocumentGraphics2D with PSDocumentGraphics2D
to receive a normal PS file instead of an EPS file. The rest is pretty
much the same. But not knowing all requirement I don't know if this will
work out for your use case. Have fun.

On 28.04.2006 13:24:39 Camilakill wrote:
> 
> I'm afraid I don't have time to build something at the moment. I have next
> week to make it work...
> 
> I was having a look at the PSGraphics2d class and I saw that I can draw
> anything I want and then get a PSGenerator to write the postscript file from
> that.
> Am I correct?
> 
> Because I could do that Instead of drawing on a Graphics2d and converting
> into an image and eventually converting into postscript. 
> 
> I am trying to do that but I am getting a NullPointException when I try to
> drawstring in the PsGraphics2d object. I believe I am not instantiating it
> correctly...
> My test code is:
> 
> File baseDir = new File(".");
> File psfile = new File(baseDir, "out/ResultObj2PS.ps");
> 
> OutputStream out = new java.io.FileOutputStream(psfile);
> PSGenerator psGen = new PSGenerator(out); 
> 
> PSGraphics2D psG2d = new PSGraphics2D(true,psGen);
> 
> Font title = new Font("Verdana", Font.PLAIN, 18);
> 
> psG2d.setFont(title);
> psG2d.drawString("camila testing again",1,1);
> 
> psG2d.dispose();
> out.close();


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to