Javaによる印刷



public int print(Graphics g, PageFormat pf, int page)
throws PrinterException
{
if (page >= 1) return Printable.NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D)g;
g2.translate(pf.getImageableX(), pf.getImageableY());
//印刷範囲を表示
/*g2.draw(new Rectangle2D.Double(0, 0,
pf.getImageableWidth(), pf.getImageableHeight()));*/
System.out.println("A4 Size:"+pf.getImageableWidth()+" "+pf.getImageableHeight());
drawPage(g2);// to print
return Printable.PAGE_EXISTS;
}
String fontname="MS 明朝";
int type =Font.PLAIN;
int size=15;
type=type|Font.BOLD;
Font font;
font=new Font(fontname,type,size);
g2.setFont(font);
g2.drawString("極座標による花の描画",30,50);
size=12;type = Font.PLAIN;
font=new Font(fontname,type,size);
g2.setFont(font);
g2.drawString("ca=70,cb=17,cc=6,",30,65);