javax.print.attribute.HashDocAttributeSet Java Examples
The following examples show how to use
javax.print.attribute.HashDocAttributeSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrintTest.java From spring-boot with Apache License 2.0 | 6 votes |
private void printText2Action() { printStr = area.getText().trim(); if(printStr != null && printStr.length() > 0) { PAGES = getPagesCount(printStr); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob job = printService.createPrintJob(); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(this, flavor, das); try { job.print(doc, pras); } catch(PrintException pe) { pe.printStackTrace(); } } else { JOptionPane.showConfirmDialog(null, "Sorry, Printer Job is Empty, Print Cancelled!", "Empty", -1, 2); } }
Example #2
Source File: PrintSEUmlauts.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #3
Source File: PrintSEUmlauts.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #4
Source File: PrintSEUmlauts.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #5
Source File: PrintSEUmlauts.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #6
Source File: PrintTest.java From spring-boot with Apache License 2.0 | 5 votes |
private void printFileAction() { JFileChooser fileChooser = new JFileChooser(System.getProperty("USER_DIR")); // fileChooser.setFileFilter(new JavaFilter()); int state = fileChooser.showOpenDialog(this); if(state == 0) { File file = fileChooser.getSelectedFile(); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, flavor, pras); if(service != null) try { DocPrintJob job = service.createPrintJob(); FileInputStream fis = new FileInputStream(file); DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das); job.print(doc, pras); } catch(Exception e) { e.printStackTrace(); } } }
Example #7
Source File: LocatePrint.java From spring-boot with Apache License 2.0 | 5 votes |
private void printFileAction() { // 构造一个文件选择器,默认为当前目录 JFileChooser fileChooser = new JFileChooser(); int state = fileChooser.showOpenDialog(null);//弹出文件选择对话框 if (state == fileChooser.APPROVE_OPTION)//如果用户选定了文件 { File file = fileChooser.getSelectedFile();//获取选择的文件 //构建打印请求属性集 PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); //设置打印格式,因为未确定文件类型,这里选择AUTOSENSE DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; //查找所有的可用打印服务 PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); //定位默认的打印服务 PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); //显示打印对话框 PrintService service = ServiceUI.printDialog(null, 200, 200, printService , defaultService, flavor, pras); if (service != null) { try { DocPrintJob job = service.createPrintJob();//创建打印作业 FileInputStream fis = new FileInputStream(file);//构造待打印的文件流 DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das);//建立打印文件格式 job.print(doc, pras);//进行文件的打印 } catch(Exception e) { e.printStackTrace(); } } } }
Example #8
Source File: LocatePrint.java From spring-boot with Apache License 2.0 | 5 votes |
public void printContent() { printStr = "打印测试内容";// 获取需要打印的目标文本 if (printStr != null && printStr.length() > 0) // 当打印内容不为空时 { PAGES = 1; // 获取打印总页数 // 指定打印输出格式 DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); // 定位默认的打印服务 PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); // PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); // Toolkit.getDefaultToolkit().getPrintJob // 创建打印作业 PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, flavor, pras); //PrintService service = ServiceUI.printDialog(null, 200, 200, printService, printService , flavor, pras); //DocPrintJob job = printService.createPrintJob(); DocPrintJob job = service.createPrintJob(); // 设置打印属性 // PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); // 设置纸张大小,也可以新建MediaSize类来自定义大小 pras.add(MediaSizeName.ISO_A4); DocAttributeSet das = new HashDocAttributeSet(); // 指定打印内容 Doc doc = new SimpleDoc(this, flavor, das); // 不显示打印对话框,直接进行打印工作 try { job.print(doc, pras); // 进行每一页的具体打印操作 } catch (PrintException pe) { pe.printStackTrace(); } } else { // 如果打印内容为空时,提示用户打印将取消 JOptionPane.showConfirmDialog(null,"Sorry, Printer Job is Empty, Print Cancelled!", "Empty", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); } }
Example #9
Source File: PrintSEUmlauts.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #10
Source File: PrintSEUmlauts.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #11
Source File: PrintSEUmlauts.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #12
Source File: PrintSEUmlauts.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #13
Source File: PrintSEUmlauts.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #14
Source File: PrintSEUmlauts.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #15
Source File: PrintSEUmlauts.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { GraphicsEnvironment.getLocalGraphicsEnvironment(); DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory. lookupStreamPrintServiceFactories(flavor, mime); if (factories.length == 0) { System.out.println("No print service found."); return; } FileOutputStream output = new FileOutputStream("out.ps"); StreamPrintService service = factories[0].getPrintService(output); SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet()); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new PrintJobAdapter() { @Override public void printJobCompleted(PrintJobEvent pje) { testPrintAndExit(); } }); job.print(doc, new HashPrintRequestAttributeSet()); }
Example #16
Source File: PageableDoc.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #17
Source File: PageableDoc.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #18
Source File: PageableDoc.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #19
Source File: PageableDoc.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #20
Source File: PageableDoc.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #21
Source File: PageableDoc.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #22
Source File: PageableDoc.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #23
Source File: PageableDoc.java From Bytecoder with Apache License 2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #24
Source File: PageableDoc.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #25
Source File: PageableDoc.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #26
Source File: PageableDoc.java From hottub with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #27
Source File: PageableDoc.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #28
Source File: PageableDoc.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }
Example #29
Source File: PageableDoc.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public DocAttributeSet getAttributes() { return new HashDocAttributeSet(); }