添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
聪明伶俐的皮带
·
向华强在商界什么等级?马云参加他的生日宴,来 ...
·
1 月前
·
可爱的木耳
·
SqlServer更改字段类型--varch ...
·
2 月前
·
憨厚的芒果
·
樱花动漫-最新高清热播电影-好看的电视剧免费 ...
·
2 月前
·
痴情的酸菜鱼
·
Как понять ошибку ...
·
3 月前
·
唠叨的豌豆
·
What is the ...
·
3 月前
·
link管理
›
Can you send OutputStream to a named printer? (I/O and Streams forum at Coderanch)
https://coderanch.com/t/552119/java/send-OutputStream-named-printer
深沉的刺猬
5 月前
Can output stream be directed to a printer other than default (windows) ? this gives a list of Printers available to my desktop
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null); System.out.println("Number of print services: " + printServices.length); for (PrintService printer : printServices) System.out.println("Printer: " + printer.getName());
there are seven names in the list one of which is a default printer,
I have some
java
code creating a pdf using itext that I print like this
Document document = new Document(PageSize.LETTER); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); document.open(); PdfContentByte cb = writer.getDirectContent(); String a1 = "blah blah blah"; String a2 = "some string"; BaseFont bf = BaseFont.createFont( BaseFont.COURIER_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED); // we need to switch to text mode cb.beginText(); cb.moveText(60, 732); // 36 806 Td cb.setFontAndSize(bf, 12); cb.showText(a1); cb.moveText(+132, 0); // 0 -12 Td cb.showText(a2); // leave text mode cb.endText(); // document.newPage(); // Page 2 // we need to switch to text mode writer.addJavaScript("this.print({bUI: false, bSilent: true, bShrinkToFit: true});",false); document.close(); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); // // setting the content type response.setContentType("application/pdf"); // // the contentlength is needed for MSIE!!! response.setContentLength(baos.size()); // write ByteArrayOutputStream to the ServletOutputStream OutputStream out = response.getOutputStream(); baos.writeTo(out); out.flush(); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage());
this sends the BytArrayOutputstream to the default printer, is it possible to send the print to one of the other printers in the list?
current ranch time (not your local time) is
Jun 26, 2024 15:31:46
all times are in ranch time: GMT-6 in summer, GMT-7 in winter
contact us
|
advertise
|
推荐文章
聪明伶俐的皮带
·
向华强在商界什么等级?马云参加他的生日宴,来北京有迈巴赫接送|向太|李连杰|娱乐圈_网易订阅
1 月前
可爱的木耳
·
SqlServer更改字段类型--varchar转decimal - KJXY - 博客园
2 月前
憨厚的芒果
·
樱花动漫-最新高清热播电影-好看的电视剧免费在线观看
2 月前
痴情的酸菜鱼
·
Как понять ошибку Numeric value out of range? — Хабр Q&A
3 月前
唠叨的豌豆
·
What is the AddSingleton vs AddScoped vs Add Transient C# Asp.net Core?
3 月前