码迷,mamicode.com
首页 > 其他好文 > 详细

OAF_文件系列12_实现OAF导出PDF方式TemplateHelper(案例)

时间:2015-08-05 12:00:31      阅读:388      评论:0      收藏:0      [点我收藏+]

标签:

http://wenku.baidu.com/link?url=ujbT5CHkeC1bAtUn9Nsm_FgVB4k4nAWwwlphukyPGKNoPv5cDjRONWAZmf6RejggMg9onxIg_Rqi_gKKV665EVffofZ3Ds_IdKh9Y3tsKZq

 

    public void PrintPDF(OAPageContext pageContext, OAWebBean webBean,
                         CLOB xmlClob, String printType,
                         String paymentRequestId) {
        HttpServletResponse response =
            (HttpServletResponse)pageContext.getRenderingContext().getServletResponse();
        // Set the Output Report File Name and Content Type
        String contentDisposition;
        String fileName;
        try {
            if ("INVOICE".equals(printType)) {
                fileName = "后补发票";
            } else {
                fileName = "付款申请";
            }
            contentDisposition =
                    "attachment;filename=" + java.net.URLEncoder.encode(fileName,
                                                                        "UTF-8") +
                    paymentRequestId + ".pdf";

            response.setHeader("Content-Disposition", contentDisposition);
            response.setContentType("application/pdf");
            Reader inputReader = xmlClob.getCharacterStream();
            OADBTransactionImpl oaTrans =
                (OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction();
            String templateName = "";
            if ("CON".equals(printType)) {
                templateName = "XVK_NO_CNT_PAYMENT_REQUEST";
            } else if ("INVOICE".equals(printType)) {
                templateName = "XVK_ADD_INV_PAYMENT_REQUEST";
            } else {
                templateName = "XVK_CONTRACT_PAYMENT_REQUEST";
            }
            TemplateHelper.processTemplate(oaTrans.getAppsContext(), "XVK",
                                           templateName, "zh", "CN",
                                           inputReader,
                                           TemplateHelper.OUTPUT_TYPE_PDF,
                                           null, response.getOutputStream());

            response.getOutputStream().flush();
            response.getOutputStream().close();
        } catch (Exception e) {
            response.setContentType("text/html");
            throw new OAException(e.getMessage(), OAException.ERROR);
        }

        pageContext.setDocumentRendered(false);
    }

OAF_文件系列12_实现OAF导出PDF方式TemplateHelper(案例)

标签:

原文地址:http://www.cnblogs.com/eastsea/p/4704041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!