Hi Team,
I am using below code to convert input stream to PDF conversion and then downloading that PDF file but facing performance issue . it takes 2 to 3 minutes to complete hole process.
Please tell me what’s going wrong in my code snipet.
public void convertToPdf(String policyId,Integer documentId,ServletContext context,ServletOutputStream outputStream,HttpServletResponse response, String pageFlag) throws UnsupportedEncodingException, Exception {
** Utilities.applyLicenseFromFile();**
** PolicyForm policyForm=policyManager.viewPolicyInfo(Integer.parseInt(policyId));**
** if(pageFlag!=null && pageFlag.equalsIgnoreCase(“policyListing”)){**
** documentId=policyForm.getDocumentId(); **
** } **
** LOGGER.info("Inside method convertToPdf() - Conversion Started :::::::::::::::::::::::::::::: ");**
** String fileName = “Policy “+policyForm.getPolicyNumber()+”.html”;**
** String cssFileLink=context.getRealPath("/resources/layoutcss/policyEditor.css");**
** String policyContent = new String(documentManager.openDocumentFromDMS(documentId), “UTF-8”);**
** String html=" "**
** +"
"**
** +“Policy Details
”+getPolicyDetails(policyForm)**
** +“Policy Content
”+policyContent**
** +"
** ConversionHandler conversionHandler = new ConversionHandler(new ConversionConfig());**
** PdfSaveOptions saveOption = new PdfSaveOptions();**
** byte[] bytearr = html.getBytes();**
** response.setContentType(“application/pdf”);**
** response.setHeader(“Content-Disposition”, “attachment; filename=” + “Policy “+policyForm.getPolicyNumber()+”.pdf”);**
** response.setHeader(“Cache-Control”, “no-cache”);**
** ConvertedDocument convertedDocument= conversionHandler.convert(new ByteArrayInputStream(bytearr),fileName,saveOption);**
** GroupDocsOutputStream groupDocsOutputStream = new GroupDocsOutputStream(response.getOutputStream());**
** convertedDocument.save(groupDocsOutputStream);**
** LOGGER.info("Inside method convertToPdf() - Conversion Ended :::::::::::::::::::::::::::::: ");**
** }**