Dharma Teja Thammu (DharmaTejaT5078)
Corporation Service Company
Senior Software Engineer
Corporation Service Company
DharmaTejaT5078 Member since 2019 2 posts
Corporation Service Company
Posted: January 27, 2021
Last activity: January 28, 2021
Posted: 27 Jan 2021 15:29 EST
Last activity: 28 Jan 2021 22:41 EST

Print PDF

I have a requirement to print PDF through a background job in the application. I am planning to set up a Job scheduler and invoke a activity. However this code only seems to connect to a printer but unable to print. any ideas? socket = null; addr = null; socketAddress = null; reader= null; writer= null; input = null; output= null;

int port =9100; int timeout=5000; byte[] bodyBytes = null; //byte[] modifiedBodyBytes = null; //String bodyString = null;


    addr =;     socket = new, port);     socket.setSoTimeout(timeout);        bodyBytes = new;     oLog.infoForced("TestPrinter bodyBytes length "+bodyBytes.length);    // BodyString = new String(bodyBytes, "US-ASCII");    // modifiedBodyBytes= BodyString.getBytes("US-ASCII");

    output = socket.getOutputStream();       oLog.infoForced("TestPrinter output stream "+output);           input = socket.getInputStream();     oLog.infoForced("TestPrinter input stream "+input);            // kick it out     output.write(bodyBytes);     output.flush();     oLog.infoForced("TestPrinter output stream "+output);        socket.shutdownOutput();        reader = new;      oLog.infoForced("TestPrinter read input stream "+reader);     printerResponse = reader.readLine();     oLog.infoForced("TestPrinter printer response "+printerResponse);          status = "success";     }   catch (Exception e) {   e.printStackTrace();     //oLog.error("TestPrinter Error in sending to printer ");   oLog.error("TestPrinter"+e);

  status = "fail"; } finally {     if (input != null) try { input.close();oLog.infoForced("TestPrinter closed input stream ");} catch (Exception e) {oLog.infoForced("TestPrinter Issue closing input stream ");   }   if (socket != null) try { socket.close(); oLog.infoForced("TestPrinter closed socket connection ");} catch (Exception e) {oLog.infoForced("TestPrinter Issue closing socket ");   }     if (output != null) try { output.close(); oLog.infoForced("TestPrinter closed output stream ");} catch (Exception e) {oLog.infoForced("TestPrinter Issue closing output stream ");} }

Pega Platform 8.3.3 Case Management Financial Services Senior System Architect