Print with Java with printer configured by IP

2

Well I needed to solve a problem that is, as the software will run in the cloud, I was thinking of sending the information to the printer through it configured by IP on the machine, I already configured it in Windows but found no example right on the Internet to do it the way I want, through a fixed IP. Is there any way to tailor this code below to do this?

    try {

        InputStream inputStream = new ByteArrayInputStream(cupomNaoFiscal.getBytes());
        DocFlavor docFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
        SimpleDoc simpleDoc = new SimpleDoc(inputStream, docFlavor, null);
        PrintService printService = PrintServiceLookup.lookupDefaultPrintService();

        PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        printRequestAttributeSet.add(new JobName("Impressão", null));
        printRequestAttributeSet.add(OrientationRequested.PORTRAIT);
        printRequestAttributeSet.add(MediaSizeName.ISO_A8);
        printRequestAttributeSet.add();

        DocPrintJob docPrintJob = printService.createPrintJob();

        docPrintJob.print(simpleDoc, printRequestAttributeSet);

        inputStream.close();

    } catch (Exception e) {
        return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
    }
    
asked by anonymous 22.02.2018 / 04:50

0 answers