PrintStreamパッケージ

 

Biz/BrowserからPrintStreamスプールファイル(以下PSSファイル)を印刷するパッケージです。

 

クラス

 

名前

説明

Version

PC

Mobile

AI

PreviewForm

PrintStreamDocumentオブジェクトのプレビューと印刷を行います

4.0.3

-

-

PrintStreamDocument

PSSファイルを管理します

4.0.3

-

-

PrintStreamPage

PrintStreamDocumentクラスの各ページを保持します

4.0.3

-

-

 

PrintStreamの仕組み

 

 

PrintStream for InternetExplorerを利用するシステムは、次のような処理をします。

1. Internet ExplorerからWebサーバへ印刷リクエストを送ります

2. Webサーバ(PrintStreamのサーバモジュール)はqfmファイルとデータを結びつけて印刷イメージを作成し、PSSファイルに圧縮します。

3. PrintStream for InternetExplorer 2で作成した印刷イメージをダウンロードします。このときPrintStream for InternetExplorer PrintStreamの終了(全ページの印刷イメージ作成)を待たずに、作成されたPSSファイルを順次ダウンロードします。

4. ダウンロードしたPSSファイルをページ単位に解凍して表示します。

 

ここにBiz/Browserを当てはめると図1−2になります

 

 

 

PrintStreamパッケージの各クラスには、上記4Biz/Browserで行うための機能があります。(上記3HttpDownloadクラスで行います)

 

一度PrintStream for InternetExplorerで印刷した帳票はその印刷を実行したクライアントにプリンタ名や印字位置を記録します。

同じクライアントで同じ帳票をPrintStreamDocumentクラスで使用する場合は、その情報をBiz/Browserでも利用します。

 

PSSファイルの構成

 

PrintStreamは以下の仕様でPSSファイルを作成します。

・第1ブロックはdataformat.txtという印刷定義情報ファイルを含みます。

・最終ブロックは最終ページのマークが記されています。

 

 

使用例1 PrintStreamDocumentクラスで印刷する

 

処理の流れ

1. HttpDownloadクラスを使い、PSSファイルをダウンロードします。

Biz/Browserから印刷要求をした場合は、サーバのPSSファイル作成時間が必要になります。

HttpDownloadクラスはWaitRetry×RetryWait秒(最長100秒+100回×100秒≒3h)の間、PSSファイルの作成を待つことができます。

それ以上待ってもPSSファイルが作成できていない場合は「ファイルが見つからない」ステータスで終了し次のURLをダウンロードします。

 

2. HttpDownload.AsyncDownloadイベントで、PrintStreamDocument.Extractメソッドを使いPSSファイルを解凍します。

Exractメソッドが最終ブロック(最終ページマークが記録されているPSSファイル)を処理した場合は戻り値のステータスに0を返します。

 

 

 

 

 

 

3. PrintStreamDocument.PrintDocumentメソッドで印刷をします。

 

サンプル
Form FormPSS {
  PrintStreamDocument psd {
    if (!$DESIGNTIME) {
      /* サーバに「printserver」を指定します */
      var down = new HttpDownload("http://printserver"); 
      Append(down, "down");
 
      /* スプールファイルの00000001.pssから00000099.pssまで */
      /* をダウンロードします */
      down.AddURL("/spool/00000011/000000[01-99].pss"); 
 
      /*ダウンロードを開始します*/
      down.Start();
    }
 
    /* 1つのpssをダウンロードしたらすぐに解凍します */
    /* イベントの処理中はダウンロードは停止しています */
    Function OnAsyncDownload(e) {
      /* ダウンロードが成功した場合に解凍します */
      if (e.response.status == 200) {
        var rc = Extract(e.response);
        if (rc.status == 0) {
          /* メソッドの戻り値 status  0 の場合はドキュメントの終わり */
          /* なのでダウンロードを終了します */
          down.Stop();
        }
      } else {
        /*ダウンロードエラーの場合は直ちにダウンロードを終了します */
        down.Stop();
      }
    }
  }
 
  OptionButton opt1 {
    OptionItem item1[2];
    item1[0].Title = "プレビュー";
    item1[1].Title = "印刷";
    Value = 0;
  }
 
  Button btn1 {
    Title = "印刷";
    Function OnTouch(e) {
      if (^.opt1 == 1) {
        ^.psd.PrintDocument("printer");
      } else {
        ^.psd.PrintDocument("プレビュー");
      }
    }
  }
}

 

使用例2 PreviewFormクラスでプレビューする

 

処理の流れ

スプールファイルを解凍するまで(2.まで)は上記と同じです。

