Menu ▾ ▴

#1 doesn't print chars on right and cuts final line

open
nobody
None
5
2006-06-21
2006-06-21
Anonymous
No

The Printing code (taken from someone else's code)
has been stripped of the Graphics2D scale method,
which correctly formats the page so that the edge of
the right and at the bottom are not clipped

here is the code

insert at top of print method

Graphics2D g2 = (Graphics2D) g;

add following after "dim" variable

double width = dim.getWidth();
double pageWidth = pf.getImageableWidth();
double scale = pageWidth / width;

after "g.translate(0, (int)(-pageIndex *
pageHeight));"

put this
g2.scale(scale,scale);

change ALL references of "g" to "g2"

e.g.
g2.translate((int)(pf.getImageableX()), (int)
(pf.getImageableY()));
g2.translate(0, (int)(-pageIndex * pageHeight));
editorPane.paint(g2);

Discussion


Log in to post a comment.