base 64をpdfに変換してページ表示

2089 ワード

byte[] bytes = base64String;  // base64     byte  
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(bytes); // byte      
if(baos!= null){
                httpServletResponse.setContentType("application/pdf");
                httpServletResponse.setContentLength(baos.size());
                httpServletResponse.setHeader("Expires", "0");
                httpServletResponse.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
                httpServletResponse.setHeader("Pragma", "public");
                javax.servlet.ServletOutputStream sos = httpServletResponse.getOutputStream();
                baos.writeTo(sos); //byte     servlet   
                sos.flush();
                sos.close();
                baos.close();
            }