Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printout scale differs depending of where app is executed from

Status
Not open for further replies.

mes123

Programmer
Jul 29, 2005
62
GB
I have an application that uses the Graphics2D API and draws out an invoice. This is then printed on the local printer.

When I run the application from within NetBeans the invoice prints full scale. When I execute the application from the command line the invoice prints out at 2/3 scale!

I've tried setting the page area to be much larger than the real paper just in case something was scaling the image but it makes no difference.

Code:
PrinterJob printjob = PrinterJob.getPrinterJob();
        PageFormat pageFormat = new PageFormat();
        Paper paper = new Paper();
        paper.setSize(600, 840);
        paper.setImageableArea(20, 50, 1800, 1900);
        pageFormat.setPaper(paper);
        printjob.setPrintable(doc, pageFormat);
        
        try {
            printjob.print();
        } catch (Exception e){};


an extract of the code that creates the image is

Code:
square =  new Rectangle2D.Double(1,1, 410, 110); // address box
            g2d.setStroke(new BasicStroke(1));
            g2d.draw(square);
            g2d.drawLine(205, 1, 205, 110); // vertical divider line
            g2d.drawLine(1, 90, 410, 90); // hor div line
            
            g2d.drawString("Customer:", 3, 15);
            g2d.drawString("Deliver To:", 208, 15);
            g2d.drawLine(100, 1, 100, 20);
            g2d.drawLine(100, 20, 205, 20);
            g2d.drawString("Order No:", 103, 15);
            
            g2d.drawString("E-Mail:", 208, 103);
            g2d.drawString("Tel:", 3, 103);
            
            
            sq2 = new Rectangle2D.Double(1, 113, 410, 40);  // box 2
            g2d.draw(sq2);
            g2d.drawLine(1, 133, 410, 133); // h div
            g2d.drawLine(205, 113, 205, 153); // v div
            
            g2d.drawString("Date:", 3, 128);
            g2d.drawString("Ship Via:", 3, 148);
            g2d.drawString("Taken By:", 208, 128);
            g2d.drawString("Cust ONo.:", 208, 148);

Any ideas? This code has to be tested an deployed in about two weeks and the panic is starting to set in!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top