1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| public int print(Graphics g, PageFormat pageFormat, int page) throws PrinterException {
Graphics2D g2d = (Graphics2D) g;
int imageableWidth = (int)pageFormat.getImageableWidth();
int imageableHeight = (int)pageFormat.getImageableHeight();
PrintRequestAttributeSet attributs = new HashPrintRequestAttributeSet();
PrinterJob travail = PrinterJob.getPrinterJob();
PageFormat pageFormat2 = travail.getPageFormat(attributs);
Paper papier = new Paper();
papier.setSize(595, 842);
pageFormat2.setPaper(papier);
pageFormat2.setOrientation(PageFormat.PORTRAIT);
g2d.translate(pageFormat2.getImageableX(),pageFormat2.getImageableY());
new ArticlePrintModel(this.article1, g2d, imageableWidth, imageableHeight, this.group);
g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] {1,2}, 0));
int pageYCenter = imageableHeight/2;
g2d.drawLine(0, pageYCenter, imageableWidth, pageYCenter);
if(this.article2!=null) {
g2d.translate(0, pageYCenter+40);
new ArticlePrintModel(this.article2, g2d, imageableWidth, imageableHeight/2, this.group);
}
return PAGE_EXISTS;
} |
Partager