3. PreviewFormクラスのStartPageメソッドで表示するPrintStreamDocumentオブジェクトをセットします。

4. AddPageメソッドでプレビューするページを指定します。

5. EndPageメソッドでページ指定の終了を知らせます。

 

 

サンプル
Form Form1{
  PreviewForm PreviewForm1 {
    PrintStreamDocument psd {
      if (!$DESIGNTIME) {
        /* サーバに「printserver」を指定します */
        var down = new HttpDownload("http://printserver");
        Append(down, "down");
 
        /* スプールファイルの00000001.pssから00000099.pssまで */
        /* をダウンロードします*/
        down.AddURL("/spool/00000011/000000[01-99].pss");
        down.Start();
      }
 
      /* 1つのpssをダウンロードしたらすぐにページ単位に解凍します */
      Function OnAsyncDownload(e) {
        /*ダウンロードが成功した場合に解凍します*/
        if (e.response.status == 200) {
          var rc = Extract(e.response);
          if (rc.status == 0) {
            /* メソッドの戻り値 status  0 の場合はドキュメントの */
            /* 終わりなのでダウンロードを終了します */
            down.Stop();
          }
        } else {
          /* ダウンロードエラーの場合は直ちにダウンロードを中止します */
          down.Stop();
        }
      }
    }
 
    Function Preview() {
      var cnt = psd.GetPageCount();
      /* パラメータにはPrintStreamDocumentオブジェクトを渡します */
      StartPage(psd);
      for (var i = 0; i < cnt; i++) {
        /* PrintStreamオブジェクトの中から指定されたページを */
        /* 取り出し表示します */
        AddPage(i + 1);
      }
      /* これ以上表示するページが無いことを知らせます */
      EndPage();
    }
  }
 
  Button btn1 {
    Function OnTouch(e) {
      ^.PreviewForm1.Preview();
    }
  }
}

 

使用例3 複数のPrintStreamDocumentを一つにまとめる

 

処理の流れ

1. 2つのPSSファイルを平行ダウンロードするために2つのPrintStreamDocumentオブジェクトにそれぞれHttpDownloadオブジェクトを定義します。

2. PrintStreamDocument1PrintStreamDocument2をまとめて表示するためのPrintStreamDocument3を定義します。

3. PSSファイルを解凍した各PrintStreamDocumentから1ページ毎に取り出してPrintStreamDocument3にコピーします。

 

 

サンプル
/* http://printserver/spool/00000011/000000[01-99].pss */
/* をダウンロード・解凍します */
PrintStreamDocument PrintStreamDocument1 {
  if (!$DESIGNTIME) {
    var down = new HttpDownload("http://printserver");
    Append(down, "down");
    down.AddURL("/spool/00000011/000000[01-99].pss");
    down.Start();
  }
 
  Function OnAsyncDownload(e) {
    if (e.response.status == 200) {
      var rc = Extract(e.response);
      if (rc.status == 0) {
        down.Stop();
      }
    } else {
      down.Stop();
    }
  }
}
/* http://printserver/spool/00000012/000000[01-99].pss */
/* をダウンロード・解凍します */
PrintStreamDocument PrintStreamDocument2 {
  if (!$DESIGNTIME) {
    var down = new HttpDownload("http://printserver");
    Append(down, "down");
    down.AddURL("/spool/00000012/000000[01-99].pss");
    down.Start();
  }
 
  Function OnAsyncDownload(e) {
    if (e.response.status == 200) {
      var rc = Extract(e.response);
      if (rc.status == 0) {
        down.Stop();
      }
    } else {
      down.Stop();
    }
  }
}
 
/* PrintStreamDocument1PrintStreamDocument2 */
/* 合わせるためのオブジェクト */
PrintStreamDocument PrintStreamDocument3 {
  Function AddDoc() {
    /* PrintStreamDocument1から偶数ページをコピーする */
    var cnt = ^.PrintStreamDocument1.GetPageCount();
    for (var i = 0; i < cnt; i++) {
      if (i % 2) {
        var page = ^.PrintStreamDocument1.GetPage(i + 1);
        AddPage(page);
      }
    }
    /* PrintStreamDocumentから奇数ページをコピーする */
    var cnt = ^.PrintStreamDocument2.GetPageCount();
    for (var i = 0; i < cnt; i++) {
      if (i % 2 == 0) {
        var page = ^.PrintStreamDocument2.GetPage(i + 1);
        AddPage(page);
      }
    }
    PrintDocument("プレビュー");
  }
}

 



「オンラインマニュアル」一覧へ戻る
「Bizの宝箱」TOPへ戻る