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 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用