List of usage examples for com.itextpdf.text.pdf PdfPTable setWidths
public void setWidths(final int relativeWidths[]) throws DocumentException
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private PdfPTable createTableTarimas() { PdfPTable table = new PdfPTable(4); PdfPCell cell;/*from w w w . j a va 2s . co m*/ cell = new PdfPCell(new Phrase("FOLIO DHL", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorRight(GRIS_CLARO); cell.setFixedHeight(20f); table.addCell(cell); cell = new PdfPCell(new Phrase("PRODUCTO (Descripcin)", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("CDIGO INTERNO", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("CANTIDAD", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); try { table.setWidths(new float[] { 1f, 1.5f, 2.5f, 1f }); table.setWidthPercentage(100); } catch (DocumentException ex) { Log.print(ex); Log.print(ex); } return table; }
From source file:com.empatkepala.view.MyPdfView.java
@Override protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception { List<CV> cvs = (List<CV>) model.get("cv"); List<String> cvValue = new ArrayList<>(); List<String> namaAtribut = new ArrayList<>(); namaAtribut.add("ID CV :"); cvValue.add(Long.toString(cvs.get(0).getIdCV())); namaAtribut.add("Uid :"); cvValue.add(cvs.get(0).getUid());//from w w w . j a v a2 s .c o m namaAtribut.add("Title :"); cvValue.add(cvs.get(0).getTitle()); // <<<<<<< feature/mpp // namaAtribut.add("Department :"); cvValue.add(cvs.get(0).getDepartment().toString()); // ======= namaAtribut.add("Department :"); cvValue.add(cvs.get(0).getDepartment()); // >>>>>>> dev namaAtribut.add("Job Title :"); cvValue.add(cvs.get(0).getJobTitle()); namaAtribut.add("Full Name :"); cvValue.add(cvs.get(0).getFullName()); namaAtribut.add("Place Date Of Birth :"); cvValue.add(cvs.get(0).getPlaceDateOfBirth()); namaAtribut.add("Id Card Number :"); cvValue.add(cvs.get(0).getIdCardNumber()); namaAtribut.add("Driving License :"); cvValue.add(cvs.get(0).getDrivingLicense().toString()); namaAtribut.add("Email :"); cvValue.add(cvs.get(0).getEmailAddress()); namaAtribut.add("twitter :"); cvValue.add(cvs.get(0).getTwitter()); namaAtribut.add("facebook :"); cvValue.add(cvs.get(0).getFacebook()); namaAtribut.add("linkedIn :"); cvValue.add(cvs.get(0).getLinkedIn()); namaAtribut.add("blog :"); cvValue.add(cvs.get(0).getBlog()); namaAtribut.add("handphone :"); cvValue.add(cvs.get(0).getHandphone()); namaAtribut.add("religion :"); cvValue.add(cvs.get(0).getReligion()); namaAtribut.add("ethnicty :"); cvValue.add(cvs.get(0).getEthnicity()); namaAtribut.add("Marital Status :"); cvValue.add(cvs.get(0).getMaritalStatus()); namaAtribut.add("Current Address :"); cvValue.add(cvs.get(0).getCurrentAddress()); namaAtribut.add("Home Address :"); cvValue.add(cvs.get(0).getHomeAddress()); namaAtribut.add("Home Phone :"); cvValue.add(cvs.get(0).getHomePhone()); namaAtribut.add("Emergency Call :"); cvValue.add(cvs.get(0).getEmergencyCall()); namaAtribut.add("Father Name :"); cvValue.add(cvs.get(0).getFatherName()); namaAtribut.add("Father Birthday :"); cvValue.add(cvs.get(0).getFatherBirthday()); namaAtribut.add("Father Latest Education :"); cvValue.add(cvs.get(0).getFatherLatestEducation()); namaAtribut.add("Father CurrentJob :"); cvValue.add(cvs.get(0).getFatherCurrentJob()); namaAtribut.add("Mother Name :"); cvValue.add(cvs.get(0).getMotherName()); namaAtribut.add("Mother Birthday :"); cvValue.add(cvs.get(0).getMotherBirthday()); namaAtribut.add("Mother Latest Education :"); cvValue.add(cvs.get(0).getMotherLatestEducation()); namaAtribut.add("Mother Current Job :"); cvValue.add(cvs.get(0).getmotherCurrentJob()); namaAtribut.add("Spouse Name :"); cvValue.add(cvs.get(0).getSpouseName()); namaAtribut.add("Spouse BirthDay :"); cvValue.add(cvs.get(0).getSpousebirthDay()); namaAtribut.add("SpouseLatestEducation :"); cvValue.add(cvs.get(0).getSpouseLatestEducation()); namaAtribut.add("SpouseCurrentJob() :"); cvValue.add(cvs.get(0).getSpouseCurrentJob()); namaAtribut.add("Responsibilities :"); cvValue.add(cvs.get(0).getResponsibilities()); namaAtribut.add("Responsibilities Type :"); cvValue.add(cvs.get(0).getResponsibilitiesType()); namaAtribut.add("School :"); cvValue.add(cvs.get(0).getSchool().get(0).getSchoolName()); namaAtribut.add("Major :"); cvValue.add(cvs.get(0).getSchool().get(0).getMajor()); namaAtribut.add("City :"); cvValue.add(cvs.get(0).getSchool().get(0).getCity()); namaAtribut.add("Periode :"); cvValue.add(cvs.get(0).getSchool().get(0).getPeriode()); namaAtribut.add("GPA :"); cvValue.add(cvs.get(0).getSchool().get(0).getGpa().toString()); namaAtribut.add("School :"); cvValue.add(cvs.get(0).getSchool().get(1).getSchoolName()); namaAtribut.add("Major :"); cvValue.add(cvs.get(0).getSchool().get(1).getMajor()); namaAtribut.add("City :"); cvValue.add(cvs.get(0).getSchool().get(1).getCity()); namaAtribut.add("Periode :"); cvValue.add(cvs.get(0).getSchool().get(1).getPeriode()); namaAtribut.add("GPA :"); cvValue.add(cvs.get(0).getSchool().get(1).getGpa().toString()); namaAtribut.add("Reason Major :"); cvValue.add(cvs.get(0).getReasonMajor()); namaAtribut.add("mother titleThesis :"); cvValue.add(cvs.get(0).getTitleThesis()); namaAtribut.add("Non Formal Course"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getNameOfCourse()); namaAtribut.add("Organizer"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getOrganizer()); namaAtribut.add("Year"); cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(0).getYear())); namaAtribut.add("Notes"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getNotes()); namaAtribut.add("Non Formal Course"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(1).getNameOfCourse()); namaAtribut.add("Organizer"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(0).getOrganizer()); namaAtribut.add("Year"); cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(1).getYear())); namaAtribut.add("Notes"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(1).getNotes()); namaAtribut.add("Non Formal Course"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getNameOfCourse()); namaAtribut.add("Organizer"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getOrganizer()); namaAtribut.add("Year"); cvValue.add(String.valueOf(cvs.get(0).getNonFrmlCrs().get(2).getYear())); namaAtribut.add("Notes"); cvValue.add(cvs.get(0).getNonFrmlCrs().get(2).getNotes()); namaAtribut.add("Achievements"); cvValue.add(cvs.get(0).getAchievements().get(0).getAchievement()); namaAtribut.add("year"); cvValue.add(String.valueOf(cvs.get(0).getAchievements().get(0).getYear())); namaAtribut.add("notes"); cvValue.add(cvs.get(0).getAchievements().get(0).getNotes()); namaAtribut.add("Achievements"); cvValue.add(cvs.get(0).getAchievements().get(1).getAchievement()); namaAtribut.add("year"); cvValue.add(String.valueOf(cvs.get(0).getAchievements().get(1).getYear())); namaAtribut.add("notes"); cvValue.add(cvs.get(0).getAchievements().get(1).getNotes()); namaAtribut.add("Social Activity"); cvValue.add(cvs.get(0).getSocialact().get(0).getNameOrganization()); namaAtribut.add("FieldOfOrganization"); cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(0).getFieldOfOrganization())); namaAtribut.add("AttendancePeriod"); cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(0).getAttendancePeriod())); namaAtribut.add("Notes"); cvValue.add(cvs.get(0).getSocialact().get(0).getNotes()); namaAtribut.add("Social Activity"); cvValue.add(cvs.get(0).getSocialact().get(1).getNameOrganization()); namaAtribut.add("FieldOfOrganization"); cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(1).getFieldOfOrganization())); namaAtribut.add("AttendancePeriod"); cvValue.add(String.valueOf(cvs.get(0).getSocialact().get(1).getAttendancePeriod())); namaAtribut.add("Notes"); cvValue.add(cvs.get(0).getSocialact().get(1).getNotes()); namaAtribut.add("Language"); cvValue.add(cvs.get(0).getLanguage().get(0).getNameOfLanguage()); namaAtribut.add("spokenLanguage"); cvValue.add(String.valueOf(cvs.get(0).getLanguage().get(0).getspokenLanguage())); namaAtribut.add("writtenLanguage"); cvValue.add(String.valueOf(cvs.get(0).getLanguage().get(0).getwrittenLanguage())); namaAtribut.add("Reason Interested In GDN :"); cvValue.add(cvs.get(0).getReasonInterestedInGDN()); namaAtribut.add("Reason Apply On That Position :"); cvValue.add(cvs.get(0).getReasonApplyOnThatPosition()); namaAtribut.add("Factor Encourage You On That Job :"); cvValue.add(cvs.get(0).getFactorEncourageYouOnThatJob()); namaAtribut.add("Kind Of Environtment :"); cvValue.add(cvs.get(0).getKindOfEnvirontment()); namaAtribut.add("LifeValue :"); cvValue.add(cvs.get(0).getLifeValue()); namaAtribut.add("SpesificSkill :"); cvValue.add(cvs.get(0).getSpesificSkill()); namaAtribut.add("Hobbies :"); cvValue.add(cvs.get(0).getHobbies()); namaAtribut.add("Describe About You :"); cvValue.add(cvs.get(0).getDescribeAboutYou()); namaAtribut.add("PlaceGetInformationGDN :"); cvValue.add(cvs.get(0).getPlaceGetInformationGDN()); namaAtribut.add("Relative Working On GDN :"); cvValue.add(cvs.get(0).getRelativeWorkingOnGDN()); namaAtribut.add("Have Applied On GDN :"); cvValue.add(cvs.get(0).getHaveAppliedOnGDN()); namaAtribut.add("Have Part Time Job :"); cvValue.add(cvs.get(0).getHavePartTimejob()); namaAtribut.add("Time Start Work :"); cvValue.add(cvs.get(0).getTimeStartWork()); namaAtribut.add("Applicant Status :"); cvValue.add(cvs.get(0).getApplicantStatus()); namaAtribut.add("Children"); cvValue.add(cvs.get(0).getChil().get(0).getChildrenName()); namaAtribut.add("Children Birthday"); cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenBirthday())); namaAtribut.add("Children Current Job"); cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenCurrentJob())); namaAtribut.add("Children Last Education"); cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChilLatestEdu())); namaAtribut.add("Children"); cvValue.add(cvs.get(0).getChil().get(0).getChildrenName()); namaAtribut.add("Children Birthday"); cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenBirthday())); namaAtribut.add("Children Current Job"); cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChildrenCurrentJob())); namaAtribut.add("Children Latest Education"); cvValue.add(String.valueOf(cvs.get(0).getChil().get(0).getChilLatestEdu())); namaAtribut.add("Brothers"); cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrothersName())); namaAtribut.add("Brother Birthday"); cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrothersBirthday())); namaAtribut.add("Brother Latest Education"); cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrotherLatestEducation())); namaAtribut.add("Brother Current Job"); cvValue.add(String.valueOf(cvs.get(0).getBro().get(0).getBrotherCurrentJob())); namaAtribut.add("Work Experience"); cvValue.add(cvs.get(0).getWorkExp().get(0).getCompanyName()); namaAtribut.add("Company Field"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getCompanyField())); namaAtribut.add("Position"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getPosition())); namaAtribut.add("Period"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getPeriod())); namaAtribut.add("Work Experience"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getJobDescription())); namaAtribut.add("Reason to Leave"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReasonToLeave())); namaAtribut.add("References Name"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferenceName())); namaAtribut.add("Reference Position"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferencePosition())); namaAtribut.add("Reference Phone Number"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getReferencePhoneNumber())); namaAtribut.add("Organization Chart"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(0).getOrganizationalChart())); namaAtribut.add("Work Experience"); cvValue.add(cvs.get(0).getWorkExp().get(1).getCompanyName()); namaAtribut.add("Company Field"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getCompanyField())); namaAtribut.add("Position"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getPosition())); namaAtribut.add("Period"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getPeriod())); namaAtribut.add("Work Experience"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getJobDescription())); namaAtribut.add("Reason to Leave"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReasonToLeave())); namaAtribut.add("References Name"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferenceName())); namaAtribut.add("Reference Position"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferencePosition())); namaAtribut.add("Reference Phone Number"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getReferencePhoneNumber())); namaAtribut.add("Organization Chart"); cvValue.add(String.valueOf(cvs.get(0).getWorkExp().get(1).getOrganizationalChart())); // PdfPTable table = new PdfPTable(2); table.setWidthPercentage(85); table.setWidths(new int[] { 3, 4 }); Font headFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD); for (CV cv : cvs) { for (int i = 0; i < namaAtribut.size(); i++) { PdfPCell hcell; hcell = new PdfPCell(new Phrase(" " + namaAtribut.get(i), headFont)); hcell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(hcell); hcell = new PdfPCell(new Phrase(" " + cvValue.get(i))); hcell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(hcell); } } // PdfPTable table = new PdfPTable(1); // table.setWidthPercentage(60); // table.setWidths(new int[] {4}); // // Font headFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD); // PdfPCell hcell; // hcell = new PdfPCell(new Phrase("Data", headFont)); // hcell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hcell.setHorizontalAlignment(Element.ALIGN_CENTER); // table.addCell(hcell); for (CV cv : cvs) { // PdfPCell cell; // // cell = new PdfPCell(new Phrase("ID CV :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(Long.toString(cv.getIdCV()))); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Uid :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getUid())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Title :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getTitle())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Job Title :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getJobTitle())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Full Name :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getFullName())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Place Date Of Birth :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getTitle())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("idCardNumber :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getIdCardNumber())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Driving License :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // ArrayList<String> sim = new ArrayList<String>(); // sim = cv.getDrivingLicense(); // cell = new PdfPCell(new Phrase(sim.toString())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Email :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getEmailAddress())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("twitter :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getTwitter())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("facebook :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getFacebook())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("linkedIn :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getLinkedIn())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("blog :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getBlog())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("handphone :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getHandphone())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("religion :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getReligion())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("ethnicty :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getEthnicity())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Marital Status :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getMaritalStatus())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Content Address :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getCurrentAddress())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Home Address :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getEmailAddress())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Home Phone :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getHomePhone())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("emergency Call :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getEmergencyCall())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Father Name :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getFatherName())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Father Birthday :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getFatherBirthday())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Father Latest Education :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getFatherLatestEducation())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Father Current Job :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getFatherCurrentJob())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Mother Name :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getMotherName())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Mother Birthday :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getMotherBirthday())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Mother Latest Education :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getEmailAddress())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Mother Current Job :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getEmailAddress())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Spouse name :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getSpouseName())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Spouse Birthday :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getSpousebirthDay())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Spouse Latest Education :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getSpouseLatestEducation())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Spouse Current Job :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getSpouseCurrentJob())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Responsibilities :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getResponsibilities())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Responsibilities Type :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getResponsibilitiesType())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase("Responsibilities :")); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); // // cell = new PdfPCell(new Phrase(cv.getResponsibilities())); // cell.setPaddingLeft(5); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // cell.setHorizontalAlignment(Element.ALIGN_LEFT); // table.addCell(cell); } document.add(table); }
From source file:com.etest.pdfgenerator.InventoryCasesReportPDF.java
public InventoryCasesReportPDF() { Document document = null;// w w w. ja v a 2 s . c o m Date date = new Date(); try { document = new Document(PageSize.LETTER, 50, 50, 50, 50); PdfWriter.getInstance(document, outputStream); document.open(); Font header = FontFactory.getFont("Times-Roman", 12, Font.BOLD); Font content = FontFactory.getFont("Times-Roman", 10); Font dateFont = FontFactory.getFont("Times-Roman", 8); Image img = null; try { img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png"); img.scaleToFit(60, 60); img.setAbsolutePosition(500, 700); } catch (BadElementException | IOException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } document.add(img); Paragraph reportTitle = new Paragraph(); reportTitle.setAlignment(Element.ALIGN_CENTER); reportTitle.add(new Phrase("Inventory of Cases Report", header)); document.add(reportTitle); Paragraph datePrinted = new Paragraph(); datePrinted.setSpacingAfter(20f); datePrinted.setAlignment(Element.ALIGN_CENTER); datePrinted.add( new Phrase("Date printed: " + new SimpleDateFormat("dd MMMM yyyy").format(date), dateFont)); document.add(datePrinted); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100); table.setWidths(new int[] { 100, 300, 100, 100 }); table.setSpacingAfter(5f); PdfPCell cellOne = new PdfPCell(new Phrase("Subject")); cellOne.setBorder(Rectangle.NO_BORDER); cellOne.setPaddingLeft(10); cellOne.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cellOne.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellTwo = new PdfPCell(new Phrase("Descriptive Title")); cellTwo.setBorder(Rectangle.NO_BORDER); cellTwo.setPaddingLeft(10); cellTwo.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cellTwo.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellThree = new PdfPCell(new Phrase("No. of Cases")); cellThree.setBorder(Rectangle.NO_BORDER); cellThree.setPaddingLeft(10); cellThree.setHorizontalAlignment(Element.ALIGN_CENTER); cellThree.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellFour = new PdfPCell(new Phrase("No. of Items")); cellFour.setBorder(Rectangle.NO_BORDER); cellFour.setPaddingLeft(10); cellFour.setHorizontalAlignment(Element.ALIGN_CENTER); cellFour.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cellOne); table.addCell(cellTwo); table.addCell(cellThree); table.addCell(cellFour); table.getDefaultCell().setBorderWidth(0f); document.add(table); for (InventoryOfCasesReport report : service.getInventoryOfCases()) { PdfPTable table2 = new PdfPTable(4); table2.setWidthPercentage(100); table2.setWidths(new int[] { 100, 300, 100, 100 }); table2.setSpacingBefore(3f); table2.setSpacingAfter(3f); if (!service.getListOfSyllabusIdByCurriculumId(report.getCurriculumId()).isEmpty()) { if (!service .getListOfCellCaseIdBySyllabusId( service.getListOfSyllabusIdByCurriculumId(report.getCurriculumId())) .isEmpty()) { PdfPCell cell1 = new PdfPCell(new Paragraph(report.getSubject(), content)); cell1.setBorder(0); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell(new Paragraph(report.getDescriptiveTitle(), content)); cell2.setBorder(0); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell(new Paragraph( String.valueOf(service.getTotalCellCasesBySyllabus( service.getListOfSyllabusIdByCurriculumId(report.getCurriculumId()))), content)); cell3.setBorder(0); cell3.setPaddingLeft(10); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell4 = new PdfPCell(new Paragraph( String.valueOf(service.getTotalCellItemsByCellCaseId( service.getListOfCellCaseIdBySyllabusId(service .getListOfSyllabusIdByCurriculumId(report.getCurriculumId())))), content)); cell4.setBorder(0); cell4.setPaddingLeft(10); cell4.setHorizontalAlignment(Element.ALIGN_CENTER); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell1); table2.addCell(cell2); table2.addCell(cell3); table2.addCell(cell4); document.add(table2); } } } } catch (DocumentException ex) { Logger.getLogger(InventoryItemsReportPDF.class.getName()).log(Level.SEVERE, null, ex); } finally { document.close(); } }
From source file:com.etest.pdfgenerator.ItemAnalysisReportPDF.java
public ItemAnalysisReportPDF(int tqCoverageId) { this.tqCoverageId = tqCoverageId; Document document = null;//from w w w . java 2s. c o m Date date = new Date(); try { document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, outputStream); document.open(); Font header = FontFactory.getFont("Times-Roman", 12, Font.BOLD); Font content = FontFactory.getFont("Times-Roman", 10); Font dateFont = FontFactory.getFont("Times-Roman", 8); Image img = null; try { img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png"); img.scaleToFit(60, 60); img.setAbsolutePosition(450, 730); } catch (BadElementException | IOException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } document.add(img); Paragraph reportTitle = new Paragraph(); reportTitle.setAlignment(Element.ALIGN_CENTER); reportTitle.add(new Phrase("Item Analysis Report", header)); document.add(reportTitle); Paragraph datePrinted = new Paragraph(); datePrinted.setSpacingAfter(20f); datePrinted.setAlignment(Element.ALIGN_CENTER); datePrinted.add( new Phrase("Date printed: " + new SimpleDateFormat("dd MMMM yyyy").format(date), dateFont)); document.add(datePrinted); Paragraph subject = new Paragraph(); subject.setAlignment(Element.ALIGN_LEFT); subject.add(new Phrase( "Subject: " + cs.getCurriculumById(tq.getTQCoverageById(getTqCoverageId()).getCurriculumId()) .getSubject().toUpperCase(), content)); document.add(subject); Paragraph term = new Paragraph(); term.setAlignment(Element.ALIGN_LEFT); term.add(new Phrase("SY and Semester Administered: 2015-16 2nd Semester", content)); document.add(term); Paragraph type = new Paragraph(); type.setSpacingAfter(20f); type.setAlignment(Element.ALIGN_LEFT); type.add( new Phrase("Type of Test: " + tq.getTQCoverageById(getTqCoverageId()).getExamTitle(), content)); document.add(type); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100); table.setWidths(new int[] { 130, 300, 300, 300, 300 }); // table.setSpacingAfter(5f); PdfPCell cellOne = new PdfPCell(new Phrase("Item No.")); cellOne.setBorderWidthTop(1); cellOne.setBorderWidthLeft(1); cellOne.setBorderWidthRight(1); cellOne.setBorderWidthBottom(1); cellOne.setPaddingLeft(10); cellOne.setPaddingRight(10); cellOne.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cellOne.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellTwo = new PdfPCell(new Phrase("Difficulty")); cellTwo.setBorderWidthTop(1); cellTwo.setBorderWidthLeft(1); cellTwo.setBorderWidthRight(1); cellTwo.setBorderWidthBottom(1); cellTwo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTwo.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellThree = new PdfPCell(new Phrase("Interpretation")); cellThree.setBorderWidthTop(1); cellThree.setBorderWidthLeft(1); cellThree.setBorderWidthRight(1); cellThree.setBorderWidthBottom(1); cellThree.setHorizontalAlignment(Element.ALIGN_CENTER); cellThree.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellFour = new PdfPCell(new Phrase("Discrimination")); cellFour.setBorderWidthTop(1); cellFour.setBorderWidthLeft(1); cellFour.setBorderWidthRight(1); cellFour.setBorderWidthBottom(1); cellFour.setHorizontalAlignment(Element.ALIGN_CENTER); cellFour.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellFive = new PdfPCell(new Phrase("Interpretation")); cellFive.setBorderWidthTop(1); cellFive.setBorderWidthLeft(1); cellFive.setBorderWidthRight(1); cellFive.setBorderWidthBottom(1); cellFive.setHorizontalAlignment(Element.ALIGN_CENTER); cellFive.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cellOne); table.addCell(cellTwo); table.addCell(cellThree); table.addCell(cellFour); table.addCell(cellFive); table.getDefaultCell().setBorderWidth(0f); document.add(table); PdfPTable table2 = new PdfPTable(5); table2.setWidthPercentage(100); table2.setWidths(new int[] { 130, 300, 300, 300, 300 }); int itemNo = 1; for (CellItem ci : cis.getItemAnalysisResult(tqCoverageId)) { PdfPCell cell1 = new PdfPCell(new Paragraph(String.valueOf(itemNo), content)); cell1.setBorderWidthTop(1); cell1.setBorderWidthLeft(1); cell1.setBorderWidthRight(1); cell1.setBorderWidthBottom(1); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell(new Paragraph(String.valueOf(ci.getDifficultIndex()), content)); cell2.setBorderWidthTop(1); cell2.setBorderWidthLeft(1); cell2.setBorderWidthRight(1); cell2.setBorderWidthBottom(1); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell(new Paragraph( ItemAnalysisInterpretation.getDifficultyInterpretation(ci.getDifficultIndex()), content)); cell3.setBorderWidthTop(1); cell3.setBorderWidthLeft(1); cell3.setBorderWidthRight(1); cell3.setBorderWidthBottom(1); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell4 = new PdfPCell(new Paragraph(String.valueOf(ci.getDiscriminationIndex()), content)); cell4.setBorderWidthTop(1); cell4.setBorderWidthLeft(1); cell4.setBorderWidthRight(1); cell4.setBorderWidthBottom(1); cell4.setHorizontalAlignment(Element.ALIGN_CENTER); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell5 = new PdfPCell(new Paragraph( ItemAnalysisInterpretation.getDiscriminationInterpretation(ci.getDiscriminationIndex()), content)); cell5.setBorderWidthTop(1); cell5.setBorderWidthLeft(1); cell5.setBorderWidthRight(1); cell5.setBorderWidthBottom(1); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell1); table2.addCell(cell2); table2.addCell(cell3); table2.addCell(cell4); table2.addCell(cell5); itemNo++; } table.getDefaultCell().setBorderWidth(0f); document.add(table2); } catch (DocumentException ex) { Logger.getLogger(ItemAnalysisReportPDF.class.getName()).log(Level.SEVERE, null, ex); } finally { document.close(); } }
From source file:com.etest.pdfgenerator.TQCoveragePDF.java
public TQCoveragePDF(int tqCoverageId) { this.tqCoverageId = tqCoverageId; Document document = null;//ww w. ja v a 2 s .c o m try { document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, outputStream); document.open(); Font header1 = FontFactory.getFont("Times-Roman", 14, Font.BOLD); Font header2 = FontFactory.getFont("Times-Roman", 12, Font.BOLD); Font content = FontFactory.getFont("Times-Roman", 10); Image img = null; try { img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png"); img.scaleToFit(60, 60); img.setAbsolutePosition(100, 720); } catch (BadElementException | IOException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } document.add(img); Paragraph title = new Paragraph(); title.setAlignment(Element.ALIGN_CENTER); title.add(new Phrase("COLLEGE OF NURSING", header2)); document.add(title); Paragraph school = new Paragraph(); school.setAlignment(Element.ALIGN_CENTER); school.add(new Phrase("Siliman University", header2)); document.add(school); Paragraph location = new Paragraph(); location.setSpacingAfter(10f); location.setAlignment(Element.ALIGN_CENTER); location.add(new Phrase("Dumaguete City", header2)); document.add(location); Paragraph examTitle = new Paragraph(); examTitle.setSpacingAfter(20f); examTitle.setAlignment(Element.ALIGN_CENTER); examTitle .add(new Phrase( cs.getCurriculumById(tq.getTQCoverageById(getTQCoverageId()).getCurriculumId()) .getSubject() + " " + tq.getTQCoverageById(getTQCoverageId()).getExamTitle(), header2)); document.add(examTitle); Paragraph instruction = new Paragraph(); instruction.setSpacingAfter(5f); instruction.setAlignment(Element.ALIGN_LEFT); instruction.add( new Phrase("INSTRUCTIONS: Read the cases carefully. Choose the letter of the correct answer. " + "Use an answer sheet and follow instruction for its use.", content)); document.add(instruction); int itemNo = 1; Map<Integer, Map<Integer, Integer>> tqCoverage = tq.getTQCoverage(getTQCoverageId()); for (Map.Entry<Integer, Map<Integer, Integer>> tqCases : tqCoverage.entrySet()) { Integer tqCaseId = tqCases.getKey(); Label caseTopic = new Label(); caseTopic.setValue(ccs.getCellCaseById(tqCaseId).getCaseTopic()); caseTopic.setContentMode(ContentMode.HTML); document.add(new Paragraph(caseTopic.getValue().replaceAll("(?i)<p.*?>.*?</p>", ""), content)); Map<Integer, Integer> value = tqCases.getValue(); for (Map.Entry<Integer, Integer> itemIds : value.entrySet()) { Integer itemId = itemIds.getKey(); Integer itemKeyId = itemIds.getValue(); List<String> keyList = k.getAllItemKey(itemId); if (keyList.isEmpty()) { ShowErrorNotification.error( "No Item Key was found for STEM: \n" + cis.getCellItemById(itemId).getItem()); return; } Label stem = new Label(); // stem.setValue(itemNo+". "+cis.getCellItemById(itemId).getItem().replace("{key}", keyList.get(0))); stem.setValue(itemNo + ". " + cis.getCellItemById(itemId).getItem().replace("{key}", k.getItemKeyById(itemKeyId))); stem.setContentMode(ContentMode.HTML); document.add(new Paragraph(stem.getValue(), content)); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setSpacingBefore(10f); table.setSpacingAfter(10f); //Set Column widths float[] columnWidths = { 1f, 1f }; table.setWidths(columnWidths); PdfPCell cell1 = new PdfPCell( new Paragraph("A) " + cis.getCellItemById(itemId).getOptionA(), content)); // cell1.setBorderColor(BaseColor.BLUE); cell1.setBorder(0); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell( new Paragraph("C) " + cis.getCellItemById(itemId).getOptionC(), content)); // cell2.setBorderColor(BaseColor.GREEN); cell2.setBorder(0); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell( new Paragraph("B) " + cis.getCellItemById(itemId).getOptionB(), content)); // cell3.setBorderColor(BaseColor.RED); cell3.setBorder(0); cell3.setPaddingLeft(10); cell3.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell4 = new PdfPCell( new Paragraph("D) " + cis.getCellItemById(itemId).getOptionD(), content)); // cell4.setBorderColor(BaseColor.RED); cell4.setBorder(0); cell4.setPaddingLeft(10); cell4.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); document.add(table); itemNo++; } } document.newPage(); Paragraph ticketNo = new Paragraph(); ticketNo.setSpacingAfter(30f); ticketNo.setAlignment(Element.ALIGN_LEFT); ticketNo.add(new Phrase("TQ Ticket #: " + tq.getTqCoverageTicketNo(getTQCoverageId()), content)); document.add(ticketNo); document.add(new Paragraph("Answer Key: ")); itemNo = 1; List<TQAnswerKey> answerKey = tq.getTQCoverageAnswerKey(getTQCoverageId()); for (TQAnswerKey t : answerKey) { document.add(new Paragraph( t.getItemNo() + ": " + cis.getOptionAnswer(t.getCellItemId()).get(t.getAnswer()))); } } catch (DocumentException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } finally { if (document != null) { document.close(); } } }
From source file:com.gadroves.gsisinve.controller.FacturarController.java
private void createItemsTable(Document doc, TbFacturaVenta facturaVenta) throws DocumentException { PdfPTable table = new PdfPTable(4); PdfPCell c1 = new PdfPCell(new Phrase("Descripcion")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);// ww w . j a va 2 s. co m c1 = new PdfPCell(new Phrase("Cantidad")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Precio Unitario")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Valor")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); //table.setHeaderRows(1); PdfPCell desc; PdfPCell cant; PdfPCell pu; PdfPCell val; for (TbLineaFac lineaFac : facturaVenta.getTbLineaFacsById()) { desc = new PdfPCell(new Phrase(lineaFac.getDescripcion())); cant = new PdfPCell(new Phrase(String.valueOf(lineaFac.getQuant()))); pu = new PdfPCell(new Phrase(String.valueOf(lineaFac.getP_unitario()))); val = new PdfPCell(new Phrase(String.valueOf(lineaFac.getTotal()))); table.addCell(desc); table.addCell(cant); table.addCell(pu); table.addCell(val); } float[] columnWidths = new float[] { 40f, 10f, 10f, 10f }; table.setWidths(columnWidths); doc.add(table); }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable bodySection() throws Exception { String exportRefRemarks = ""; String routingInsRemarks = ""; String InsStatement = ""; StringBuilder pierValues = new StringBuilder(); String[] remarkTypes = { REMARKS_TYPE_ROUTING_INSTRU, REMARKS_TYPE_EXPORT_REF }; List remarks = new LclRemarksDAO().getRemarksByTypes(lclbl.getFileNumberId(), remarkTypes); for (Object row : remarks) { Object[] col = (Object[]) row; if (col[1].toString().equalsIgnoreCase("Export Reference")) { exportRefRemarks = col[0].toString(); }// ww w . j a v a2 s .co m if (col[1].toString().equalsIgnoreCase("Routing Instruction")) { routingInsRemarks = col[0].toString(); } } String bill_type = lclbl.getBillingType(); billingType = bill_type.equalsIgnoreCase("P") ? "** FREIGHT PREPAID **" : bill_type.equalsIgnoreCase("C") ? "** FREIGHT COLLECT **" : bill_type.equalsIgnoreCase("B") && "Y".equalsIgnoreCase(printPpdBlBothKey) ? "** FREIGHT PREPAID **" : "** FREIGHT COLLECT **"; billType = bill_type.equalsIgnoreCase("P") ? "PPD" : bill_type.equalsIgnoreCase("C") ? "COL" : "BOTH"; LclSsDetail bookedOrPickedVoy = null; ExportVoyageSearchModel pickedDetails = new LclUnitSsDAO() .getPickedVoyageByVessel(lclBooking.getFileNumberId(), "E"); if (pickedDetails != null && CommonUtils.isNotEmpty(pickedDetails.getUnitSsId())) { LclUnitSs lclUnitSs = new LclUnitSsDAO().findById(Long.parseLong(pickedDetails.getUnitSsId())); bookedOrPickedVoy = lclUnitSs.getLclSsHeader().getVesselSsDetail(); unitNumber = lclUnitSs.getLclUnit().getUnitNo(); voyageNumber = lclUnitSs.getLclSsHeader().getScheduleNo(); sealOut = CommonUtils.isNotEmpty(lclUnitSs.getSUHeadingNote()) ? lclUnitSs.getSUHeadingNote().toUpperCase() : ""; } else { bookedOrPickedVoy = null != lclbl.getBookedSsHeaderId() ? lclbl.getBookedSsHeaderId().getVesselSsDetail() : null; } StringBuilder carrierName = new StringBuilder(); if (bookedOrPickedVoy != null) { sailDate = DateUtils.formatStringDateToAppFormatMMM(bookedOrPickedVoy.getStd()); sailDateFormat = DateUtils.formatDateToMMMMDDYYYY(bookedOrPickedVoy.getStd()); ladenSailDateRemarks = "\nLaden On Board:" + sailDate; if (CommonFunctions.isNotNull(bookedOrPickedVoy.getSpReferenceName())) { carrierName.append(bookedOrPickedVoy.getSpReferenceName()).append(" "); } if (CommonUtils.isNotEmpty(bookedOrPickedVoy.getTransMode())) { carrierName.append(bookedOrPickedVoy.getTransMode()).append(". "); } if (CommonUtils.isNotEmpty(bookedOrPickedVoy.getSpReferenceNo())) { carrierName.append(bookedOrPickedVoy.getSpReferenceNo()); } pierValues.append(bookedOrPickedVoy.getDeparture().getUnLocationName()); if (null != bookedOrPickedVoy.getDeparture().getStateId()) { pierValues.append("/").append(bookedOrPickedVoy.getDeparture().getStateId().getCode()); } } Paragraph p = null; table = new PdfPTable(2); table.setWidthPercentage(100f); table.setWidths(new float[] { 5.3f, 4.7f }); PdfPCell bCell = null; bCell = new PdfPCell(); bCell.setBorder(0); bCell.setPadding(0f); bCell.setBorderWidthBottom(0.06f); bCell.setBorderWidthTop(0.06f); bCell.setBorderWidthRight(0.06f); PdfPTable bTable = new PdfPTable(2); bTable.setWidths(new float[] { 5f, 4f }); bTable.setWidthPercentage(100f); bTable.addCell(makeCellLeftTopNoBorderFont("SHIPPER/EXPORTER", -0.5f, 0.8f, blackBoldFont65)); PdfPCell shCell = new PdfPCell(); shCell.setBorder(0); shCell.setColspan(2); shCell.setPadding(0f); shCell.setPaddingLeft(4f); shCell.setBorderWidthBottom(0.06f); shCell.setFixedHeight(65f); String shipperDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getShipContact()); if (CommonUtils.isNotEmpty(shipperDetails)) { p = new Paragraph(11f, "" + shipperDetails.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(15f); } else { p = new Paragraph(8f, "", totalFontQuote); shCell.setPadding(35f); } shCell.addElement(p); bTable.addCell(shCell); //consignee bTable.addCell(makeCellLeftTopNoBorderFont("CONSIGNEE", -0.5f, 0.8f, blackBoldFont65)); //consignee Values PdfPCell cvCell = new PdfPCell(); cvCell.setBorder(0); cvCell.setColspan(2); cvCell.setPadding(0f); cvCell.setPaddingLeft(4f); cvCell.setBorderWidthBottom(0.06f); cvCell.setFixedHeight(65f); String consDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getConsContact()); if (CommonUtils.isNotEmpty(consDetails)) { p = new Paragraph(11f, "" + consDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(15f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); cvCell.setPadding(30f); } cvCell.addElement(p); bTable.addCell(cvCell); //Notify bTable.addCell(makeCellLeftTopNoBorderFont("NOTIFY PARTY", -0.5f, 0.8f, blackBoldFont65)); //consignee Values PdfPCell nvCell = new PdfPCell(); nvCell.setBorder(0); nvCell.setColspan(2); nvCell.setPadding(0f); nvCell.setPaddingLeft(4f); nvCell.setBorderWidthBottom(0.06f); nvCell.setFixedHeight(70f); String notyDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getNotyContact()); if (CommonUtils.isNotEmpty(notyDetails)) { p = new Paragraph(11f, "" + notyDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(25f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); nvCell.setPadding(40f); } nvCell.addElement(p); bTable.addCell(nvCell); //place of receipt PdfPCell prCell = new PdfPCell(); prCell.setBorder(0); prCell.setPaddingLeft(-0.9f); prCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "PLACE OF RECEIPT", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); prCell.addElement(p); bTable.addCell(prCell); /* Pier Logic */ String pier = "N".equalsIgnoreCase(printPierPol) ? ("N".equalsIgnoreCase(printPierPol) && !"N".equalsIgnoreCase(hblPierOverRideKey)) ? hblPierOverRideKey : pierValues.toString() : ""; /* POL Logic */ String pol = ""; if ("Y".equalsIgnoreCase(printPierPol)) { if ("N".equalsIgnoreCase(hblPierOverRideKey)) { pol = pierValues.toString(); } else { pol = hblPierOverRideKey; } } else { pol = !"N".equalsIgnoreCase(hblPolOverRideKey) ? hblPolOverRideKey : polValues; } Boolean checkBlInsurance = new LclBlAcDAO().checkBlInsurance(lclbl.getFileNumberId(), INSURANCE_CHARGE_CODE); if (checkBlInsurance && "Y".equalsIgnoreCase(printBlInsuranceKey)) { InsStatement = LoadLogisoftProperties.getProperty("InsuranceChargeComment"); } PdfPCell pierCell = new PdfPCell(); pierCell.setBorder(0); pierCell.setBorderWidthLeft(0.06f); pierCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "PIER", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); pierCell.addElement(p); bTable.addCell(pierCell); //place of receipt values PdfPCell prvCell = new PdfPCell(); prvCell.setBorder(0); prvCell.setBorderWidthBottom(0.06f); if (lclBooking.getPooPickup()) { LclBookingPad lclBookingPad = lclBooking.getLclFileNumber().getLclBookingPadList().get(0); String pickUp_city = lclBookingPad.getPickUpCity().replaceAll("/", ","); pickUp_city = pickUp_city.substring(pickUp_city.indexOf("-") + 1, pickUp_city.length()); p = new Paragraph(7f, "" + pickUp_city.toUpperCase(), totalFontQuote); } else { StringBuilder placeofReceipt = new StringBuilder(); if (null != lclbl.getPortOfOrigin()) { placeofReceipt.append(lclbl.getPortOfOrigin().getUnLocationName()); if (CommonFunctions.isNotNull(lclbl.getPortOfOrigin().getStateId()) && CommonFunctions.isNotNull(lclbl.getPortOfOrigin().getStateId().getCode())) { placeofReceipt.append(",").append(lclbl.getPortOfOrigin().getStateId().getCode()); } } p = new Paragraph(7f, "" + placeofReceipt.toString().toUpperCase(), totalFontQuote); } p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); prvCell.addElement(p); bTable.addCell(prvCell); //pier values PdfPCell piervCell = new PdfPCell(); piervCell.setBorder(0); piervCell.setBorderWidthLeft(0.06f); piervCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + pier, totalFontQuote); p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); piervCell.addElement(p); bTable.addCell(piervCell); //exporting carrier PdfPCell ecCell = new PdfPCell(); ecCell.setBorder(0); ecCell.setPaddingLeft(-0.5f); ecCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "EXPORTING CARRIER (Vessel) (Flag)", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); ecCell.addElement(p); bTable.addCell(ecCell); //portof loading PdfPCell portCell = new PdfPCell(); portCell.setBorder(0); portCell.setPaddingTop(-0.2f); portCell.setBorderWidthLeft(0.06f); p = new Paragraph(7f, "PORT OF LOADING", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); portCell.addElement(p); bTable.addCell(portCell); //exporting values PdfPCell exvCell = new PdfPCell(); exvCell.setBorder(0); exvCell.setFixedHeight(15f); exvCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + carrierName.toString().toUpperCase(), totalFontQuote); p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); exvCell.addElement(p); bTable.addCell(exvCell); //port of loading values PdfPCell portvCell = new PdfPCell(); portvCell.setBorder(0); portvCell.setBorderWidthLeft(0.06f); portvCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + pol.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); portvCell.addElement(p); bTable.addCell(portvCell); //sea port of discharge PdfPCell seaCell = new PdfPCell(); seaCell.setBorder(0); seaCell.setPaddingLeft(-0.5f); seaCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "SEA PORT OF DISCHARGE", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); seaCell.addElement(p); bTable.addCell(seaCell); //finalde PdfPCell finalCell = new PdfPCell(); finalCell.setBorder(0); finalCell.setBorderWidthLeft(0.06f); finalCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "FINAL DELIVERY TO", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); finalCell.addElement(p); bTable.addCell(finalCell); //sea values PdfPCell seavCell = new PdfPCell(); seavCell.setBorder(0); seavCell.setFixedHeight(25f); // seavCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + podValues.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); seavCell.addElement(p); bTable.addCell(seavCell); //fina deliver values String finalDest = !fdOverride.equalsIgnoreCase("N") ? fdOverride : (agencyInfo != null && CommonUtils.isNotEmpty(agencyInfo[2])) ? agencyInfo[2] : blUtils.getBLConcatenatedFinalDestination(lclbl); PdfPCell finalvCell = new PdfPCell(); finalvCell.setBorder(0); finalvCell.setBorderWidthLeft(0.06f); p = new Paragraph(7f, !finalDest.equalsIgnoreCase(podValues) ? "" + finalDest.toUpperCase() : "", totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); finalvCell.addElement(p); bTable.addCell(finalvCell); bCell.addElement(bTable); table.addCell(bCell); //2column cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); PdfPTable pTable = new PdfPTable(2); pTable.setWidths(new float[] { 4f, 2f }); pTable.setWidthPercentage(100f); PdfPCell nCell = null; nCell = new PdfPCell(); nCell.setBorder(0); nCell.setPaddingTop(0.2f); p = new Paragraph(7f, "DOCUMENT NO", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); nCell.addElement(p); pTable.addCell(nCell); nCell = new PdfPCell(); nCell.setBorder(0); nCell.setPaddingTop(0.2f); p = new Paragraph(7f, "PAGE : " + ++page_count, blackBoldFont65); p.setAlignment(Element.ALIGN_RIGHT); nCell.addElement(p); pTable.addCell(nCell); String consolidateNumber = new LclConsolidateDAO() .getConsolidatesFileNumbers(lclbl.getLclFileNumber().getId().toString()); consolidateNumber = null == consolidateNumber ? lclbl.getLclFileNumber().getFileNumber() : lclbl.getLclFileNumber().getFileNumber() + "," + consolidateNumber; PdfPCell dvCell = new PdfPCell(); dvCell.setBorder(0); dvCell.setColspan(2); dvCell.setBorderWidthBottom(0.06f); dvCell.setPaddingLeft(8f); dvCell.setPaddingBottom(5f); dvCell.setPaddingTop(2f); p = new Paragraph(8f, "" + consolidateNumber.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); dvCell.addElement(p); pTable.addCell(dvCell); PdfPCell eCell = new PdfPCell(); eCell.setBorder(0); eCell.setPaddingTop(0.2f); eCell.setColspan(2); p = new Paragraph(7f, "EXPORT REFERENCE", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); eCell.addElement(p); pTable.addCell(eCell); PdfPCell evCell = new PdfPCell(); evCell.setBorder(0); evCell.setColspan(2); evCell.setBorderWidthBottom(0.06f); evCell.setPaddingLeft(8f); evCell.setFixedHeight(35f); exportRefRemarks = exportRefRemarks + ("EXPORT".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "") + ("EXPORT".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : ""); if (exportRefRemarks != null && !exportRefRemarks.equals("")) { p = new Paragraph(10f, "" + exportRefRemarks, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", contentBLNormalFont); } evCell.addElement(p); pTable.addCell(evCell); PdfPCell fCell = new PdfPCell(); fCell.setBorder(0); fCell.setColspan(2); fCell.setPaddingTop(0.2f); p = new Paragraph(7f, "FORWARDING AGENT-REFERENCES", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); fCell.addElement(p); pTable.addCell(fCell); //forwarding avlues PdfPCell fvCell = new PdfPCell(); fvCell.setBorder(0); fvCell.setColspan(2); fvCell.setPaddingLeft(3f); fvCell.setPaddingTop(2f); fvCell.setBorderWidthBottom(0.06f); fvCell.setFixedHeight(65f); if (null != lclbl.getFwdAcct() && !lclbl.getFwdAcct().getAccountName().equalsIgnoreCase("NO FRT. FORWARDER ASSIGNED")) { boolean forwarderAcctFlag = new LCLBlDAO() .getFreightForwardAcctStatus(lclbl.getFwdAcct().getAccountno()); String fwdDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getFwdContact()); if (CommonUtils.isNotEmpty(fwdDetails) && !forwarderAcctFlag) { p = new Paragraph(11f, "" + fwdDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(15f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); fvCell.setPadding(25f); } fvCell.addElement(p); pTable.addCell(fvCell); } else { p = new Paragraph(8f, "", totalFontQuote); fvCell.setBorderWidthBottom(0.06f); pTable.addCell(fvCell); } //pointoforigin PdfPCell pCell = new PdfPCell(); pCell.setBorder(0); pCell.setColspan(2); pCell.setPaddingTop(0.2f); p = new Paragraph(7f, "POINT AND COUNTRY OF ORIGIN", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); pCell.addElement(p); pTable.addCell(pCell); //point avlues PdfPCell pvCell = new PdfPCell(); pvCell.setBorder(0); pvCell.setColspan(2); pvCell.setPaddingLeft(8f); pvCell.setPaddingBottom(5f); pvCell.setPaddingTop(2f); pvCell.setFixedHeight(20f); pvCell.setBorderWidthBottom(0.06f); if (lclbl.getPointOfOrigin() != null) { p = new Paragraph(9f, "" + lclbl.getPointOfOrigin(), totalFontQuote); pvCell.addElement(p); } p.setAlignment(Element.ALIGN_LEFT); pTable.addCell(pvCell); //domes PdfPCell doCell = new PdfPCell(); doCell.setBorder(0); doCell.setColspan(2); doCell.setPaddingTop(0.2f); p = new Paragraph(7f, "DOMESTIC ROUTING/EXPORT INSTRUCTIONS", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); doCell.addElement(p); pTable.addCell(doCell); //point avlues PdfPCell dovCell = new PdfPCell(); dovCell.setBorder(0); dovCell.setColspan(2); dovCell.setPaddingLeft(8f); dovCell.setBorderWidthBottom(0.06f); dovCell.setFixedHeight(45f); routingInsRemarks = routingInsRemarks + ("ROUTING".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "") + ("ROUTING".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : ""); if (routingInsRemarks != null && !"".equalsIgnoreCase(routingInsRemarks)) { p = new Paragraph(10f, "" + routingInsRemarks, totalFontQuote); p.setSpacingAfter(10f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", contentBLNormalFont); dovCell.setPadding(15f); } dovCell.addElement(p); pTable.addCell(dovCell); //addito PdfPCell adCell = new PdfPCell(); adCell.setBorder(0); adCell.setColspan(2); adCell.setPaddingTop(0.2f); p = new Paragraph(7f, "ADDITIONAL DOCUMENT NUMBERS", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); adCell.addElement(p); pTable.addCell(adCell); //add values PdfPCell advCell = new PdfPCell(); advCell.setBorder(0); advCell.setColspan(2); advCell.setPadding(10f); p = new Paragraph(7f, InsStatement, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); advCell.addElement(p); pTable.addCell(advCell); cell.addElement(pTable); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable commodityValues() throws DocumentException, ParseException, Exception { Paragraph p = null;/* www. j a va 2s . com*/ table = new PdfPTable(2); table.setWidthPercentage(100f); table.setWidths(new float[] { 5f, 3.2f }); cell = new PdfPCell(); cell.setBorder(2); cell.setBorderWidthTop(0.6f); cell.setBorderWidthRight(0.6f); cell.setBorderWidthBottom(0f); if (isFirst_page) { cell.addElement(appendChargesAndCommodity()); isFirst_page = false; } else { cell.setFixedHeight(100f); } table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthTop(0.6f); cell.addElement(appendDescComments()); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); PdfPTable fileAndLogo = new PdfPTable(2); fileAndLogo.setWidthPercentage(100f); fileAndLogo.setWidths(new float[] { 4f, 2f }); PdfPCell file = new PdfPCell(); file.setBorder(0); String blNumbering = new LCLBlDAO().getExportBlNumbering(lclbl.getLclFileNumber().getId().toString()); p = new Paragraph(16f, "B/L# " + blNumbering, blackBoldFont14); file.setPaddingTop(-6f); file.addElement(p); fileAndLogo.addCell(file); String companyLogo = LoadLogisoftProperties.getProperty( "ECU".equalsIgnoreCase(ruleName) ? "application.image.logo" : "application.image.econo.logo"); Image img = Image.getInstance(servletPath + companyLogo); img.scalePercent(25); file = new PdfPCell(img); file.setBorder(0); file.setBorder(Rectangle.NO_BORDER); file.setHorizontalAlignment(Element.ALIGN_LEFT); file.setVerticalAlignment(Element.ALIGN_LEFT); file.setBorder(0); fileAndLogo.addCell(file); cell.addElement(fileAndLogo); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable appendChargesAndCommodity() throws Exception { LclBlAcDAO lclBlAcDAO = new LclBlAcDAO(); List<LclBlPiece> lclBlPiecesList = lclbl.getLclFileNumber().getLclBlPieceList(); List<LclBlAc> chargeList = lclBlAcDAO.getLclCostByFileNumberAsc(lclbl.getFileNumberId()); PdfPTable chargeTable = new PdfPTable(6); PdfPCell chargeCell = null;/*from ww w .j a va 2s .co m*/ chargeTable.setWidths(new float[] { 3.8f, 1.5f, .8f, 3.8f, 1.5f, .8f }); chargeTable.setWidthPercentage(100f); Paragraph p = null; this.total_ar_amount = 0.00; this.total_ar_col_amount = 0.00; this.total_ar_ppd_amount = 0.00; List<LinkedHashMap<String, PdfPCell>> listChargeMap = null; LinkedHashMap<String, PdfPCell> chargeMap = null; if ("BOTH".equalsIgnoreCase(billType)) { listChargeMap = this.getTotalChargesList(chargeList, lclBlPiecesList); } else { chargeMap = this.getTotalCharges(chargeList, lclBlPiecesList); } LclBlAc blAC = lclBlAcDAO.manualChargeValidate(lclbl.getFileNumberId(), "OCNFRT", false); if (lclBlPiecesList != null && lclBlPiecesList.size() > 0 && blAC != null) { BigDecimal CFT = BigDecimal.ZERO, LBS = BigDecimal.ZERO; LclBlPiece lclBlPiece = (LclBlPiece) lclBlPiecesList.get(0); if (blAC.getRatePerUnitUom() != null) { CFT = blAC.getRatePerUnitUom().equalsIgnoreCase("FRV") ? blAC.getRatePerVolumeUnit() : BigDecimal.ZERO; LBS = blAC.getRatePerUnitUom().equalsIgnoreCase("FRW") ? blAC.getRatePerWeightUnit() : BigDecimal.ZERO; } if (CFT != BigDecimal.ZERO || LBS != BigDecimal.ZERO) { StringBuilder cbmValues = new StringBuilder(); if (CFT != BigDecimal.ZERO && lclBlPiece.getActualVolumeImperial() != null) { cbmValues.append(NumberUtils .convertToThreeDecimalhash(lclBlPiece.getActualVolumeImperial().doubleValue())); } if (LBS != BigDecimal.ZERO && lclBlPiece.getActualWeightImperial() != null) { cbmValues.append(NumberUtils .convertToThreeDecimalhash(lclBlPiece.getActualWeightImperial().doubleValue())); } if (null != blAC.getArAmount() && blAC.getArAmount().toString().equalsIgnoreCase(OCNFRT_Total)) { if (CFT == BigDecimal.ZERO) { cbmValues.append(" LBS @ ").append(LBS).append(" PER 100 LBS @ ") .append(blAC.getArAmount()); } else { cbmValues.append(" CFT @ ").append(CFT).append(" PER CFT @").append(blAC.getArAmount()); } chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(6); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(6); p = new Paragraph(2f, "" + cbmValues.toString().toUpperCase(), totalFontQuote); p.add(new Paragraph(2f, null != lclBlPiece && null != lclBlPiece.getCommodityType() ? " Commodity# " + lclBlPiece.getCommodityType().getCode() : " Commodity#", totalFontQuote)); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } } } this.OCNFRT_Total = ""; LinkedHashMap<String, PdfPCell> left_chargeMap = new LinkedHashMap<String, PdfPCell>(); LinkedHashMap<String, PdfPCell> right_chargeMap = new LinkedHashMap<String, PdfPCell>(); if ("BOTH".equalsIgnoreCase(billType) && listChargeMap != null && !listChargeMap.isEmpty()) { if (listChargeMap.size() > 1) { if (listChargeMap.get(0).size() > 6 || listChargeMap.get(1).size() > 6) { chargeMap = new LinkedHashMap<String, PdfPCell>(); chargeMap.putAll(listChargeMap.get(0)); chargeMap.putAll(listChargeMap.get(1)); int count = 0, size = chargeMap.size() / 2 <= 6 ? 6 : chargeMap.size() / 2; for (String key : chargeMap.keySet()) { if (count++ < size) { left_chargeMap.put(key, chargeMap.get(key)); } else { right_chargeMap.put(key, chargeMap.get(key)); } } } else { left_chargeMap.putAll(listChargeMap.get(0)); right_chargeMap.putAll(listChargeMap.get(1)); } } else { int count = 0, size = listChargeMap.get(0).size() / 2 <= 6 ? 6 : listChargeMap.get(0).size() / 2; for (String key : listChargeMap.get(0).keySet()) { if (count++ < size) { left_chargeMap.put(key, listChargeMap.get(0).get(key)); } else { right_chargeMap.put(key, listChargeMap.get(0).get(key)); } } } } else if (chargeMap != null && !chargeMap.isEmpty()) { int count = 0, size = chargeMap.size() / 2 <= 6 ? 6 : chargeMap.size() / 2; for (String key : chargeMap.keySet()) { if (count++ < size) { left_chargeMap.put(key, chargeMap.get(key)); } else { right_chargeMap.put(key, chargeMap.get(key)); } } } if (!left_chargeMap.isEmpty()) { String chargeDesc = null; PdfPTable innner_chargeTable = new PdfPTable(2); innner_chargeTable.setWidthPercentage(100f); PdfPCell inner_chargeCell = null; chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); chargeCell.setBorderWidthRight(0.6f); chargeCell.setPadding(0); innner_chargeTable = new PdfPTable(2); innner_chargeTable.setWidths(new float[] { 5f, 3f }); if (!left_chargeMap.isEmpty()) { for (String key : left_chargeMap.keySet()) { inner_chargeCell = new PdfPCell(); inner_chargeCell.setBorder(0); inner_chargeCell.setPaddingLeft(-15); chargeDesc = key.substring(key.indexOf("#") + 1, key.indexOf("$")); inner_chargeCell.addElement(new Paragraph(7f, "" + chargeDesc, totalFontQuote)); innner_chargeTable.addCell(inner_chargeCell); inner_chargeCell = new PdfPCell(); inner_chargeCell.setBorder(0); inner_chargeCell = left_chargeMap.get(key); innner_chargeTable.addCell(inner_chargeCell); } } chargeCell.addElement(innner_chargeTable); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); chargeCell.setPadding(0); innner_chargeTable = new PdfPTable(2); innner_chargeTable.setWidths(new float[] { 5f, 3f }); if (!left_chargeMap.isEmpty()) { for (String key : right_chargeMap.keySet()) { inner_chargeCell = new PdfPCell(); inner_chargeCell.setBorder(0); inner_chargeCell.setPaddingLeft(-15); chargeDesc = key.substring(key.indexOf("#") + 1, key.indexOf("$")); inner_chargeCell.addElement(new Paragraph(7f, "" + chargeDesc, totalFontQuote)); innner_chargeTable.addCell(inner_chargeCell); inner_chargeCell = new PdfPCell(); inner_chargeCell.setBorder(0); inner_chargeCell = right_chargeMap.get(key); innner_chargeTable.addCell(inner_chargeCell); } } chargeCell.addElement(innner_chargeTable); chargeTable.addCell(chargeCell); } else { this.total_ar_amount = 0.00; this.total_ar_ppd_amount = 0.00; this.total_ar_col_amount = 0.00; } String acctNo = ""; String billToParty = ""; if (CommonFunctions.isNotNull(lclbl.getBillToParty()) && CommonUtils.isNotEmpty(lclbl.getBillToParty())) { if (lclbl.getBillToParty().equalsIgnoreCase("T") && CommonFunctions.isNotNull(lclbl.getThirdPartyAcct())) { billToParty = "THIRD PARTY"; acctNo = lclbl.getThirdPartyAcct().getAccountno(); } else if (lclbl.getBillToParty().equalsIgnoreCase("S") && CommonFunctions.isNotNull(lclbl.getShipAcct())) { billToParty = "SHIPPER"; acctNo = lclbl.getShipAcct().getAccountno(); } else if (lclbl.getBillToParty().equalsIgnoreCase("F") && CommonFunctions.isNotNull(lclbl.getFwdAcct())) { billToParty = "FORWARDER"; acctNo = lclbl.getFwdAcct().getAccountno(); } else if (lclbl.getBillToParty().equalsIgnoreCase("A") && CommonFunctions.isNotNull(lclbl.getAgentAcct())) { billToParty = "AGENT"; if (lclBooking.getBookingType().equals("T") && lclbl.getLclFileNumber().getLclBookingImport().getExportAgentAcctNo() != null) { acctNo = lclbl.getLclFileNumber().getLclBookingImport().getExportAgentAcctNo().getAccountno(); } else if (lclBooking.getAgentAcct() != null) { acctNo = lclBooking.getAgentAcct().getAccountno(); } else { acctNo = lclbl.getAgentAcct().getAccountno(); } } } if ("BOTH".equalsIgnoreCase(billType)) { if (this.total_ar_ppd_amount != 0.00 || this.total_ar_col_amount != 0.00) { if (this.total_ar_ppd_amount != 0.00) { if (CommonFunctions.isNotNullOrNotEmpty(ppdBillToSet) && ppdBillToSet.size() == 1) { for (String billTo : ppdBillToSet) { arBillToParty = billTo; break; } if (arBillToParty.equalsIgnoreCase("T")) { billToParty = "THIRD PARTY"; acctNo = null != lclbl.getThirdPartyAcct() ? lclbl.getThirdPartyAcct().getAccountno() : acctNo; } else if (arBillToParty.equalsIgnoreCase("S")) { acctNo = null != lclbl.getShipAcct() ? lclbl.getShipAcct().getAccountno() : acctNo; billToParty = "SHIPPER"; } else if (arBillToParty.equalsIgnoreCase("F")) { billToParty = "FORWARDER"; acctNo = null != lclbl.getFwdAcct() ? lclbl.getFwdAcct().getAccountno() : acctNo; } } else { acctNo = null; } chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(2); p = new Paragraph(7f, "T O T A L (USA)", totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(4); chargeCell.setBorder(0); if (null != acctNo) { p = new Paragraph(7f, "$" + NumberUtils.convertToTwoDecimal(this.total_ar_ppd_amount) + " PPD " + billToParty + "-" + acctNo, totalFontQuote); } else { p = new Paragraph(7f, "$" + NumberUtils.convertToTwoDecimal(this.total_ar_ppd_amount) + " PPD ", totalFontQuote); } p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } if (this.total_ar_col_amount != 0.00) { String colAcctNo = ""; if (lclBooking.getBookingType().equals("T") && lclbl.getLclFileNumber().getLclBookingImport().getExportAgentAcctNo() != null) { colAcctNo = lclbl.getLclFileNumber().getLclBookingImport().getExportAgentAcctNo() .getAccountno(); } else if (lclBooking.getAgentAcct() != null) { colAcctNo = lclBooking.getAgentAcct().getAccountno(); } else if (lclbl.getAgentAcct() != null) { colAcctNo = lclbl.getAgentAcct().getAccountno(); } chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(2); if (this.total_ar_ppd_amount == 0.00) { p = new Paragraph(7f, "T O T A L (USA)", totalFontQuote); } else { p = new Paragraph(7f, "", totalFontQuote); } p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(4); chargeCell.setBorder(0); p = new Paragraph(7f, "$" + NumberUtils.convertToTwoDecimal(this.total_ar_col_amount) + " COL AGENT-" + colAcctNo, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } NumberFormat numberFormat = new DecimalFormat("###,###,##0.000"); if (this.total_ar_ppd_amount != 0.00) { String totalString1 = numberFormat.format(this.total_ar_ppd_amount).replaceAll(",", ""); int indexdot = totalString1.indexOf("."); String beforeDecimal = totalString1.substring(0, indexdot); String afterDecimal = totalString1.substring(indexdot + 1, totalString1.length()); chargeCell = new PdfPCell(); chargeCell.setColspan(6); chargeCell.setBorder(0); p = new Paragraph(7f, "" + ConvertNumberToWords.convert(Integer.parseInt(beforeDecimal)) + " DOLLARS AND " + StringUtils.removeEnd(afterDecimal, "0") + " CENTS", totalFontQuote); chargeCell.setHorizontalAlignment(Element.ALIGN_CENTER); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } if (this.total_ar_col_amount != 0.00) { String totalString1 = numberFormat.format(this.total_ar_col_amount).replaceAll(",", ""); int indexdot = totalString1.indexOf("."); String beforeDecimal = totalString1.substring(0, indexdot); String afterDecimal = totalString1.substring(indexdot + 1, totalString1.length()); chargeCell = new PdfPCell(); chargeCell.setColspan(6); chargeCell.setBorder(0); p = new Paragraph(7f, "" + ConvertNumberToWords.convert(Integer.parseInt(beforeDecimal)) + " DOLLARS AND " + StringUtils.removeEnd(afterDecimal, "0") + " CENTS", totalFontQuote); chargeCell.setHorizontalAlignment(Element.ALIGN_CENTER); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } } } else if (this.total_ar_amount != 0.00) { chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(2); chargeCell.setPaddingTop(8f); p = new Paragraph(7f, "T O T A L (USA)", totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(4); chargeCell.setBorder(0); chargeCell.setPaddingTop(8f); p = new Paragraph(7f, "$" + NumberUtils.convertToTwoDecimal(this.total_ar_amount) + " " + billType + " " + billToParty + "-" + acctNo, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); NumberFormat numberFormat = new DecimalFormat("###,###,##0.000"); String totalString1 = numberFormat.format(this.total_ar_amount).replaceAll(",", ""); int indexdot = totalString1.indexOf("."); String beforeDecimal = totalString1.substring(0, indexdot); String afterDecimal = totalString1.substring(indexdot + 1, totalString1.length()); chargeCell = new PdfPCell(); chargeCell.setColspan(6); chargeCell.setBorder(0); p = new Paragraph(7f, "" + ConvertNumberToWords.convert(Integer.parseInt(beforeDecimal)) + " DOLLARS AND " + StringUtils.removeEnd(afterDecimal, "0") + " CENTS", totalFontQuote); chargeCell.setHorizontalAlignment(Element.ALIGN_CENTER); chargeCell.addElement(p); chargeTable.addCell(chargeCell); } chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(4); p = new Paragraph(5f, "" + sailDateFormat, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(5); chargeCell.setBorder(0); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setColspan(3); chargeCell.setBorder(0); chargeCell.setRowspan(3); String fdPodValue = null; if (agencyInfo != null && CommonUtils.isNotEmpty(agencyInfo[2])) { fdPodValue = agencyInfo[2]; } else if (CommonFunctions.isNotNull(lclbl.getFinalDestination()) && CommonFunctions.isNotNull(lclbl.getFinalDestination().getCountryId()) && CommonFunctions.isNotNull(lclbl.getFinalDestination().getCountryId().getCodedesc())) { fdPodValue = lclbl.getFinalDestination().getUnLocationName() + "," + lclbl.getFinalDestination().getCountryId().getCodedesc(); } p = new Paragraph(7f, fdPodValue != null ? fdPodValue.toUpperCase() : podValues.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); p = new Paragraph(5f, "UNIT# " + unitNumber, headingblackBoldFont); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); chargeCell.setPaddingTop(2f); p = new Paragraph(5f, "SEAL# " + sealOut, headingblackBoldFont); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); chargeCell = new PdfPCell(); chargeCell.setBorder(0); chargeCell.setColspan(3); chargeCell.setPaddingTop(2f); p = new Paragraph(5f, "CONTROL-VOY# " + voyageNumber, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); chargeCell.addElement(p); chargeTable.addCell(chargeCell); String emailId = ""; StringBuilder agentDetails = new StringBuilder(); //Agent Details String agentAcctNo = ""; if ("Y".equalsIgnoreCase(altAgentKey)) { agentAcctNo = CommonUtils.isNotEmpty(altAgentValue) ? altAgentValue : ""; } else if (lclbl.getAgentAcct() != null) { agentAcctNo = (agencyInfo != null && CommonUtils.isNotEmpty(agencyInfo[0])) ? agencyInfo[0] : lclbl.getAgentAcct().getAccountno(); } if (CommonUtils.isNotEmpty(agentAcctNo)) { CustAddress custAddress = new CustAddressDAO().findPrimeContact(agentAcctNo); if (CommonFunctions.isNotNull(custAddress)) { if (CommonFunctions.isNotNull(custAddress.getAcctName())) { agentDetails.append(custAddress.getAcctName()).append(" "); } if (CommonFunctions.isNotNull(custAddress.getPhone())) { agentDetails.append("Phone: ").append(custAddress.getPhone()).append("\n"); } else { agentDetails.append("\n"); } if (CommonFunctions.isNotNull(custAddress.getCoName())) { agentDetails.append(custAddress.getCoName()).append("\n"); } if (CommonFunctions.isNotNull(custAddress.getAddress1())) { agentDetails.append(custAddress.getAddress1().replace(", ", "\n")).append("\n"); } if (CommonFunctions.isNotNull(custAddress.getCity1())) { agentDetails.append(custAddress.getCity1()); } if (CommonFunctions.isNotNull(custAddress.getState())) { agentDetails.append(" ").append(custAddress.getState()); } if (CommonFunctions.isNotNull(custAddress.getEmail1())) { emailId = custAddress.getEmail1(); } } } BigDecimal PrintInvoiceValue = null; if (lclbl.getPortOfDestination() != null) { boolean schnum = new LCLPortConfigurationDAO().getSchnumValue(lclbl.getPortOfDestination().getId()); if (schnum) { BigDecimal printInvoice = lclbl.getInvoiceValue(); Long fileId = lclbl.getFileNumberId(); if (!CommonUtils.isEmpty(printInvoice) && !CommonUtils.isEmpty(fileId)) { PrintInvoiceValue = printInvoice; } } } chargeCell = new PdfPCell(); chargeCell.setBorder(2); chargeCell.setColspan(6); chargeCell.setPadding(0f); PdfPTable agent_Contact_Table = new PdfPTable(3); agent_Contact_Table.setWidthPercentage(100f); agent_Contact_Table.setWidths(new float[] { 2.3f, 1.7f, 1.8f }); PdfPCell agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setBorder(0); agent_Contact_cell.setBorderWidthTop(1f); agent_Contact_cell.setBorderWidthLeft(1f); agent_Contact_cell.setBorderWidthBottom(0.06f); agent_Contact_cell.setBorderWidthRight(1f); p = new Paragraph(7f, "To Pick Up Freight Please Contact: ", blackContentNormalFont); p.setAlignment(Element.ALIGN_LEFT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setBorder(0); agent_Contact_cell.setColspan(2); agent_Contact_cell.setBorderWidthTop(1f); agent_Contact_cell.setPaddingBottom(2f); p = new Paragraph(7f, "Email: " + emailId.toLowerCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setColspan(2); agent_Contact_cell.setBorder(0); agent_Contact_cell.setBorderWidthLeft(1f); p = new Paragraph(7f, "" + agentDetails.toString(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setBorder(0); agent_Contact_cell.setPaddingTop(27f); p = new Paragraph(7f, "" + agentAcctNo, totalFontQuote); p.setAlignment(Element.ALIGN_RIGHT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); agent_Contact_cell = new PdfPCell(); agent_Contact_cell.setBorder(0); agent_Contact_cell.setColspan(3); agent_Contact_cell.setBorderWidthLeft(1f); StringBuilder builder = new StringBuilder(); builder.append(PrintInvoiceValue != null ? "Value of Goods:USD $" + PrintInvoiceValue : ""); p = new Paragraph(3f, "" + builder.toString(), totalFontQuote); p.setAlignment(Element.ALIGN_RIGHT); agent_Contact_cell.addElement(p); agent_Contact_Table.addCell(agent_Contact_cell); chargeCell.addElement(agent_Contact_Table); chargeTable.addCell(chargeCell); return chargeTable; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable appendDescComments() throws Exception { PdfPTable descTable = new PdfPTable(5); descTable.setWidthPercentage(100f);/* w w w.j a v a 2 s.c o m*/ descTable.setWidths(new float[] { 0.1f, 0.5f, 4f, 0.5f, 0.01f }); PdfPCell descCell = null; Paragraph p = null; descCell = new PdfPCell(); descCell.setBorder(0); descCell.setColspan(5); String comments = LoadLogisoftProperties.getProperty(ruleName.equalsIgnoreCase("ECU") ? "ECU.tariffterms" : this.ruleName.equalsIgnoreCase("OTI") ? "OTI.tariffterms" : "Econo.tariffterms"); p = new Paragraph(8f, comments + "" + "" + "\n" + "IN WITNESS WHERE OF THE CARRIER BY ITS AGENT HAS SIGNED................. 3(THREE) BILLS OF LADING, ALL OF THE SAME TENOR AND DATE, " + "ONE OF WHICH BEING ACCOMPLISHED, THE OTHERS TO STAND VOID.\nPLEASE SEE OUR WEBSITE FOR TERMS AND CONDITIONS.", contentNormalFont); p.setSpacingAfter(10f); p.setAlignment(Element.ALIGN_LEFT); descCell.addElement(p); descCell.setFixedHeight(100f); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setColspan(5); descCell.setFixedHeight(10f); descCell.setBorder(0); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setColspan(2); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setBorderWidthBottom(0.06f); String carrierName = LoadLogisoftProperties.getProperty(ruleName.equalsIgnoreCase("ECU") ? "ECU.carrier" : ruleName.equalsIgnoreCase("OTI") ? "OTI.carrier" : "Econo.carrier"); p = new Paragraph(12f, "BY " + carrierName.toUpperCase(), fontCompNormalSub); p.setAlignment(Element.ALIGN_LEFT); descCell.addElement(p); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setColspan(2); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setFixedHeight(15f); descCell.setColspan(2); descCell.setBorder(0); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "", blackBoldFontSize8); p.setAlignment(Element.ALIGN_LEFT); descCell.addElement(p); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setColspan(2); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setColspan(2); descCell.setFixedHeight(15f); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setBorderWidthBottom(0.06f); p = new Paragraph(12f, "" + polValues.toUpperCase(), fontCompNormalSub); p.setAlignment(Element.ALIGN_CENTER); descCell.addElement(p); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setColspan(2); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setColspan(2); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); if ("N".equalsIgnoreCase(portKey)) { p = new Paragraph(7f, "PORT", fontCompNormalSub); } else { p = new Paragraph(7f, "PORT" + " " + portKeyValue, fontCompNormalSub); } p.setAlignment(Element.ALIGN_CENTER); descCell.addElement(p); descTable.addCell(descCell); descCell = new PdfPCell(); descCell.setBorder(0); descCell.setColspan(2); descTable.addCell(descCell); return descTable; }