3

Docker の microservice-spring5 以降、PDF をプリンターに送信しようとしています。

これを行うには、Apache Camel Printer を見つけました。他に提案があればコメントしてください。

https://camel.apache.org/components/latest/lpr-component.html

だから..ポート515がlpd/lprに問題ないことを確認するためにtelnetを実行します

lpr で PDF(InputStream) をプリンターに直接送信しようとしています

public void sendToPrinter(InputStream is) {
  String sendTo = "lpr://myIpAddress/myPrinterName?flavor=DocFlavor.INPUT_STREAM&mimeType=PDF";
  try {
    ModelCamelContext context = new DefaultCamelContext();
    context.addRoutes(new RouteBuilder() {
      public void configure() {
        from("direct:start").to(sendTo);
      }
    });
    context.start(); // **exception throw here** 
    
    ProducerTemplate template = context.createProducerTemplate();
    template.start();
    template.send("direct:start", new Processor() {
      @Override
      public void process(Exchange exchange) throws Exception {
        byte[] buffer = new byte[is.available()];
        int n = is.available();
        for (int i = 0; i < n; i++) {
          buffer[i] = (byte) is.read();
        }
        is.close();
        exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
        Message in = exchange.getIn();
        in.setBody(buffer);
      }
    }
}

Exception: javax.print.PrintException: No printer found with name: myIpAddresse/myPrinterName. Please verify that the host and printer are registered and reachable from this machine.

Docker イメージ Linux でサーバー CUPS をセットアップできません。コードでプリンター サーバーに直接アドレス指定する必要があります。何か案が ?

4

0 に答える 0