Re: [JAVA2D] How to set custom paper size using printer jobs
Hi Phil, I have tried with the followings jres: jre 1.5_12, jre1.6_3, jre 1.6_EA_5. The printer I am using is Epson LX-300+II. The operating system is windows XP sp2. I have also tried in UBUNTU. I have set the paper size in the server properties of the printer, but it takes the size that it considers is best for printing (A5) instead of the size that I am trying to set.With another program like wordpad the printer takes the custom paper size I have se in the server properties of the printer. import java.awt.Font; import java.awt.Graphics; import java.awt.print.PageFormat; import java.awt.print.Paper; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; public class PrintTest implements Printable { public PrintTest(){ super(); } public void print() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pageFormat = createFormat(); try { job.setPrintable(this,pageFormat); if (job.printDialog()) { job.print(); } } catch (PrinterException e) { e.printStackTrace(); } } public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex == 0) { painter(graphics); return PAGE_EXISTS; } return NO_SUCH_PAGE; } void painter(Graphics graphics) { graphics.setFont(new Font("Sans Serif", Font.PLAIN, 11)); char[] data = "Printing an area. This is a test that is driving me crazy. It is time to come out" .toCharArray(); graphics.drawChars(data, 0, data.length, 25, 70); } public static void main(String[] args){ PrintTest printTest=new PrintTest(); printTest.print(); } private PageFormat createFormat() { PageFormat format = new PageFormat(); format.setPaper(new Custom()); return format; } private class Custom extends Paper { public Custom() { super(); setSize(560,491); } } } [Message sent by forum member 'lucho01' (lucho01)] http://forums.java.net/jive/thread.jspa?messageID=241301 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] How to set custom paper size using printer jobs
Right, on windows, the default paper size is based on the default for the printer which is what makes a lot more sense than a hard-coded value. I believe this was fixed a LONG time ago (1.3 ie 1999-2000) -phil. [EMAIL PROTECTED] wrote: I forgot to mention that, at that time, the default paper size was Letter, which was fine for people living in the US, but rather annoying for people living in Europe. That is why I had to create my own A4 class. Have a nice weekend. [Message sent by forum member 'pietblok' (pietblok)] http://forums.java.net/jive/thread.jspa?messageID=241290 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] How to set custom paper size using printer jobs
I forgot to mention that, at that time, the default paper size was Letter, which was fine for people living in the US, but rather annoying for people living in Europe. That is why I had to create my own A4 class. Have a nice weekend. [Message sent by forum member 'pietblok' (pietblok)] http://forums.java.net/jive/thread.jspa?messageID=241290 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] How to set custom paper size using printer jobs
If your printer doesn't support custom paper sizes, then setting one will just cause the closest supported paper size to be used. However there is also a bug specific to the case when the end user then changes the printer in the print dialog to one that is not the system default one where we validate against the original printer, not the selected one. That's 6359283 PrinterJob.pageDialog() ret. incorrect PageFormat when non-default printer used. Its only fixed in JDK 7 builds. http://bugs.sun.com/view_bug.do?bug_id=6359283 If neither of the above describe your situation, then try running the latest JRE : 1.6.0_03 (you didn't mention this so far as I could see). If none of that helps you would need to provide a complete small self-contained test program (not just code snippets), and also the exact JRE version (output from java -version) and also the O/S and printer model and driver so we could look further. -phil. [EMAIL PROTECTED] wrote: Hi Piet thanks for your help, I am trying to resolve my problem using your code but it did not worked. I am still getting the size A5 no matter what I try to define. I don't know if I am missing something. Please look at the following code and see if you can find what I cant find. PageFormat pageFormat = createFormat(); try { job.setPrintable(this,pageFormat); if (job.printDialog()) { job.print(); } } catch (PrinterException e) { e.printStackTrace(); } private PageFormat createFormat() { PageFormat format = new PageFormat(); format.setPaper(new Custom()); return format; } private class Custom extends Paper { public Custom() { super(); setSize(491, 594); setImageableArea(36.0, 36.0, 522.99212598425197, 450.8897637795276); } } [Message sent by forum member 'lucho01' (lucho01)] http://forums.java.net/jive/thread.jspa?messageID=241236 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] How to set custom paper size using printer jobs
Well, I am not an expert on printing issues, so probably it is as difficult for me as it is for you. The code snippets came from a class that I created some time ago and that seemed to work for me. I remember that it took me some time to get it working at all. The original version of this code dates from the time that there was no javax.print package, so before java 1.4. (I never succeeded to get javax.print classes to really work for me). Maybe you should have a look at the complete code and try to find if there are essential differences with your code. Here is the code: http://www.pbjar.org/docs/src/org/pbjar/games/swing/PrintAction.java If you want to see it in action, go to: http://www.pbjar.org/webstartdemo.html and try the Sudoku solver. In the options menu it has the print action. In the code, forget about the I18nInstaller. That is just to get dynamic internationalization, and I don't think that is bothering you at this moment. :) Good luck! [Message sent by forum member 'pietblok' (pietblok)] http://forums.java.net/jive/thread.jspa?messageID=241288 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] How to set custom paper size using printer jobs
Sorry the code of the Custom class is below: private class Custom extends Paper { public Custom() { super(); setSize(594,491); setImageableArea(36.0, 36.0, 522.99212598425197, 450.8897637795276); } } [Message sent by forum member 'lucho01' (lucho01)] http://forums.java.net/jive/thread.jspa?messageID=241238 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] How to set custom paper size using printer jobs
Hi Piet thanks for your help, I am trying to resolve my problem using your code but it did not worked. I am still getting the size A5 no matter what I try to define. I don't know if I am missing something. Please look at the following code and see if you can find what I cant find. PageFormat pageFormat = createFormat(); try { job.setPrintable(this,pageFormat); if (job.printDialog()) { job.print(); } } catch (PrinterException e) { e.printStackTrace(); } private PageFormat createFormat() { PageFormat format = new PageFormat(); format.setPaper(new Custom()); return format; } private class Custom extends Paper { public Custom() { super(); setSize(491, 594); setImageableArea(36.0, 36.0, 522.99212598425197, 450.8897637795276); } } [Message sent by forum member 'lucho01' (lucho01)] http://forums.java.net/jive/thread.jspa?messageID=241236 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] How to set custom paper size using printer jobs
Sorry again, the word "new" dropped from PageFormat format = PageFormat(); this should read: PageFormat format = new PageFormat(); Piet [Message sent by forum member 'pietblok' (pietblok)] http://forums.java.net/jive/thread.jspa?messageID=241227 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] How to set custom paper size using printer jobs
Hi, I am not sure what you are doing wrong. However, a long time ago I experimented with printing and maybe some code snippets will help you. private class A4 extends Paper { public A4() { super(); setSize(594.992125984252, 841.8897637795276); setImageableArea(36.0, 36.0, 522.99212598425197, 769.8897637795276); } } and private PageFormat createFormat() { PageFormat format = PageFormat(); format.setPaper(new A4()); return format; } for me this worked. Hope it helps. (Sorry for the bad layout, I just don't know how to get that right) Piet [Message sent by forum member 'pietblok' (pietblok)] http://forums.java.net/jive/thread.jspa?messageID=241226 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
[JAVA2D] How to set custom paper size using printer jobs
I am trying to set a custom paper size using printer jobs but it does not take my custom paper size and instead it takes the default paper size. The code I am using is as follows: PageFormat pageFormat = job.defaultPage(); Paper paper = new Paper(); paper.setSize(500,500); // Large Address Dimension paper.setImageableArea(20, 20, 450, 420); pageFormat.setPaper(paper); pageFormat.setOrientation(PageFormat.PORTRAIT); try { job.setPrintable(this,pageFormat); if (job.printDialog()) { job.print(); } } catch (PrinterException e) { e.printStackTrace(); } What am I doing wrong? [Message sent by forum member 'lucho01' (lucho01)] http://forums.java.net/jive/thread.jspa?messageID=241224 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
Re: [JAVA2D] X11 - not implemented yet?
Hi Jan, See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4833528 It's basically the same problem that you're running into, but unfortunately the bug report doesn't mention the Unix-specific workaround, which is: -Dsun.java2d.pmoffscreen=false (Hopefully that should work.) Chris On Oct 19, 2007, at 12:19 AM, [EMAIL PROTECTED] wrote: Hi, just yesterday I've got exception attached below when testing some BlendComposite stuff. I know that X11 support is not on top of your list, but any idea when it will be done? BTW, JDK I use is: Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_02-b05, mixed mode) Cheers, Jan [code] Exception in thread "AWT-EventQueue-0" java.lang.InternalError: not implemented yet at sun.java2d.x11.X11SurfaceData.getRaster (X11SurfaceData.java:173) at sun.java2d.pipe.GeneralCompositePipe.renderPathTile (GeneralCompositePipe.java:82) at sun.java2d.pipe.SpanShapeRenderer$Composite.renderBox (SpanShapeRenderer.java:42) at sun.java2d.pipe.SpanShapeRenderer.renderRect (SpanShapeRenderer.java:171) at sun.java2d.pipe.SpanShapeRenderer.fill (SpanShapeRenderer.java:122) at sun.java2d.pipe.PixelToShapeConverter.fillRect (PixelToShapeConverter.java:44) at sun.java2d.pipe.ValidatePipe.fillRect(ValidatePipe.java:58) at sun.java2d.SunGraphics2D.fillRect(SunGraphics2D.java:2265) at org.jdesktop.swingx.graphics.BlenderVisualCheck$2.paint (BlenderVisualCheck.java:121) at javax.swing.JComponent.paintChildren(JComponent.java:864) at javax.swing.JComponent.paint(JComponent.java:1036) at javax.swing.JComponent.paintChildren(JComponent.java:864) at javax.swing.JComponent.paint(JComponent.java:1036) at javax.swing.JLayeredPane.paint(JLayeredPane.java:564) at javax.swing.JComponent.paintChildren(JComponent.java:864) at javax.swing.JComponent.paintToOffscreen(JComponent.java: 5129) at javax.swing.BufferStrategyPaintManager.paint (BufferStrategyPaintManager.java:285) at javax.swing.RepaintManager.paint(RepaintManager.java:1128) at javax.swing.JComponent.paint(JComponent.java:1013) at java.awt.GraphicsCallback$PaintCallback.run (GraphicsCallback.java:21) at sun.awt.SunGraphicsCallback.runOneComponent (SunGraphicsCallback.java:60) at sun.awt.SunGraphicsCallback.runComponents (SunGraphicsCallback.java:97) at java.awt.Container.paint(Container.java:1797) at javax.swing.RepaintManager.paintDirtyRegions (RepaintManager.java:734) at javax.swing.RepaintManager.paintDirtyRegions (RepaintManager.java:679) at javax.swing.RepaintManager.seqPaintDirtyRegions (RepaintManager.java:659) at javax.swing.SystemEventQueueUtilities $ComponentWorkRequest.run(SystemEventQueueUtilities.java:128) at java.awt.event.InvocationEvent.dispatch (InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters (EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter (EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:160) at java.awt.EventDispatchThread.run (EventDispatchThread.java:121) [/code] [Message sent by forum member 'rah003' (rah003)] http://forums.java.net/jive/thread.jspa?messageID=241133 == = To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
[JAVA2D] X11 - not implemented yet?
Hi, just yesterday I've got exception attached below when testing some BlendComposite stuff. I know that X11 support is not on top of your list, but any idea when it will be done? BTW, JDK I use is: Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_02-b05, mixed mode) Cheers, Jan [code] Exception in thread "AWT-EventQueue-0" java.lang.InternalError: not implemented yet at sun.java2d.x11.X11SurfaceData.getRaster(X11SurfaceData.java:173) at sun.java2d.pipe.GeneralCompositePipe.renderPathTile(GeneralCompositePipe.java:82) at sun.java2d.pipe.SpanShapeRenderer$Composite.renderBox(SpanShapeRenderer.java:42) at sun.java2d.pipe.SpanShapeRenderer.renderRect(SpanShapeRenderer.java:171) at sun.java2d.pipe.SpanShapeRenderer.fill(SpanShapeRenderer.java:122) at sun.java2d.pipe.PixelToShapeConverter.fillRect(PixelToShapeConverter.java:44) at sun.java2d.pipe.ValidatePipe.fillRect(ValidatePipe.java:58) at sun.java2d.SunGraphics2D.fillRect(SunGraphics2D.java:2265) at org.jdesktop.swingx.graphics.BlenderVisualCheck$2.paint(BlenderVisualCheck.java:121) at javax.swing.JComponent.paintChildren(JComponent.java:864) at javax.swing.JComponent.paint(JComponent.java:1036) at javax.swing.JComponent.paintChildren(JComponent.java:864) at javax.swing.JComponent.paint(JComponent.java:1036) at javax.swing.JLayeredPane.paint(JLayeredPane.java:564) at javax.swing.JComponent.paintChildren(JComponent.java:864) at javax.swing.JComponent.paintToOffscreen(JComponent.java:5129) at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285) at javax.swing.RepaintManager.paint(RepaintManager.java:1128) at javax.swing.JComponent.paint(JComponent.java:1013) at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21) at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60) at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97) at java.awt.Container.paint(Container.java:1797) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:734) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679) at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:659) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) [/code] [Message sent by forum member 'rah003' (rah003)] http://forums.java.net/jive/thread.jspa?messageID=241133 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".