douming4359 2015-06-30 06:43
浏览 216

Desktop.getDesktop()。print(path)避免出现窗口

Before telling you the issue, I'm going to present you my solution:

On windows, I have a php server (Wamp server) that fulfill a .rtf template depending on the user entry. Basically this is about quality for an industry company, the user describe hiself and then describe the issue. I save this new .rtf file with a special name : basically the type of issue encounter and then an id. This .rtf file is used on server side to generate a pdf file (always server side). I found a snipet of java code that convert my .rtf file in pdf because I print the .rtf file and like the default printer on the server is a virtual printer, pdfCreator, a pdf is create on a specific folder. The pdf will be used by the server to send an automatic email back to the client and another one for the quality.

I have a java class called Printer.java that contains on the main

 Desktop.getDesktop().print(new File(args[0]));

surrounded by try catch.

This java code works very well on command line but when I tried to run it through my php server :

exec("java -cp C:\\wamp\\www\etour\\printer\\printer\\build\\classes Printer C:\\wamp\\www\etour\eparation_TB2015000001.doc");    

It doesn't work because a window prompt and in a php server (apparently) you cannot open a window. When you call Desktop.getDesktop().print() with an rtf file, like Microsoft Words is defined to open by default this kind of file, java will try to open Words. While calling by command line, Words open, print the file and then close automaticly but when I call it by php, the server nerver stop (infinite spin) on my page and wamp stop the process after 90 secs.

Any idea ?

Thanks for your help guys.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥120 计算机网络的新校区组网设计
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据