Results 1 to 3 of 3
  1. #1
    rdjava's Avatar
    rdjava is offline Member
    Join Date
    Jan 2011
    Posts
    38
    Rep Power
    0

    Default Printing a scalled Component

    I have a problem with printing a component or a set of components, I only need to print 1 page for the current print job, this works but parts of the page are cut off because the component is too large for the page.

    If anyone has any insight on this with example code etc. would be greatly appreciated.

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    I would recommend using the 'scale' method of Graphics2D to scale it to fit the page. The scale factors are:

    sx = (double) pageWidth / getBounds().width
    sy = (double) pageHeight / getBounds().height

    (where pagewidth and pageheight account for margins and are obtained from the PrintJob)

  3. #3
    rdjava's Avatar
    rdjava is offline Member
    Join Date
    Jan 2011
    Posts
    38
    Rep Power
    0

    Default

    Quote Originally Posted by toadaly View Post
    I would recommend using the 'scale' method of Graphics2D to scale it to fit the page. The scale factors are:

    sx = (double) pageWidth / getBounds().width
    sy = (double) pageHeight / getBounds().height

    (where pagewidth and pageheight account for margins and are obtained from the PrintJob)
    Thanks! that did wonders for me! :D

Similar Threads

  1. printing string backwards and printing every other
    By droidus in forum New To Java
    Replies: 22
    Last Post: 03-10-2011, 10:17 AM
  2. add(component) gives 2 components?
    By warchieflll in forum Advanced Java
    Replies: 2
    Last Post: 01-31-2011, 04:08 PM
  3. Component to use ?
    By pbaudru in forum AWT / Swing
    Replies: 2
    Last Post: 02-17-2010, 10:55 AM
  4. the component does not show
    By shruti in forum AWT / Swing
    Replies: 8
    Last Post: 07-08-2009, 01:21 PM
  5. add component to component
    By Omarero in forum New To Java
    Replies: 7
    Last Post: 05-17-2009, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •