I actually can print using the txt file to printer, however, when I change to docx or pdf I get many undefined characters which cannot be understood at all. Do you guys have any ideas on how to solve this.
The code I used.
The code I used.
Code:
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()
Comment