List of usage examples for com.lowagie.text.pdf PdfCopyFields PdfCopyFields
public PdfCopyFields(OutputStream os) throws DocumentException
From source file:org.kuali.continuity.service.ReportServiceJasperImpl.java
License:Educational Community License
@SuppressWarnings("unchecked") public void runPrint(int pid, String acronymPlusName, String institutionId, String section, String filePath, OutputStream outStream) { // jasperReportService = new JasperReportServiceImpl(); // String indir="C:/ws/wsjasper/JasperAssist1/"; String indir = filePath + srcFolder; String fontDir = filePath + fontFolder; String imageDir = filePath + imageFolder + "begin-report.png"; String reportDir = filePath + report; String thisrpt = "starting"; ArrayList<String> pdfs = new ArrayList<String>(); String fs = System.getProperty("file.separator"); fontFolder = fs + "WEB-INF" + fs + "classes" + fs; GregorianCalendar now = new GregorianCalendar(); System.out.println("Start time: " + now.getTime()); Map startParameterMap = getStartParameters(pid, startSql); //rpd.getParameters(jasperReportService.getConnection(), startSql, new Integer(436)); boolean hasInstructionRows = false; boolean hasInformationRowsIt2 = false; boolean hasInformationRowsIt3 = false; boolean hasCriticalFunction = false; hasInstructionRows = hasRows(pid, instructionSql); hasInformationRowsIt2 = hasRows(pid, informationSqlIt2); hasInformationRowsIt3 = hasRows(pid, informationSqlIt3); hasCriticalFunction = hasRows(pid, criticalFunctionSql); String instructionManageTool = getInstructionManageTool(institutionId, instructionManageSql); Map<String, String> infoMap = getInfo(institutionId, getInfoSql); String optionSection = "FACULTY PREPAREDNESS"; System.out.println(" Is instruction size > 0? " + hasInstructionRows); if (section.equals("fr") && ((String) startParameterMap.get("OPTION_SECTION")).equals("INSTRUCTION") && !hasInstructionRows) { section = "in-no-data"; } else if (section.equals("fr") && ((String) startParameterMap.get("OPTION_SECTION")).equals("INSTRUCTION")) { section = "in"; } else if (section.equals("all") && ((String) startParameterMap.get("OPTION_SECTION")).equals("INSTRUCTION") && hasInstructionRows) { all[3] = "in"; } else if (section.equals("all") && ((String) startParameterMap.get("OPTION_SECTION")).equals("INSTRUCTION") && !hasInstructionRows) { all[3] = "in-no-data"; }//from w w w. j a v a2 s.c o m if (!hasCriticalFunction) { ((String[]) listMap.get("cf"))[0] = "cf1-no-data"; } else { ((String[]) listMap.get("cf"))[0] = "cf1"; } if (!hasInformationRowsIt2) { ((String[]) listMap.get("it"))[1] = "IT2-no-data"; } else { ((String[]) listMap.get("it"))[1] = "IT2"; } if (!hasInformationRowsIt3) { ((String[]) listMap.get("it"))[2] = "IT3-no-data"; } else { ((String[]) listMap.get("it"))[2] = "IT3"; } boolean isLbnl = this.systemDomainService.getById(Integer.parseInt(institutionId)).isLBNL(); if (((String) startParameterMap.get("OPTION_SECTION")).equals("FACULTY PREPAREDNESS")) { ((String[]) listMap.get("front"))[1] = "Front2-prepareness"; if (isLbnl) { optionSection = "PI PREPAREDNESS"; } else { optionSection = "FACULTY PREPAREDNESS"; } } else if (((String) startParameterMap.get("OPTION_SECTION")).equals("INSTRUCTION")) { ((String[]) listMap.get("front"))[1] = "Front2"; optionSection = "INSTRUCTION"; } String systemName = this.systemDomainService.getSystemName(Integer.parseInt(institutionId)); boolean customImage = false; if (this.systemDomainUIImageService.getImageByOwnerIdAndImageEnum(Integer.parseInt(institutionId), UIImageEnum.BANNER) != null) { customImage = true; } startParameterMap.put(ReportServiceEnum.IN_DIR.toString(), indir); startParameterMap.put(ReportServiceEnum.IMAGE_DIR.toString(), imageDir); startParameterMap.put(ReportServiceEnum.INSTITUTION_ID.toString(), instructionManageTool); startParameterMap.put(ReportServiceEnum.OPTION_SECTION.toString(), optionSection); startParameterMap.put(ReportServiceEnum.REPORT_DIR.toString(), reportDir); startParameterMap.put(ReportServiceEnum.TEAMS_SCREEN_FLAG.toString(), infoMap.get("TeamsScreenFlag")); startParameterMap.put(ReportServiceEnum.SKILLS_SCREEN_FLAG.toString(), infoMap.get("SkillsScreenFlag")); startParameterMap.put(ReportServiceEnum.STAFFING_SCREEN_FLAG.toString(), infoMap.get("StaffingScreenFlag")); startParameterMap.put(ReportServiceEnum.ACRONYM_PLUS_NAME.toString(), acronymPlusName); startParameterMap.put(ReportServiceEnum.SYSTEM_NAME.toString(), systemName); startParameterMap.put(ReportServiceEnum.DOMAIN_ID.toString(), institutionId); startParameterMap.put(ReportServiceEnum.LNBL.toString(), new Boolean(isLbnl)); startParameterMap.put(ReportServiceEnum.CUSTOM_IMAGE.toString(), new Boolean(customImage)); List<String> reports = reportList(section); try { int pg = 1; loadFonts(fontDir); PdfCopyFields copy = new PdfCopyFields(outStream); for (String report : reports) { thisrpt = report; System.out.println("runPrint: Processing: " + thisrpt); String pdfout = outFolder + report + ".pdf"; pg = pg + jasperReportService.runAdd(indir + report + ".jrxml", copy, pg, startParameterMap); pdfs.add(pdfout); } copy.close(); jasperReportService.closeStream(outStream); } catch (Exception e) { System.out.println("runPrint2: Run Exception: " + e + " processing " + thisrpt); e.printStackTrace(); } GregorianCalendar then = new GregorianCalendar(); Long diff = then.getTimeInMillis() - now.getTimeInMillis(); Double difd = diff / 1000.0; System.out.println("RSJI: End time: " + then.getTime() + " difference: " + difd); }
From source file:org.kuali.kfs.module.ar.document.service.impl.DunningLetterServiceImpl.java
License:Open Source License
/** * Loops through the collection of lookup results, creating pdfs for each and appending the bytes of the pdfs onto the returned "finalReport" * @see org.kuali.kfs.module.ar.document.service.DunningLetterDistributionService#createDunningLettersForAllResults(org.kuali.kfs.module.ar.businessobject.DunningLetterTemplate, java.util.Collection) *///from ww w .ja v a2 s . c o m @Override public byte[] createDunningLettersForAllResults(Collection<GenerateDunningLettersLookupResult> results) throws DocumentException, IOException { ByteArrayOutputStream zos = null; PdfCopyFields reportCopy = null; byte[] finalReport = null; try { zos = new ByteArrayOutputStream(); reportCopy = new PdfCopyFields(zos); reportCopy.open(); List<DunningLetterTemplate> dunningLetterTemplates = (List<DunningLetterTemplate>) getBusinessObjectService() .findAll(DunningLetterTemplate.class); for (DunningLetterTemplate dunningLetterTemplate : dunningLetterTemplates) { for (GenerateDunningLettersLookupResult generateDunningLettersLookupResult : results) { final byte[] report = createDunningLetters(dunningLetterTemplate, generateDunningLettersLookupResult); if (ObjectUtils.isNotNull(report)) { reportCopy.addDocument(new PdfReader(report)); } } } reportCopy.close(); finalReport = zos.toByteArray(); } finally { if (zos != null) { zos.close(); } } return finalReport; }
From source file:org.kuali.kfs.module.ar.document.service.impl.DunningLetterServiceImpl.java
License:Open Source License
/** * Generates the pdf file for printing the invoices. * * @param list/*www . j a va 2 s . co m*/ * @param outputStream * @throws DocumentException * @throws IOException */ protected void generateCombinedPdfForInvoices(Collection<ContractsGrantsInvoiceDocument> list, byte[] report, OutputStream outputStream) throws DocumentException, IOException { PdfCopyFields copy = new PdfCopyFields(outputStream); copy.open(); copy.addDocument(new PdfReader(report)); for (ContractsGrantsInvoiceDocument invoice : list) { for (InvoiceAddressDetail invoiceAddressDetail : invoice.getInvoiceAddressDetails()) { Note note = noteService.getNoteByNoteId(invoiceAddressDetail.getNoteId()); if (ObjectUtils.isNotNull(note) && note.getAttachment().getAttachmentFileSize() > 0) { copy.addDocument(new PdfReader(note.getAttachment().getAttachmentContents())); } } } copy.close(); }
From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java
License:Open Source License
/** * Use iText <code>{@link PdfStamper}</code> to stamp information into field values on a PDF Form Template. * * @param agency The award the values will be pulled from. * @param reportingPeriod/*from w w w. j a v a 2 s. c om*/ * @param year * @param returnStream The output stream the federal form will be written to. */ protected void stampPdfFormValues425A(ContractsAndGrantsBillingAgency agency, String reportingPeriod, String year, OutputStream returnStream, Map<String, String> replacementList) { String federalReportTemplatePath = configService .getPropertyValueAsString(KFSConstants.EXTERNALIZABLE_HELP_URL_KEY); try { final String federal425ATemplateUrl = federalReportTemplatePath + ArConstants.FF_425A_TEMPLATE_NM + KFSConstants.ReportGeneration.PDF_FILE_EXTENSION; final String federal425TemplateUrl = federalReportTemplatePath + ArConstants.FF_425_TEMPLATE_NM + KFSConstants.ReportGeneration.PDF_FILE_EXTENSION; Map<String, Object> fieldValues = new HashMap<>(); fieldValues.put(KFSPropertyConstants.AGENCY_NUMBER, agency.getAgencyNumber()); fieldValues.put(KFSPropertyConstants.ACTIVE, Boolean.TRUE); List<ContractsAndGrantsBillingAward> awards = kualiModuleService .getResponsibleModuleService(ContractsAndGrantsBillingAward.class) .getExternalizableBusinessObjectsList(ContractsAndGrantsBillingAward.class, fieldValues); Integer pageNumber = 1, totalPages; totalPages = (awards.size() / ArConstants.Federal425APdf.NUMBER_OF_SUMMARIES_PER_PAGE) + 1; PdfCopyFields copy = new PdfCopyFields(returnStream); // generate replacement list for FF425 populateListByAgency(awards, reportingPeriod, year, agency); contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.TOTAL_PAGES, org.apache.commons.lang.ObjectUtils.toString(totalPages + 1)); KualiDecimal sumCashControl = KualiDecimal.ZERO; KualiDecimal sumCumExp = KualiDecimal.ZERO; while (pageNumber <= totalPages) { List<ContractsAndGrantsBillingAward> awardsList = new ArrayList<ContractsAndGrantsBillingAward>(); for (int i = ((pageNumber - 1) * ArConstants.Federal425APdf.NUMBER_OF_SUMMARIES_PER_PAGE); i < (pageNumber * ArConstants.Federal425APdf.NUMBER_OF_SUMMARIES_PER_PAGE); i++) { if (i < awards.size()) { awardsList.add(awards.get(i)); } } // generate replacement list for FF425 List<KualiDecimal> list = populateListByAgency(awardsList, reportingPeriod, year, agency); if (CollectionUtils.isNotEmpty(list)) { sumCashControl = sumCashControl.add(list.get(0)); if (list.size() > 1) { sumCumExp = sumCumExp.add(list.get(1)); } } // populate form with document values contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.PAGE_NUMBER, org.apache.commons.lang.ObjectUtils.toString(pageNumber + 1)); if (pageNumber == totalPages) { contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.TOTAL, contractsGrantsBillingUtilityService.formatForCurrency(sumCashControl)); contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.CASH_RECEIPTS, contractsGrantsBillingUtilityService.formatForCurrency(sumCashControl)); contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.CASH_DISBURSEMENTS, contractsGrantsBillingUtilityService.formatForCurrency(sumCumExp)); contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.CASH_ON_HAND, contractsGrantsBillingUtilityService .formatForCurrency(sumCashControl.subtract(sumCumExp))); } // add a document copy.addDocument(new PdfReader(renameFieldsIn(federal425ATemplateUrl, replacementList))); pageNumber++; } contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.PAGE_NUMBER, "1"); // add the FF425 form. copy.addDocument(new PdfReader(renameFieldsIn(federal425TemplateUrl, replacementList))); // Close the PdfCopyFields object copy.close(); } catch (DocumentException | IOException ex) { throw new RuntimeException("Tried to stamp the 425A, but couldn't do it. Just...just couldn't do it.", ex); } }
From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java
License:Open Source License
/** * Generates the pdf file for printing the invoices. * * @param list// w w w.jav a 2 s . com * @param outputStream * @throws DocumentException * @throws IOException */ protected void generateCombinedPdfForInvoices(Collection<ContractsGrantsInvoiceDocument> list, OutputStream outputStream) throws DocumentException, IOException { PdfCopyFields copy = new PdfCopyFields(outputStream); boolean pageAdded = false; for (ContractsGrantsInvoiceDocument invoice : list) { // add a document List<InvoiceAddressDetail> invoiceAddressDetails = invoice.getInvoiceAddressDetails(); for (InvoiceAddressDetail invoiceAddressDetail : invoiceAddressDetails) { if (ArConstants.InvoiceTransmissionMethod.MAIL .equals(invoiceAddressDetail.getInvoiceTransmissionMethodCode())) { Note note = noteService.getNoteByNoteId(invoiceAddressDetail.getNoteId()); Integer numberOfCopiesToPrint = invoiceAddressDetail.getCustomerAddress() .getCustomerCopiesToPrint(); if (ObjectUtils.isNull(numberOfCopiesToPrint)) { numberOfCopiesToPrint = 1; } if (!ObjectUtils.isNull(note)) { for (int i = 0; i < numberOfCopiesToPrint; i++) { if (!pageAdded) { copy.open(); } pageAdded = true; copy.addDocument(new PdfReader(note.getAttachment().getAttachmentContents())); } } invoiceAddressDetail.setInitialTransmissionDate(new Date(new java.util.Date().getTime())); } } documentService.updateDocument(invoice); } if (pageAdded) { copy.close(); } }
From source file:org.oscarehr.eyeform.web.EyeformAction.java
License:Open Source License
public void doPrint(HttpServletRequest request, OutputStream os) throws IOException, DocumentException { String ids[] = request.getParameter("apptNos").split(","); String providerNo = LoggedInInfo.loggedInInfo.get().loggedInProvider.getProviderNo(); String cpp = request.getParameter("cpp"); boolean cppFromMeasurements = false; if (cpp != null && cpp.equals("measurements")) { cppFromMeasurements = true;/*from www. j a v a 2s . c om*/ } String[] customCppIssues = OscarProperties.getInstance().getProperty("encounter.custom_cpp_issues", "") .split(","); PdfCopyFields finalDoc = new PdfCopyFields(os); finalDoc.getWriter().setStrictImageSequence(true); PdfRecordPrinter printer = new PdfRecordPrinter(request, os); int pageNum = 0; //loop through each visit..concatenate into 1 PDF for (int x = 0; x < ids.length; x++) { if (!StringUtils.isBlank(ids[x])) { int appointmentNo = Integer.parseInt(ids[x]); Appointment appointment = appointmentDao.find(appointmentNo); if (appointment == null) continue; else pageNum++; if (pageNum > 1) { printer.setNewPage(true); } Demographic demographic = demographicDao.getClientByDemographicNo(appointment.getDemographicNo()); printer.setDemographic(demographic); printer.setAppointment(appointment); //need to get notes first to set the signing provider List<CaseManagementNote> notes = caseManagementNoteDao .getMostRecentNotesByAppointmentNo(appointmentNo); notes = filterOutCpp(notes); if (notes.size() > 0) { String tmp = notes.get(0).getSigning_provider_no(); if (tmp != null && tmp.length() > 0) { Provider signingProvider = providerDao.getProvider(tmp); if (signingProvider != null) { printer.setSigningProvider(signingProvider.getFormattedName()); } } } printer.printDocHeaderFooter(); //get cpp items by appointmentNo (current history,past ocular hx, //medical hx, ocular meds, other meds, diagnostic notes /* if(cppFromMeasurements) { printCppItemFromMeasurements(printer,"Current History","cpp_currentHis",demographic.getDemographicNo(), appointmentNo, false); printCppItemFromMeasurements(printer,"Past Ocular History","cpp_pastOcularHis",demographic.getDemographicNo(), appointmentNo, true); printCppItemFromMeasurements(printer,"Medical History","cpp_medicalHis",demographic.getDemographicNo(), appointmentNo, true); printCppItemFromMeasurements(printer,"Family History","cpp_familyHis",demographic.getDemographicNo(), appointmentNo, true); printCppItemFromMeasurements(printer,"Diagnostic Notes","cpp_diagnostics",demographic.getDemographicNo(), appointmentNo, false); printCppItemFromMeasurements(printer,"Ocular Medication","cpp_ocularMeds",demographic.getDemographicNo(), appointmentNo, true); } else { */ Boolean includeCPPForPrevAppts = null; OscarProperties oscarProperties = OscarProperties.getInstance(); String eyeform_onlyPrintCurrentVisit = oscarProperties.getProperty("eyeform_onlyPrintCurrentVisit"); // if eyeform_onlyPrintCurrentVisit is not set at all then it should work as previously.. if (eyeform_onlyPrintCurrentVisit != null && eyeform_onlyPrintCurrentVisit.trim().length() > 0) { eyeform_onlyPrintCurrentVisit = eyeform_onlyPrintCurrentVisit.trim(); boolean onlyPrintCurrentApptRecordsFromEncounter = Boolean .parseBoolean(eyeform_onlyPrintCurrentVisit); //if only print current appt.. then includeCPPForPrevAppts = false if (onlyPrintCurrentApptRecordsFromEncounter) includeCPPForPrevAppts = false; else includeCPPForPrevAppts = true; } String whichEyeForm = OscarProperties.getInstance().getProperty("cme_js", ""); IssueDAO issueDao = (IssueDAO) SpringUtils.getBean("IssueDAO"); for (String customCppIssue : customCppIssues) { //Don't need to print out patient log if (customCppIssue != null && (customCppIssue.equalsIgnoreCase("PatientLog") || customCppIssue.equalsIgnoreCase("GlaucomaRiskFactors"))) continue; if (includeCPPForPrevAppts != null) { if (customCppIssue != null && customCppIssue.equalsIgnoreCase("GlaucomaRiskFactors")) { //For Dr.Jinapriya, replace PatientLog with GlaucomaRiskFactors, but still use PatientLog issue. Issue i = issueDao.findIssueByCode("PatientLog"); if (i != null) { printCppItem(printer, "Glaucoma Risk Factors", "PatientLog", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); } } else { //="PatientLog", or Misc Issue issue = issueDao.findIssueByCode(customCppIssue); if (issue != null) { printCppItem(printer, issue.getDescription(), customCppIssue, demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); } } } else { if (customCppIssue != null && customCppIssue.equalsIgnoreCase("GlaucomaRiskFactors")) { //For Dr.Jinapriya, replace PatientLog with GlaucomaRiskFactors, but still use PatientLog issue. Issue i = issueDao.findIssueByCode("PatientLog"); if (i != null) { printCppItem(printer, "Glaucoma Risk Factors", "PatientLog", demographic.getDemographicNo(), appointmentNo, true); } } else { //="PatientLog", or Misc Issue issue = issueDao.findIssueByCode(customCppIssue); if (issue != null) { printCppItem(printer, issue.getDescription(), customCppIssue, demographic.getDemographicNo(), appointmentNo, true); } } } } if (includeCPPForPrevAppts != null) { if (whichEyeForm != null && whichEyeForm.equalsIgnoreCase("eyeform_DrJinapriya")) { printCppItem(printer, "Subjective", "CurrentHistory", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Past Ocular History", "PastOcularHistory", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Medical History", "MedHistory", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Ocular Diagnoses", "FamHistory", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Objective", "DiagnosticNotes", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Drops Administered This Visit", "OcularMedication", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Systemic Meds", "OMeds", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); } else { printCppItem(printer, "Current History", "CurrentHistory", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Past Ocular History", "PastOcularHistory", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Medical History", "MedHistory", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Family History", "FamHistory", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Diagnostic Notes", "DiagnosticNotes", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Ocular Medications", "OcularMedication", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); printCppItem(printer, "Other Medications", "OMeds", demographic.getDemographicNo(), appointmentNo, includeCPPForPrevAppts); } } else { if (whichEyeForm != null && whichEyeForm.equalsIgnoreCase("eyeform_DrJinapriya")) { printCppItem(printer, "Subjective", "CurrentHistory", demographic.getDemographicNo(), appointmentNo, false); printCppItem(printer, "Past Ocular History", "PastOcularHistory", demographic.getDemographicNo(), appointmentNo, true); printCppItem(printer, "Medical History", "MedHistory", demographic.getDemographicNo(), appointmentNo, true); printCppItem(printer, "Ocular Diagnoses", "FamHistory", demographic.getDemographicNo(), appointmentNo, true); printCppItem(printer, "Objective", "DiagnosticNotes", demographic.getDemographicNo(), appointmentNo, false); printCppItem(printer, "Drops Administered This Visit", "OcularMedication", demographic.getDemographicNo(), appointmentNo, true); printCppItem(printer, "Systemic Meds", "OMeds", demographic.getDemographicNo(), appointmentNo, true); } else { //work as it is printCppItem(printer, "Current History", "CurrentHistory", demographic.getDemographicNo(), appointmentNo, false); printCppItem(printer, "Past Ocular History", "PastOcularHistory", demographic.getDemographicNo(), appointmentNo, true); printCppItem(printer, "Medical History", "MedHistory", demographic.getDemographicNo(), appointmentNo, true); printCppItem(printer, "Family History", "FamHistory", demographic.getDemographicNo(), appointmentNo, true); printCppItem(printer, "Diagnostic Notes", "DiagnosticNotes", demographic.getDemographicNo(), appointmentNo, false); printCppItem(printer, "Ocular Medications", "OcularMedication", demographic.getDemographicNo(), appointmentNo, true); printCppItem(printer, "Other Medications", "OMeds", demographic.getDemographicNo(), appointmentNo, true); } } printer.setNewPage(true); //ocular procs List<EyeformOcularProcedure> ocularProcs = null; if (includeCPPForPrevAppts == null || includeCPPForPrevAppts == true) ocularProcs = ocularProcDao.getAllPreviousAndCurrent(demographic.getDemographicNo(), appointmentNo); else ocularProcs = ocularProcDao.getAllCurrent(demographic.getDemographicNo(), appointmentNo); if (ocularProcs.size() > 0) { printer.printOcularProcedures(ocularProcs); } //specs history List<EyeformSpecsHistory> specsHistory; if (includeCPPForPrevAppts == null || includeCPPForPrevAppts == true) specsHistory = specsHistoryDao.getAllPreviousAndCurrent(demographic.getDemographicNo(), appointmentNo); else specsHistory = specsHistoryDao.getAllCurrent(demographic.getDemographicNo(), appointmentNo); if (specsHistory.size() > 0) { printer.printSpecsHistory(specsHistory); } //allergies List<Allergy> allergies = allergyDao.findAllergies(demographic.getDemographicNo()); if (allergies.size() > 0) { printer.printAllergies(allergies); } //rx printer.printRx(String.valueOf(demographic.getDemographicNo())); //measurements List<Measurements> measurements = measurementsDao.getMeasurementsByAppointment2(appointmentNo); if (measurements.size() > 0) { /* if(cppFromMeasurements) { if(getNumMeasurementsWithoutCpp(measurements)>0) { MeasurementFormatter formatter = new MeasurementFormatter(measurements); printer.printEyeformMeasurements(formatter); } } else { */ MeasurementFormatter formatter = new MeasurementFormatter(measurements); printer.printEyeformMeasurements(formatter); // } } //impression //let's filter out custom cpp notes, as they will already have been //printed out in CPP section List<CaseManagementNote> filteredNotes = new ArrayList<CaseManagementNote>(); for (CaseManagementNote note : notes) { boolean okToAdd = true; for (String i : customCppIssues) { if (i.equalsIgnoreCase("GlaucomaRiskFactors")) { //Dr.Jinapriy's GlaucomaRiskFactors=PatientLog in eyeform2 from Dr.Eric Tam if (containsIssue(note.getId().intValue(), "PatientLog")) { okToAdd = false; break; } } else { if (containsIssue(note.getId().intValue(), i)) { okToAdd = false; break; } } } if (okToAdd) filteredNotes.add(note); } if (filteredNotes.size() > 0) { printer.printNotes(filteredNotes); } //plan - followups/consults, procedures booked, tests booked, checkboxes /* List<FollowUp> followUps = followUpDao.getByAppointmentNo(appointmentNo); List<ProcedureBook> procedureBooks = procedureBookDao.getByAppointmentNo(appointmentNo); List<TestBookRecord> testBooks = testBookDao.getByAppointmentNo(appointmentNo); EyeForm eyeform = eyeFormDao.getByAppointmentNo(appointmentNo); printer.printEyeformPlan(followUps, procedureBooks, testBooks,eyeform); */ //photos DocumentResultsDao documentDao = (DocumentResultsDao) SpringUtils.getBean("documentResultsDao"); List<Document> documents = documentDao.getPhotosByAppointmentNo(appointmentNo); if (documents.size() > 0) { String servletUrl = request.getRequestURL().toString(); String url = servletUrl.substring(0, servletUrl.indexOf(request.getContextPath()) + request.getContextPath().length()); printer.printPhotos(url, documents); } //diagrams EFormValueDao eFormValueDao = (EFormValueDao) SpringUtils.getBean("EFormValueDao"); EFormGroupDao eFormGroupDao = (EFormGroupDao) SpringUtils.getBean("EFormGroupDao"); List<EFormGroup> groupForms = eFormGroupDao.getByGroupName("Eye form"); List<EFormValue> values = eFormValueDao.findByApptNo(appointmentNo); List<EFormValue> diagrams = new ArrayList<EFormValue>(); for (EFormValue value : values) { int formId = value.getFormId(); boolean include = false; for (EFormGroup group : groupForms) { if (group.getFormId() == formId) { include = true; break; } } if (include) diagrams.add(value); } if (diagrams.size() > 0) { printer.printDiagrams(diagrams); } } //!=null } //end of loop if (pageNum == 0) { printer.setNewPage(true); } printer.finish(); }
From source file:org.sejda.impl.itext.component.FormFieldsAwarePdfCopier.java
License:Apache License
public FormFieldsAwarePdfCopier(File outputFile, PdfVersion version) throws TaskException { try {//from w w w .j ava2s . c o m outputStream = new FileOutputStream(outputFile); if (version == null) { pdfCopy = new PdfCopyFields(outputStream); } else { pdfCopy = new PdfCopyFields(outputStream, version.getVersionAsCharacter()); } pdfCopy.getWriter().getInfo().put(PdfName.CREATOR, new PdfString(Sejda.CREATOR, PdfObject.TEXT_UNICODE)); } catch (FileNotFoundException e) { throw new TaskException(String.format("Unable to find the output file %s", outputFile.getPath()), e); } catch (DocumentException e) { throw new TaskException("An error occurred opening the PdfCopyFields.", e); } }
From source file:us.mn.state.health.lims.reports.action.implementation.CollectionReport.java
License:Mozilla Public License
protected byte[] merge(List<byte[]> byteList) throws DocumentException { byte[] outputBytes; OutputStream outputStream = new ByteArrayOutputStream(); try {//from w w w .j ava 2 s .c om PdfCopyFields pcf = new PdfCopyFields(outputStream); for (byte[] bytes : byteList) { ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); PdfReader pdfReader = new PdfReader(inputStream); // place holder in case we do have to rotate // if (false) { // int n = pdfReader.getNumberOfPages(); // int rot; // PdfDictionary pageDict; // for (int i = 1; i <= n; i++) { // rot = pdfReader.getPageRotation(i); // pageDict = pdfReader.getPageN(i); // pageDict.put(PdfName.ROTATE, new PdfNumber(rot + 90)); // } // } pcf.addDocument(pdfReader); } if (!byteList.isEmpty()) { pcf.close(); } outputBytes = ((ByteArrayOutputStream) outputStream).toByteArray(); return outputBytes; } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } finally { try { if (outputStream != null) outputStream.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } return null; }
From source file:util.MyPDFFiles.java
public static void concatenar2PDF(String file1, String file2, String fileSale) throws Exception { System.out.println("Concatenate Two PDF"); PdfReader reader1 = new PdfReader(file1); PdfReader reader2 = new PdfReader(file2); PdfCopyFields copy = new PdfCopyFields(new FileOutputStream(fileSale)); copy.addDocument(reader1);/*from ww w . ja v a2 s . co m*/ copy.addDocument(reader2); copy.close(); }