Article ID: 182623
Article Last Modified on 7/23/2001
import java.awt.*;
import com.ms.ui.*;
public class PrintFont extends UIFrame
{
public PrintFont()
{
PrintJob pj = getToolkit().getPrintJob(null, "Printer", null);
if (pj != null)
{
for (int i=1; i<=3; i++)
{
Graphics pg = pj.getGraphics();
if (pg != null)
{
pg.setFont(new Font("TimesRoman", Font.PLAIN, 16));
pg.setColor(Color.black);
pg.drawRect(100, 100, 100, 100);
pg.drawString("Page " + i, 600, 900);
pg.drawString("TimesRoman", 500, 900);
}
System.out.println("Dispose");
pg.dispose();
}
pj.end();
System.out.println("End");
}
}
public static void main(String args[])
{
UIFrame f = new PrintFont();
System.exit(0);
}
}
A workaround for this problem is to select a different attribute
(font/color) and do a drawString of an empty string, then select back in
the desired attribute.
try {
com.ms.awt.GraphicsX gx = (com.ms.awt.GraphicsX) printGraphics;
Point pt = gx.getTranslation();
gx.translate(-pt.x, -pt.y);
} catch (Exception e) {
}
Additional query words: print font
Keywords: kbbug kbfix kbsdkjava300fix kbsdkjava310fix KB182623