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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a printed area to center on the paper

Status
Not open for further replies.

chunkII123

IS-IT--Management
Mar 18, 2009
78
US
Alright, this seems to be an easy one for a programmer with more skill than I. Here is what I have -

Code:
public void print() {
        PrintUtilities printUtil = new PrintUtilities(this.getContentPane());

        PageFormat myPageFormat = new PageFormat();
        myPageFormat.setOrientation(PageFormat.PORTRAIT);

        Paper paperType = new Paper();
        paperType.setImageableArea(600.0, 750.0, 625.0, 792.0);

        myPageFormat.setPaper(paperType);

        printUtil.setPageFormat(myPageFormat);
        printUtil.setPageSize(.95, .95);
        printUtil.setPrintJobName("Problem Members");

        this.setVisible(false);
        
         JOptionPane.showMessageDialog(this, "Problem Members Printed.", "Problem Members", JOptionPane.INFORMATION_MESSAGE);


        // this try block does not execute
        // print comes from the printutil method of the matchedmembers form

    }

The block that it prints is 400 pixels wide, but it prints roughly (.250", .250" (x, y respectively)) on the page. I would like to center it on the x axis, and it looks as though my printable area is (640, 797), so essentially I need to set the location of the print page to (120px, (pixel resolution of a quarter inch)).

Thanks ahead of time.

-Josh

Beware of hackers bearing executables. Happy Hunting. 'irc.2600.net'
 
Dian -

JRE 5.11

Java 6 Update 13

JDK 6 Update 16

IDE - Netbeans 6.7.1

Thanks,
Josh

Beware of hackers bearing executables. Happy Hunting. 'irc.2600.net'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top