private void concatenatePatientDocumentsToFinalPDF(String fileName, StringBuilder msg) { PatientDocumentForICPReportsVoCollection patientDocuments = domain.getPatientDocuments(form.getGlobalContext().ICP.getPatientICPRecord()); if(patientDocuments == null || patientDocuments.size() == 0) { msg.append("No Scanned documents found!"); msg.append("<br>"); return; } for(int i=0; i<patientDocuments.size(); i++) { PatientDocumentForICPReportsVo document = patientDocuments.get(i); if(document == null || !document.getServerDocumentIsNotNull()) continue; String documentName = getPDFStorePath() + document.getServerDocument().getFileName(); byte[] result = readFile(documentName); if(result != null && result.length > 0) { if(appendToFile(fileName, result) == false) { msg.append("Could not append Scanned documents!"); msg.append("<br>"); return; } } else { msg.append("Could not read Scanned document from path '" + documentName + "' !"); msg.append("<br>"); return; } } }