简体   繁体   English

Java打印代码正常工作,发送到打印机但不打印任何内容(Python中的Java)

[英]The java printing code is working,send to printer but not print anything(java in python)

i have made various research on this,plus,i'm using python,which i actually implement java in python script.Somehow,the record is send to the printer(i even got the message about this)but it does not print.can anyone help me on this,i'm stuck on this.thanks. 我对此进行了各种研究,此外,我使用的是python,我实际上是在python脚本中实现java。以某种方式,记录被发送到打印机(我什至得到了关于此的消息),但它无法打印。任何人都可以帮我这个忙,谢谢。

This is the code,i got no error for this. 这是代码,对此我没有任何错误。

import system
import javax.print
import java.io
from java.lang import Thread

filestream = java.io.BufferedInputStream(java.io.FileInputStream("C:/GEEKS.txt"))

psInformat = javax.print.DocFlavor.INPUT_STREAM.AUTOSENSE

myDoc = javax.print.SimpleDoc(filestream,psInformat,None)

aset = javax.print.attribute.HashPrintRequestAttributeSet()
aset.add(javax.print.attribute.standard.Copies(2))

services = javax.print.PrintServiceLookup.lookupDefaultPrintService()

job = services.createPrintJob()

job.print(myDoc, None)

Thread.sleep(20000)

filestream.close()

You are trying to send a .docx file to the printer; 您正在尝试将.docx文件发送到打印机。 the print service almost certainly doesn't know how to render and print a .docx file. 打印服务几乎可以肯定不知道如何呈现和打印.docx文件。 Try sending a plain text file. 尝试发送纯文本文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM