2

プリンターを使用してローカルでpdfファイルを印刷しようとしています。これはコードです。印刷してみました。

fs.readFile('documents/AccountStatement.pdf', function(err, data) { 
    if (err)
        throw err;
    var printer = ipp.Printer("http://hostname:631/ipp/printer");
    var msg = {
    "operation-attributes-tag": {
      "requesting-user-name": "KUMA1936",
      "job-name": "My Test Job",
      "document-format": "application/pdf"
    },
    data: data
    };
    printer.execute("Print-Job", msg, function(err, res){
        console.log(res);
        console.log(err);
    });
});

上記のコードでは、printer.execute() メソッドと「Print-Job」パラメーターを実行します。そして、ここで631は何をしますか.resを印刷すると、そのショーが表示されます

{ バージョン: '1.1', statusCode: 'server-error-operation-not-supported', id: 442076, 'operation-attributes-tag': { 'attributes-charset': 'utf-8', 'attributes-natural -language': 'en-us' } } エラーは null です。

4

3 に答える 3

1

APIドキュメントを確認できます。最初のパラメーター (文字列) は、IPP によって定義された操作です。Print-Job操作説明はこちら

3.2.1 Print-Job Operation

   This REQUIRED operation allows a client to submit a print job with
   only one document and supply the document data (rather than just a
   reference to the data).  See Section 15 for the suggested steps for
   processing create operations and their Operation and Job Template
   attributes.

IPP でサポートされているその他の操作については、こちらを参照してください。631 は、TCP を使用する IPP に使用される受け入れポートです。

ここでエラーの詳細を確認できます。次のように表示されます。

13.1.5.2 server-error-operation-not-supported (0x0501)

   The IPP object does not support the functionality required to fulfill
   the request. This is the appropriate response when the IPP object
   does not recognize an operation or is not capable of supporting it.
   See sections 3.1.6.1 and 3.1.7.

これは、コードにエラーがないことを意味します。ほとんどの場合、プリンターが構成されていないか、IPP をサポートしていません。最後IPP.Printerになりましたが、プリンターの IP を指定する必要があります。したがって、指定した IP が有効であることを確認してください (コードは、ホスト名を指定したことを示しています)。プロジェクトページからそれが与えられます:

To find out if your printer supports IPP:

 - Google your printer's specs
 - Try: telnet YOUR_PRINTER 631. If it connects, that's a good sign.
 - Use the '/examples/findPrinters.js' script.
于 2013-04-24T15:44:11.827 に答える
0

私の場合、プリンターを共有するだけです:(別の人と共有するなど)

URLは次のようになります (findPrinters.jsで見つかります)

http://My-Computer-Name.local.:631/printers/my_printer_name

これは、プリンターがコンピューターに (USB などで) 接続されていない場合に役立ちます。ただし、LAN経由で接続します。

于 2014-09-09T12:46:37.697 に答える