Good day. JEditorPane has a method like print (). When you call, a java-dialog appears with the task of printing parameters. The default values for all fields are 25.4 mm. Is it possible to set your default values for these parameters? Thank.
1 answer
You can use the full version of the print method, you can pass it a list of attributes to print.
PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(); // размер бумаги attrs.add( MediaSizeName.ISO_A4 ); // размер доступной для печати зоны attrs.add( new MediaPrintableArea( 20, // левый верхний угол в (20мм, 20мм) 20, MediaSize.ISO.A4.getX( Size2DSyntax.MM ) - 40, // размеры MediaSize.ISO.A4.getY( Size2DSyntax.MM ) - 40, Size2DSyntax.MM ) ); (new JEditorPane()).print( null, // headerFormat null, // footerFormat true, // showPrintDialog null, // printService attrs, // attributes true // interactive ); The MediaPrintableArea attribute specifies a rectangular printable area. The area is given by the coordinates of the upper left corner and dimensions, in portrait orientation.
The list of attributes is in the description of the javax.print.attribute.standard package.
- Thank you very much. Everything worked out. - Artik
|