|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help in printing with java
I want to print an image from my harddisk and I need to print it at a specific location and size. How do I do it?
I am using the new javax.print package but after some failures, I tried to include some of the old java.awt.print code. I still get errors. Please help. Here's the code: PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(MediaSizeName.ISO_A4); aset.add(OrientationRequested.PORTRAIT); aset.add(new Copies(1)); PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset); //This is the code from the old awt.print package Paper paper = new Paper(); PageFormat page = new PageFormat(); paper.setImageableArea(0,0,600,800); page.setPaper(paper); //Using the new DocPrintJob and old setPrintable, I tried to //print at the desired size and position DocPrintJob printJob = pservices[0].createPrintJob(); #printJob.setPrintable(this, page); I still get 2 errors on the # line: 1) Can't refer a non-static var.(this) from a static context 2) Can't resolve symbol(setPrintable) Can anyone help me solve this and be able to print on any location and any desired size using the javax.print package? Thanks in advance. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Help in printing with java |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|