Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sending jasper report output to printer using adf

Muhammad.RizwanApr 16 2015 — edited Apr 19 2015

Hi,

I am using jdev 11.1.2.4.

I've a created a Jasper report and calling it from ADF as pdf output.

is there anyway I can send it directly to a printer?

I am using below method to run the report as pdf.

public static void runReport(String repPath, java.util.Map param) throws Exception

  {

    Connection conn = null;

    try

    {

    

      HttpServletResponse response = getResponse();

      ServletOutputStream out = response.getOutputStream();

      response.setHeader("Cache-Control", "max-age=0");

      response.setContentType("application/pdf");

      ServletContext context = getContext();

      InputStream fs = context.getResourceAsStream("/reports/" + repPath);

      //System.out.println(fs.toString());

      JasperReport template = (JasperReport) JRLoader.loadObject(fs);

      template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);

      conn = getConnection();

      JasperPrint print = JasperFillManager.fillReport(template, param, conn);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      JasperExportManager.exportReportToPdfStream(print, baos);

      out.write(baos.toByteArray());

      out.flush();

      out.close();

      FacesContext.getCurrentInstance().responseComplete();

    }

    catch (Exception jex)

    {

      jex.printStackTrace();

    }

    finally

    {   

      close(conn);

    }

  }

thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2015
Added on Apr 16 2015
4 comments
2,418 views