0

I have this link, and I can use this sample, to print my panel: print example I use this, to print my panel:

PrintUtilities.printComponent(this);

"this" is the panel. but after the printing, on the paper the panel is not full. Only the (about) 70% of the Width, and 60% of the Height. (sorry for my english, i am hungarian) The panel size is: 850x1160. This is the example size to an A4 paper: 595x842 -> 70dpi = A4. Please help me, how to print my panel FULLY to an A4 paper. Thank you!

Community
  • 1
  • 1
victorio
  • 6,224
  • 24
  • 77
  • 113
  • 1
    Duplicate of http://stackoverflow.com/questions/1220115/resizing-jpanel-to-prepare-for-printing-without-removing-it-from-its-original-po – GETah Dec 09 '11 at 23:23
  • 1
    Here's a related [example](http://stackoverflow.com/a/7028497/230513) using `AffineTransformOp `. – trashgod Dec 10 '11 at 02:46

1 Answers1

1
double factorX = pf.getImageableWidth() / component.getWidth();
double factorY = pf.getImageableHeight() / component.getHeight();
double factor = Math.min( factorX, factorY );
g2.scale(factor,factor);

thanks for the answers everybody!

victorio
  • 6,224
  • 24
  • 77
  • 113