Javaからプリンターに印刷する方法
JavaScriptプログラムからCROWNIXの専用ビューア(ActiveX Viewer/HTML5 Viewer)を呼出し、Webブラウザ上の指定したWindow/Frameに表示することが可能です。
 
                            1.コード
- フレーム内にHTML5 Viewerを埋め込む
- ボタンクリックでレポートを呼び出す
 
                            2.初期画面
- Report Viewerのフレームのみ表示
 
                            3.ボタンクリック後
- レポートを表示
サンプルコード
サーバーのプリンタを呼び出すことでレポートを印刷します。
import m2soft.ers.invoker.InvokerException;
import m2soft.ers.invoker.http.ReportingServerInvoker;
public class Sample {
  public static void main(String[] args)
  {
    ReportingServerInvoker invoker = new ReportingServerInvoker( "http://localhost:8080/ReportingServer/service");
    invoker.setCharacterEncoding("UTF-8");  //文字セット
    invoker.setReconnectionCount(3);        //接続のリトライ回数
    invoker.setConnectTimeout(5);           //接続のタイムアウト
    invoker.setReadTimeout(30);             //送受信のタイムアウト
    invoker.addParameter("opcode", "510");             //処理コード
    invoker.addParameter("mrd_path",                    //テンプレートパス
                          "http://localhost:8080/ReportingServer/mrd/sample.mrd");
    invoker.addParameter("mrd_param",                   //レポートパラメータ
                          "/rfn [http://localhost:8080/ReportingServer/mrd/sample.txt]");
    invoker.addParameter("protocol", "sync");          //処理結果の応答形式
    try
    {
      String response = invoker.invoke(); //要求した処理の応答待ち
      System.out.println(response);
    }
    catch(InvokerException e)
    {
      e.printStackTrace();
    }
  }
}
製品
帳票ツール
 
                             
                     
                     
                     
                    