当前位置: 技术问答>java相关
打印问题!!
来源: 互联网 发布时间:2015-08-19
本文导语: 我打印出的页面为何整体放大,且画面右侧部分进不A4的页面?代码如下: Frame getFrame(Component c) { while((c = c.getParent())!=null) { if(c instanceof Frame) return (Frame)c; } return...
我打印出的页面为何整体放大,且画面右侧部分进不A4的页面?代码如下:
Frame getFrame(Component c)
{
while((c = c.getParent())!=null)
{
if(c instanceof Frame)
return (Frame)c;
}
return null;
}
void printComponents(Component c)
{
Toolkit tk = Toolkit.getDefaultToolkit();
Frame frame = getFrame(c);
if(tk!=null)
{
String name = c.getName() + "print.job";
PrintJob pj = tk.getPrintJob(frame, name, null);
if(pj!=null)
{
Graphics pg = pj.getGraphics();
if(pg!=null)
{
try
{
c.paintAll(pg);
}
finally
{
pg.dispose();
}
}
pj.end();
}
}
}
Frame getFrame(Component c)
{
while((c = c.getParent())!=null)
{
if(c instanceof Frame)
return (Frame)c;
}
return null;
}
void printComponents(Component c)
{
Toolkit tk = Toolkit.getDefaultToolkit();
Frame frame = getFrame(c);
if(tk!=null)
{
String name = c.getName() + "print.job";
PrintJob pj = tk.getPrintJob(frame, name, null);
if(pj!=null)
{
Graphics pg = pj.getGraphics();
if(pg!=null)
{
try
{
c.paintAll(pg);
}
finally
{
pg.dispose();
}
}
pj.end();
}
}
}
|
用专业的报表工具吧..
Style/Report www.inetsoft.com 010_68941777
JReport www.jtaltal.com 010_84261288
Style/Report www.inetsoft.com 010_68941777
JReport www.jtaltal.com 010_84261288
|
javascript就可以做打印玉兰的