简体   繁体   English

在Java中没有按顺序打印文档

[英]documents are not printing in sequence in java

for(int i = 0 ; i< letters.size(); i++){
    Map<String,Object> letter= letters.get(i);
    String path      = letter.get("path").toString();
    File pritingFile = new File(path);   
    Desktop desktop = null;
       if (Desktop.isDesktopSupported()) {
                    desktop = Desktop.getDesktop();
                    desktop.print(pritingFile); 
        }

  }

above for loop is printing around 200 letters but the printer is not printing letters in the sequence of order which is sent to print. 上面的for循环可打印约200个字母,但打印机未按发送打印的顺序打印字母。

The javadoc for print(...) says: 用于print(...)的javadoc说:

Prints a file with the native desktop printing facility, using the associated application's print command. 使用关联的应用程序的打印命令,通过本机桌面打印工具打印文件。

There are no guarantees about the order in which files are printed by the native (ie OS) print system. 不能保证本机(即OS)打印系统的文件打印顺序。 Indeed, the javadoc doesn't even state that the formatted document has been submitted to the printer queue by the time that print returns. 确实,javadoc甚至没有说明格式化的文档在print返回时已经提交给打印机队列。

You may have more success using the javax.print API: 使用javax.print API可能会更成功:

There is an example in the above page. 上一页有一个示例。

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

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