请大侠们帮忙看哈:下面是我的打印代码,我要从外界文本框中获得一个打印的页数,可是我不知道这个打印页数该往哪放???请各位知道的帮忙看哈代码,提出意见,!!!!请知道的帮忙解决哈!!谢谢!!!!下面的这段代码可以运行得到打印的对话框,可是就是不能使打印机打印,请知道的帮忙解决一下!谢了!!! public void printHw()
{
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
// for (int i = 0; i < services.length; i++)
// {
// System.out.println(services[i].getName());
// }
String str = new String(textCode.getText());
if(str!=null&&str.length()>0)
{
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintService svc = PrintServiceLookup.lookupDefaultPrintService();
PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(str, flavor, null);
//PrintService selection = ServiceUI.printDialog( null, 100, 100, services, svc, null, attrs);
DocPrintJob job = svc.createPrintJob();
try
{
job.print(doc, attrs);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
{
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
// for (int i = 0; i < services.length; i++)
// {
// System.out.println(services[i].getName());
// }
String str = new String(textCode.getText());
if(str!=null&&str.length()>0)
{
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintService svc = PrintServiceLookup.lookupDefaultPrintService();
PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(str, flavor, null);
//PrintService selection = ServiceUI.printDialog( null, 100, 100, services, svc, null, attrs);
DocPrintJob job = svc.createPrintJob();
try
{
job.print(doc, attrs);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货