Q:

Java Printing a ticket

I am trying to print a ticket on Fujitsu fp-460 with this code
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
        Graphics2D g2 = (Graphics2D) g;
        g2.translate((int)pf.getImageableY(),(int) pf.getImageableY());        
        g.setFont(new Font("TimesRoman", Font.PLAIN, 20));         
        g.drawString("Some Text", 00, 00);
        g.drawString("Some Text", 00, 20);
        g.drawString("Some Text", 00, 40);        
        g.drawString("Some Text", 00, 60);
        return PAGE_EXISTS;
    }

but the printed paper have some margin on left and right how to make it print it full page ?
Printer works fine when printing from other places 

A:

I am not an expert in AWT printing, but based on the API I found this, give it a try:
pageFormat.getPaper().setSize(paperWidth, paperHeight);
pageFormat.getPaper().setImageableArea(iaX, iaY, iaWidth, iaHeight);

These should manipulate the paper size and your printable area.

