Sunday 15 September 2013

printing - Can't print text file using Java 8 in Windows 7 -



printing - Can't print text file using Java 8 in Windows 7 -

i've created study , exported text file, print in matrix printer, however, result of job blank page. did same in ubuntu , printing correctly. java bug?

this illustration code did show problem:

public class printerror extends application { public static void main(string args[]) { launch(args); } public void start(stage stage) throws printexception { printerjob printerjob = printerjob.createprinterjob(); printerjob.showprintdialog(stage); printrequestattributeset printrequestattributeset = new hashprintrequestattributeset(); printrequestattributeset.add(new copies(printerjob.getjobsettings().getcopies())); printrequestattributeset.add(new jobname("test", locale.getdefault())); docflavor flavor = docflavor.input_stream.autosense; doc mydoc = new simpledoc(classloader.class.getresourceasstream("/should-be-printed.txt"), flavor, null); docprintjob job = getprintservice(printerjob.getprinter().getname()).createprintjob(); job.print(mydoc, printrequestattributeset); } private printservice getprintservice(string name) { (printservice printservice : java.awt.print.printerjob.lookupprintservices()) { if (name.equalsignorecase(printservice.getname())) { homecoming printservice; } } homecoming null; } }

this illustration created in javafx 8 , running in java build 1.8.0-b132 in windows 7. i've created simple project @ github

from documentation:

recommended docflavors

the java print service api not define mandatorily supported docflavors. …

when have printservice instance, can utilize method getsupporteddocflavors() find out flavors supports.

when find out none of docflavor. input_stream. text_plain_… flavors in list, doesn’t help utilize autosense means “best guess” , it’s unlikely printservice guess type doesn’t support, instead, it’s more info misinterpreted 1 of formats supports.

on windows machine, none of provided printservices supports printing plaintext…

java printing javafx java-8

No comments:

Post a Comment