Example usage for com.itextpdf.text FontFactory HELVETICA_BOLD

List of usage examples for com.itextpdf.text FontFactory HELVETICA_BOLD

Introduction

In this page you can find the example usage for com.itextpdf.text FontFactory HELVETICA_BOLD.

Prototype

String HELVETICA_BOLD

To view the source code for com.itextpdf.text FontFactory HELVETICA_BOLD.

Click Source Link

Document

This is a possible value of a base 14 type 1 font

Usage

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());/*  w w  w. j  av a2  s .  co  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:fll.web.playoff.ScoresheetGenerator.java

License:Open Source License

public void writeFile(final OutputStream out, final boolean orientationIsPortrait) throws DocumentException {

    // This creates our new PDF document and declares its orientation
    Document pdfDoc;/*  w  w  w  . j  a  va  2 s.c  o  m*/
    if (orientationIsPortrait) {
        pdfDoc = new Document(PageSize.LETTER); // portrait
    } else {
        pdfDoc = new Document(PageSize.LETTER.rotate()); // landscape
    }
    PdfWriter.getInstance(pdfDoc, out);

    // Measurements are always in points (72 per inch)
    // This sets up 1/2 inch margins side margins and 0.35in top and bottom
    // margins
    pdfDoc.setMargins(0.5f * POINTS_PER_INCH, 0.5f * POINTS_PER_INCH, 0.35f * POINTS_PER_INCH,
            0.35f * POINTS_PER_INCH);
    pdfDoc.open();

    // Header cell with challenge title to add to both scoresheets
    final Paragraph titleParagraph = new Paragraph();
    final Chunk titleChunk = new Chunk(m_pageTitle,
            FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14, Font.NORMAL, BaseColor.WHITE));
    titleParagraph.setAlignment(Element.ALIGN_CENTER);
    titleParagraph.add(titleChunk);

    titleParagraph.add(Chunk.NEWLINE);
    final Chunk swVersionChunk = new Chunk("SW version: " + Version.getVersion(),
            FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE));
    titleParagraph.add(swVersionChunk);
    if (null != m_revision) {

        final Chunk revisionChunk = new Chunk(" Descriptor revision: " + m_revision,
                FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE));

        titleParagraph.add(revisionChunk);
    }

    final PdfPCell head = new PdfPCell();
    head.setColspan(2);
    head.setBorder(1);
    head.setPaddingTop(0);
    head.setPaddingBottom(3);
    head.setBackgroundColor(new BaseColor(64, 64, 64));
    head.setVerticalAlignment(Element.ALIGN_TOP);
    head.addElement(titleParagraph);

    // Cells for score field, and 2nd check initials
    final Phrase des = new Phrase("Data Entry Score _______", ARIAL_8PT_NORMAL);
    final PdfPCell desC = new PdfPCell(des);
    desC.setBorder(0);
    desC.setPaddingTop(9);
    desC.setPaddingRight(36);
    desC.setHorizontalAlignment(Element.ALIGN_RIGHT);
    final Phrase sci = new Phrase("2nd Check Initials _______", ARIAL_8PT_NORMAL);
    final PdfPCell sciC = new PdfPCell(sci);
    sciC.setBorder(0);
    sciC.setPaddingTop(9);
    sciC.setPaddingRight(36);
    sciC.setHorizontalAlignment(Element.ALIGN_RIGHT);

    // Create a table with a grid cell for each scoresheet on the page
    PdfPTable wholePage = getTableForPage(orientationIsPortrait);
    wholePage.setWidthPercentage(100);
    for (int i = 0; i < m_numSheets; i++) {
        if (i > 0 && (orientationIsPortrait || (i % 2) == 0)) {
            pdfDoc.newPage();
            wholePage = getTableForPage(orientationIsPortrait);
            wholePage.setWidthPercentage(100);
        }

        // This table is a single score sheet
        final PdfPTable scoreSheet = new PdfPTable(2);
        // scoreSheet.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.BOTTOM
        // | Rectangle.RIGHT | Rectangle.TOP); //FIXME DEBUG should be NO_BORDER
        scoreSheet.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        scoreSheet.getDefaultCell().setPaddingRight(1);
        scoreSheet.getDefaultCell().setPaddingLeft(0);

        scoreSheet.addCell(head);

        final PdfPTable teamInfo = new PdfPTable(7);
        teamInfo.setWidthPercentage(100);
        teamInfo.setWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f, .9f });

        // Time label cell
        final Paragraph timeP = new Paragraph("Time:", ARIAL_10PT_NORMAL);
        timeP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell timeLc = new PdfPCell(scoreSheet.getDefaultCell());
        timeLc.addElement(timeP);
        teamInfo.addCell(timeLc);
        // Time value cell
        final Paragraph timeV = new Paragraph(null == m_time[i] ? SHORT_BLANK : m_time[i], COURIER_10PT_NORMAL);
        final PdfPCell timeVc = new PdfPCell(scoreSheet.getDefaultCell());
        timeVc.addElement(timeV);
        teamInfo.addCell(timeVc);

        // Table label cell
        final Paragraph tblP = new Paragraph("Table:", ARIAL_10PT_NORMAL);
        tblP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell tblLc = new PdfPCell(scoreSheet.getDefaultCell());
        tblLc.addElement(tblP);
        teamInfo.addCell(tblLc);
        // Table value cell
        final Paragraph tblV = new Paragraph(m_table[i], COURIER_10PT_NORMAL);
        final PdfPCell tblVc = new PdfPCell(scoreSheet.getDefaultCell());
        tblVc.addElement(tblV);
        teamInfo.addCell(tblVc);

        // Round number label cell
        final Paragraph rndP = new Paragraph("Round:", ARIAL_10PT_NORMAL);
        rndP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell rndlc = new PdfPCell(scoreSheet.getDefaultCell());
        rndlc.addElement(rndP);
        teamInfo.addCell(rndlc);
        // Round number value cell
        final Paragraph rndV = new Paragraph(m_round[i], COURIER_10PT_NORMAL);
        final PdfPCell rndVc = new PdfPCell(scoreSheet.getDefaultCell());
        // rndVc.setColspan(2);
        rndVc.addElement(rndV);
        teamInfo.addCell(rndVc);

        final PdfPCell temp1 = new PdfPCell(scoreSheet.getDefaultCell());
        // temp1.setColspan(2);
        temp1.addElement(new Paragraph("Judge ____", ARIAL_8PT_NORMAL));
        teamInfo.addCell(temp1);

        // Team number label cell
        final Paragraph nbrP = new Paragraph("Team #:", ARIAL_10PT_NORMAL);
        nbrP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell nbrlc = new PdfPCell(scoreSheet.getDefaultCell());
        nbrlc.addElement(nbrP);
        teamInfo.addCell(nbrlc);
        // Team number value cell
        final Paragraph nbrV = new Paragraph(null == m_number[i] ? SHORT_BLANK : String.valueOf(m_number[i]),
                COURIER_10PT_NORMAL);
        final PdfPCell nbrVc = new PdfPCell(scoreSheet.getDefaultCell());
        nbrVc.addElement(nbrV);
        teamInfo.addCell(nbrVc);

        // Team division label cell
        final Paragraph divP = new Paragraph(m_divisionLabel[i], ARIAL_10PT_NORMAL);
        divP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell divlc = new PdfPCell(scoreSheet.getDefaultCell());
        divlc.addElement(divP);
        divlc.setColspan(2);
        teamInfo.addCell(divlc);
        // Team division value cell
        final Paragraph divV = new Paragraph(m_division[i], COURIER_10PT_NORMAL);
        final PdfPCell divVc = new PdfPCell(scoreSheet.getDefaultCell());
        divVc.setColspan(2);
        divVc.addElement(divV);
        teamInfo.addCell(divVc);

        final PdfPCell temp2 = new PdfPCell(scoreSheet.getDefaultCell());
        // temp2.setColspan(2);
        temp2.addElement(new Paragraph("Team ____", ARIAL_8PT_NORMAL));
        teamInfo.addCell(temp2);

        // Team name label cell
        final Paragraph nameP = new Paragraph("Team Name:", ARIAL_10PT_NORMAL);
        nameP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell namelc = new PdfPCell(scoreSheet.getDefaultCell());
        namelc.setColspan(2);
        namelc.addElement(nameP);
        teamInfo.addCell(namelc);
        // Team name value cell
        final Paragraph nameV = new Paragraph(m_name[i], COURIER_10PT_NORMAL);
        final PdfPCell nameVc = new PdfPCell(scoreSheet.getDefaultCell());
        nameVc.setColspan(5);
        nameVc.addElement(nameV);
        teamInfo.addCell(nameVc);

        // add team info cell to the team table
        final PdfPCell teamInfoCell = new PdfPCell(scoreSheet.getDefaultCell());
        teamInfoCell.addElement(teamInfo);
        teamInfoCell.setColspan(2);

        scoreSheet.addCell(teamInfoCell);

        if (null != m_goalsTable) {
            final PdfPCell goalCell = new PdfPCell(m_goalsTable);
            goalCell.setBorder(0);
            goalCell.setPadding(0);
            goalCell.setColspan(2);
            scoreSheet.addCell(goalCell);
        }

        scoreSheet.addCell(desC);
        scoreSheet.addCell(sciC);

        if (null != m_copyright) {
            final Phrase copyright = new Phrase("\u00A9" + m_copyright, f6i);
            final PdfPCell copyrightC = new PdfPCell(scoreSheet.getDefaultCell());
            copyrightC.addElement(copyright);
            copyrightC.setBorder(0);
            copyrightC.setHorizontalAlignment(Element.ALIGN_CENTER);
            copyrightC.setColspan(2);

            scoreSheet.addCell(copyrightC);
        }

        // the cell in the whole page table that will contain the single score
        // sheet
        final PdfPCell scoresheetCell = new PdfPCell(scoreSheet);
        scoresheetCell.setBorder(0);
        scoresheetCell.setPadding(0);

        // Interior borders between scoresheets on a page
        if (!orientationIsPortrait) {
            if (i % 2 == 0) {
                scoresheetCell.setPaddingRight(0.1f * POINTS_PER_INCH);
            } else {
                scoresheetCell.setPaddingLeft(0.1f * POINTS_PER_INCH);
            }
        }

        // Add the current scoresheet to the page
        wholePage.addCell(scoresheetCell);

        // Add the current table of scoresheets to the document
        if (orientationIsPortrait || (i % 2 != 0)) {
            pdfDoc.add(wholePage);
        }
    }

    // Add a blank cells to complete the table of the last page
    if (!orientationIsPortrait && m_numSheets % 2 != 0) {
        final PdfPCell blank = new PdfPCell();
        blank.setBorder(0);
        wholePage.addCell(blank);
        pdfDoc.add(wholePage);
    }

    pdfDoc.close();
}

From source file:hsa.awp.admingui.report.printer.PdfPrinter.java

License:Open Source License

@Override
public void print(ExportList list) {

    if (outputStream == null) {
        throw new IllegalArgumentException("OutputStream undefined, please use setOutputStream()");
    }//from  w ww. j a  v  a 2s  . c  om

    if (!(list instanceof PdfPrintable)) {
        throw new IllegalArgumentException("PdfPrinter can only print PdfPrintables");
    }

    PdfPrintable pdfPrintable = (PdfPrintable) list;
    Document document = setUpDocument(pdfPrintable);

    try {
        document.open();

        int numberOfColumns = pdfPrintable.getPdfProperties().getCellProperties().size();
        int numberOfRows = list.getRows().size();

        PdfPTable table = new PdfPTable(numberOfColumns);

        float[] widths = new float[numberOfColumns];

        for (int i = 0; i < widths.length; i++) {
            widths[i] = pdfPrintable.getPdfProperties().getCellProperties().get(i).getWidth();
        }

        table.setWidths(widths);

        /* header */
        for (PdfCellProperties cellProperties : pdfPrintable.getPdfProperties().getCellProperties()) {
            PdfPCell cell = new PdfPCell(
                    new Phrase(cellProperties.getHeadline(), FontFactory.getFont(FontFactory.HELVETICA_BOLD)));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
        }

        /* content */
        int rowIndex = 0;
        for (Row row : list.getRows()) {
            int columnIndex = 0;
            for (String content : row.getContent()) {
                if (content != null) {
                    PdfPCell cell = new PdfPCell(
                            new Phrase(content, FontFactory.getFont(FontFactory.HELVETICA)));
                    cell.setHorizontalAlignment(pdfPrintable.getPdfProperties().getCellProperties()
                            .get(columnIndex).getAlignment().getPdfAlign());
                    table.addCell(cell);
                } else {
                    table.addCell("");
                }
                columnIndex++;
            }
            rowIndex++;
        }

        //      /* footer */
        //      if (footerFound) {
        //        for (PdfTableColumn tableColumn : cols) {
        //          table.addCell(tableColumn.getFooter());
        //        }
        //      }

        document.add(table);

        document.add(new Phrase(" "));

        document.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    }

}

From source file:hsa.awp.admingui.report.util.HeaderFooter.java

License:Open Source License

/**
 * this method is called by Pageevent.//from   w ww .j ava 2s .  c  o m
 *
 * @param writer   write of the document
 * @param document document it self
 */
public void onEndPage(PdfWriter writer, Document document) {

    Rectangle rect = writer.getBoxSize("art");
    /* title */
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT,
            new Phrase(title, FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16)), rect.getLeft(),
            rect.getTop() + 20, 0);
    /* subtitle */
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT,
            new Phrase(subtitle, FontFactory.getFont(FontFactory.HELVETICA, 9)), rect.getLeft(),
            rect.getTop() + 9, 0);
    /* date */

    DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    java.util.Date date = new java.util.Date();

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT,
            new Phrase(dateFormat.format(date)), rect.getRight(), rect.getTop() + 15, 0);
    /* pagenumber */
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
            new Phrase(String.format("Seite %d", writer.getPageNumber())),
            (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 25, 0);
}

From source file:modelo.crearPdf.java

public String pdf(int tiquet, int idOrden, String codOrden) {
    try {/*from w  ww.  j a va2s  .c  om*/

        String sql = "Select * from tiquet where idorden = '" + idOrden + "' and tiquet='" + tiquet + "'";
        rs = Consultar(sql);
        int id = 0;
        int numTiquet = 0;
        String ob = "";
        tiquet verTiquet = new tiquet();
        colores verColor = new colores();
        String colorUno = "";
        String colorDos = "";
        System.out.print("id de la orden en el tiquet:" + idOrden);
        ArrayList<String> lista = new ArrayList<String>();
        int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0,
                c13 = 0, c14 = 0, c15 = 0;
        int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0,
                c27 = 0, c28 = 0, c29 = 0;
        int c30 = 0, c31 = 0, c32 = 0, c33 = 0;
        String observacion = "";
        String verificacion = "";
        //rs.last();
        int cuantos = rs.getRow();
        //System.out.print("puestos:" + cuantos+ "orden: " + codOrden + "tiquet: " + tiquet);
        //Creamos el CHUNK definiendo su tipo de letra, tamao
        Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tiq = new Chunk("Tiquet #",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValTiq = new Chunk("" + tiquet,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tel = new Chunk("Tel: 5783364",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ref = new Chunk("Ref",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValRef = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Correo = new Chunk("calzadoseiya@gmail.com",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Par = new Chunk("Pares",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValPar = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq = new Chunk("Fecha",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq2 = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Orden = new Chunk("Orden",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValOrd = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cor = new Chunk("CORTADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Guar = new Chunk("GUARNICION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Mon = new Chunk("MONTADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Emp = new Chunk("EMPLANTILLADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk OBSER = new Chunk("OBSERVACION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Col1 = new Chunk("Color 1",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Col2 = new Chunk("Color 2",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Encabezado = new Chunk("SEIYA",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK));
        Chunk num21 = new Chunk("21",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num22 = new Chunk("22",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num23 = new Chunk("23",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num24 = new Chunk("24",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num25 = new Chunk("25",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num26 = new Chunk("26",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num27 = new Chunk("27",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num28 = new Chunk("28",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num29 = new Chunk("29",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num30 = new Chunk("30",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num31 = new Chunk("31",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num32 = new Chunk("32",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num33 = new Chunk("33",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num34 = new Chunk("34",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num35 = new Chunk("35",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num36 = new Chunk("36",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num37 = new Chunk("37",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num38 = new Chunk("38",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num39 = new Chunk("39",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num40 = new Chunk("40",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num41 = new Chunk("41",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num42 = new Chunk("42",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num43 = new Chunk("43",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num44 = new Chunk("44",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));

        //Fecha actual en formato completo:
        //Tue Sep 23 01:18:48 CEST 2014
        Date fechaActual = new Date();

        //Formateando la fecha:
        DateFormat formatoHora = new SimpleDateFormat("HH-mm-ss");
        DateFormat formatoFecha = new SimpleDateFormat("yyyy-MM-dd");
        DateFormat Fecha = new SimpleDateFormat("dd/MM/yyyy");
        //  System.out.println("Fecha: "+formatoFecha.format(fechaActual)+" Son las: "+formatoHora.format(fechaActual));
        String fe = Fecha.format(fechaActual);
        //Directorio destino para las descargas
        File folder = new File("c:\\seiya\\tiquets");

        //Crea el directorio de destino en caso de que no exista
        folder.mkdirs();

        int numeroAleatorio = (int) (Math.random() * 2500 + 1);
        //Nombre del fichero <strong>PDF</strong> Resultante de la ejecucion
        String dir = "C:\\seiya\\tiquets\\Tiquet_" + tiquet + ".pdf";
        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream(dir);
        Rectangle pageSize = new Rectangle(300f, 792f); //ancho y alto
        //Creacion del documento con un tamao y unos margenes predeterminados

        Document document = new Document(pageSize, 1, 1, 1, 1);
        // Obtener la instancia del PdfWriter
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);

        //Opens the document.
        //You have to open the document before you can begin to add content to the body of the document.
        document.open();
        //**************************************************************

        //Ejemplos de TABLE
        titulo = new Chunk("", FontFactory.getFont(FontFactory.COURIER, 20, Font.UNDERLINE, BaseColor.BLACK));
        document.add(titulo);
        //Aadir tabla 5 columnas
        PdfPTable table = new PdfPTable(15);
        //Aadir CABECERA

        PdfPCell cell = new PdfPCell();
        cell.setColspan(15);
        table.addCell(cell);

        Image image = Image.getInstance("logo.png");
        //    String col = "jhon";
        cell = new PdfPCell(image);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(7);
        table.addCell(cell);
        /*
        cell = new PdfPCell(new Phrase("imagen:"));
        cell.setColspan(4);
        cell.setRowspan(7);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //cell.setBackgroundColor(BaseColor.GRAY);
        table.addCell(cell);
                
        /*table.addCell(createImageCell(IMG1));*/
        cell = new PdfPCell(new Phrase(direccion));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(6);
        cell.setRowspan(2);

        table.addCell(cell);

        while (rs.next()) {

            c1 = rs.getInt(1);
            c2 = rs.getInt(2);
            c3 = rs.getInt(3);
            c4 = rs.getInt(4);
            c5 = rs.getInt(5);
            observacion = rs.getString(6);
            verificacion = rs.getString(7);
            c8 = rs.getInt(8);
            c9 = rs.getInt(9);
            c10 = rs.getInt(10);
            c11 = rs.getInt(11);
            c12 = rs.getInt(12);
            c13 = rs.getInt(13);
            c14 = rs.getInt(14);
            c15 = rs.getInt(15);
            c16 = rs.getInt(16);
            c17 = rs.getInt(17);
            c18 = rs.getInt(18);
            c19 = rs.getInt(19);
            c20 = rs.getInt(20);
            c21 = rs.getInt(21);
            c22 = rs.getInt(22);
            c23 = rs.getInt(23);
            c24 = rs.getInt(24);
            c25 = rs.getInt(25);
            c26 = rs.getInt(26);
            c27 = rs.getInt(27);
            c28 = rs.getInt(28);
            c29 = rs.getInt(29);
            c30 = rs.getInt(30);
            c31 = rs.getInt(31);
            c32 = rs.getInt(32);
            c33 = rs.getInt(33);

            String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ",
                    c09 = " ", c010 = " ", c011 = " ", c012 = " ";
            String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ",
                    c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " ";
            String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ",
                    c032 = " ", c033 = " ", c034 = " ";
            if (c1 != 0)
                c01 = String.valueOf(c1);
            if (c2 != 0)
                c02 = String.valueOf(c2);
            if (c3 != 0)
                c03 = String.valueOf(c3);
            if (c4 != 0)
                c04 = String.valueOf(c4);
            if (c5 != 0)
                c05 = String.valueOf(c5);
            if (c8 != 0)
                c08 = String.valueOf(c8);
            if (c9 != 0)
                c09 = String.valueOf(c9);
            if (c10 != 0)
                c010 = String.valueOf(c10);
            if (c11 != 0)
                c011 = String.valueOf(c11);
            if (c12 != 0)
                c012 = String.valueOf(c12);
            if (c13 != 0)
                c013 = String.valueOf(c13);
            if (c14 != 0)
                c014 = String.valueOf(c14);
            if (c15 != 0)
                c015 = String.valueOf(c15);
            if (c16 != 0)
                c016 = String.valueOf(c16);
            if (c17 != 0)
                c017 = String.valueOf(c17);
            if (c18 != 0)
                c018 = String.valueOf(c18);
            if (c19 != 0)
                c019 = String.valueOf(c19);
            if (c20 != 0)
                c020 = String.valueOf(c20);
            if (c21 != 0)
                c021 = String.valueOf(c21);
            if (c22 != 0)
                c022 = String.valueOf(c22);
            if (c23 != 0)
                c023 = String.valueOf(c23);
            if (c24 != 0)
                c024 = String.valueOf(c24);
            if (c25 != 0)
                c025 = String.valueOf(c25);
            if (c26 != 0)
                c026 = String.valueOf(c26);
            if (c27 != 0)
                c027 = String.valueOf(c27);
            if (c28 != 0)
                c028 = String.valueOf(c28);
            if (c29 != 0)
                c029 = String.valueOf(c29);
            if (c30 != 0)
                c030 = String.valueOf(c30);
            if (c31 != 0)
                c031 = String.valueOf(c31);
            if (c32 != 0)
                c032 = String.valueOf(c32);
            if (c33 != 0)
                c033 = String.valueOf(c33);

            colorUno = verColor.consultarNombreColorUno(c4);
            colorDos = verColor.consultarNombreColorDos(c5);
            ob = verTiquet.ConsultaObservacion(tiquet);
            Chunk ValCol1 = new Chunk(colorUno,
                    FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
            Chunk ValCol2 = new Chunk(colorDos,
                    FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
            Chunk ValObserv = new Chunk(ob,
                    FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));

            System.out.print("Color Uno: " + colorUno);

            cell = new PdfPCell(new Phrase(Tiq));
            cell.setColspan(3);
            cell.setRowspan(2);
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + tiquet));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(2);
            cell.setRowspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Tel));
            cell.setColspan(6);
            cell.setRowspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.CYAN);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(Ref));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(2);
            cell.setRowspan(2);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("" + c8));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(3);
            cell.setRowspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Correo));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(6);
            cell.setRowspan(2);//para eliminar espacio cabecera reemplazo el 2 por 3
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(Par));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(2);
            cell.setRowspan(2);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase("" + c9));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(3);
            cell.setRowspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(FechaTiq));//espacio intermedio cabecera
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(2);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(fe));//espacio intermedio cabecera
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Orden));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(2);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase("" + codOrden));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            //cell.setBackgroundColor(BaseColor.ORANGE);
            cell.setColspan(3);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Cor));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(""));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            cell.setRowspan(1);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Guar));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(""));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Mon));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(""));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Emp));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(""));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(OBSER));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            cell.setRowspan(2);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(ValObserv));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(11);
            cell.setRowspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Col1));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(3);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(ValCol1));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(4);
            table.addCell(cell);

            cell = new PdfPCell(new Phrase(Col2));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(3);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(ValCol2));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setColspan(5);
            table.addCell(cell);

            table.addCell(new Phrase(num21));
            table.addCell(new Phrase(num22));
            table.addCell(new Phrase(num23));
            table.addCell(new Phrase(num24));
            table.addCell(new Phrase(num25));
            table.addCell(new Phrase(num26));
            table.addCell(new Phrase(num27));
            table.addCell(new Phrase(num28));
            table.addCell(new Phrase(num29));
            table.addCell(new Phrase(num30));
            table.addCell(new Phrase(num31));
            table.addCell(new Phrase(num32));
            table.addCell(new Phrase(num33));
            table.addCell(new Phrase(num34));
            table.addCell(new Phrase(num35));

            table.addCell("" + c010);
            table.addCell("" + c011);
            table.addCell("" + c012);
            table.addCell("" + c013);
            table.addCell("" + c014);
            table.addCell("" + c015);
            table.addCell("" + c016);
            table.addCell("" + c017);
            table.addCell("" + c018);
            table.addCell("" + c019);
            table.addCell("" + c020);
            table.addCell("" + c021);
            table.addCell("" + c022);
            table.addCell("" + c023);
            table.addCell("" + c024);

            table.addCell(new Phrase(num36));
            table.addCell(new Phrase(num37));
            table.addCell(new Phrase(num38));
            table.addCell(new Phrase(num39));
            table.addCell(new Phrase(num40));
            table.addCell(new Phrase(num41));
            table.addCell(new Phrase(num42));
            table.addCell(new Phrase(num43));
            table.addCell(new Phrase(num44));
            table.addCell(" ");
            table.addCell(" ");
            table.addCell(" ");
            table.addCell(" ");
            table.addCell(" ");
            table.addCell(" ");

            table.addCell("" + c025);
            table.addCell("" + c026);
            table.addCell("" + c027);
            table.addCell("" + c028);
            table.addCell("" + c029);
            table.addCell("" + c030);
            table.addCell("" + c031);
            table.addCell("" + c032);
            table.addCell("" + c033);
            table.addCell("");
            table.addCell("");
            table.addCell("");
            table.addCell("");
            table.addCell("");
            table.addCell("");

            table.setWidthPercentage(100f);
            table.setHorizontalAlignment(Element.ALIGN_RIGHT);

            document.add(table);

            // String cadena="";
            Chunk cadena = null;
            for (int i = 1; i <= 4; i++) {
                //Chunk chunkSeparador =  new Chunk(SEPARADOR);
                // document.add(chunkSeparador);
                // document.add(Chunk.NEWLINE);

                PdfPTable tabla = new PdfPTable(15);
                if (i == 1)
                    cadena = Emp;
                if (i == 2)
                    cadena = Mon;

                if (i == 3) {
                    cadena = Guar;

                }
                if (i == 4)
                    cadena = Cor;

                cell = new PdfPCell(
                        new Phrase("-----------------------------------------------------------------"));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(15);
                cell.setRowspan(1);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(Encabezado));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(5);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(cadena));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(4);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(Tiq));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase("" + tiquet));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(Par));
                cell.setHorizontalAlignment(Font.BOLD);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase("" + c9));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(4);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(Ref));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase("" + c8));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(Col1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(4);
                tabla.addCell(cell);

                cell = new PdfPCell(new Phrase(Col2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                tabla.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(5);
                tabla.addCell(cell);

                tabla.addCell(new Phrase(num21));
                tabla.addCell(new Phrase(num22));
                tabla.addCell(new Phrase(num23));
                tabla.addCell(new Phrase(num24));
                tabla.addCell(new Phrase(num25));
                tabla.addCell(new Phrase(num26));
                tabla.addCell(new Phrase(num27));
                tabla.addCell(new Phrase(num28));
                tabla.addCell(new Phrase(num29));
                tabla.addCell(new Phrase(num30));
                tabla.addCell(new Phrase(num31));
                tabla.addCell(new Phrase(num32));
                tabla.addCell(new Phrase(num33));
                tabla.addCell(new Phrase(num34));
                tabla.addCell(new Phrase(num35));

                tabla.addCell("" + c010);
                tabla.addCell("" + c011);
                tabla.addCell("" + c012);
                tabla.addCell("" + c013);
                tabla.addCell("" + c014);
                tabla.addCell("" + c015);
                tabla.addCell("" + c016);
                tabla.addCell("" + c017);
                tabla.addCell("" + c018);
                tabla.addCell("" + c019);
                tabla.addCell("" + c020);
                tabla.addCell("" + c021);
                tabla.addCell("" + c022);
                tabla.addCell("" + c023);
                tabla.addCell("" + c024);

                tabla.addCell(new Phrase(num36));
                tabla.addCell(new Phrase(num37));
                tabla.addCell(new Phrase(num38));
                tabla.addCell(new Phrase(num39));
                tabla.addCell(new Phrase(num40));
                tabla.addCell(new Phrase(num41));
                tabla.addCell(new Phrase(num42));
                tabla.addCell(new Phrase(num43));
                tabla.addCell(new Phrase(num44));
                tabla.addCell(" ");
                tabla.addCell(" ");
                tabla.addCell(" ");
                tabla.addCell(" ");
                tabla.addCell(" ");
                tabla.addCell(" ");

                tabla.addCell("" + c025);
                tabla.addCell("" + c026);
                tabla.addCell("" + c027);
                tabla.addCell("" + c028);
                tabla.addCell("" + c029);
                tabla.addCell("" + c030);
                tabla.addCell("" + c031);
                tabla.addCell("" + c032);
                tabla.addCell("" + c033);
                tabla.addCell("");
                tabla.addCell("");
                tabla.addCell("");
                tabla.addCell("");
                tabla.addCell("");
                tabla.addCell("");

                tabla.setWidthPercentage(100f);
                tabla.setHorizontalAlignment(Element.ALIGN_RIGHT);

                document.add(tabla);

            }
            //FIN Ejemplos de TABLE

        }

        document.close();

        return "exito";

    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        return "Error al Generar el PDF";
    }

}

From source file:modelo.impOrdenCarta.java

public boolean impOrden(int idOrden, String codOrden, int numRegTiq) {
    try {/*from  w w w  .j  ava  2 s.  c  o  m*/

        int id = 0;
        int numTiquet = 0;
        String ob = "";
        colores verColor = new colores();
        String colorUno = "";
        String colorDos = "";
        ArrayList<String> lista = new ArrayList<String>();
        int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0,
                c13 = 0, c14 = 0, c15 = 0;
        int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0,
                c27 = 0, c28 = 0, c29 = 0;
        int c30 = 0, c31 = 0, c32 = 0, c33 = 0;
        String observacion = "";
        int CanTotal = 0;

        int idCliente = 0;
        String ciu = "";
        String fecped = "";
        String fecent = "";

        for (orden ord : new orden().CargarDatosOrden(codOrden)) {
            idCliente = ord.getCliente();
            ciu = ord.getCiudad();
            fecped = ord.getPedido();
            fecent = ord.getEntrega();
        }
        String nomCliente = nuevaOrden.ConsultarNombreCliente(idCliente);

        Chunk idClient = new Chunk(nomCliente,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Tiq = new Chunk("TK",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValTiq = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tel = new Chunk("Tel: 5783364",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Ref = new Chunk("REF",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValRef = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Correo = new Chunk("calzadoseiya@gmail.com",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Cliente = new Chunk("CLIENTE",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecEnt = new Chunk("FECHA ENTREGA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecEnt = new Chunk(fecent,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecPed = new Chunk("FECHA PEDIDO",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecPed = new Chunk(fecped,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq2 = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Orden = new Chunk("ORDEN",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValOrd = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ciudad = new Chunk("CIUDAD",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValCiudad = new Chunk(ciu,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cant = new Chunk("CANT.",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Mon = new Chunk("MONTADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Emp = new Chunk("EMPLANTILLADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk OBSER = new Chunk("OBSERVACION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Col1 = new Chunk("Color 1",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Col2 = new Chunk("Color 2",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Encabezado = new Chunk("SEIYA",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK));
        Chunk num21 = new Chunk("21",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num22 = new Chunk("22",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num23 = new Chunk("23",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num24 = new Chunk("24",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num25 = new Chunk("25",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num26 = new Chunk("26",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num27 = new Chunk("27",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num28 = new Chunk("28",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num29 = new Chunk("29",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num30 = new Chunk("30",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num31 = new Chunk("31",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num32 = new Chunk("32",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num33 = new Chunk("33",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num34 = new Chunk("34",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num35 = new Chunk("35",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num36 = new Chunk("36",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num37 = new Chunk("37",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num38 = new Chunk("38",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num39 = new Chunk("39",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num40 = new Chunk("40",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num41 = new Chunk("41",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num42 = new Chunk("42",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num43 = new Chunk("43",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num44 = new Chunk("44",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));

        File folder = new File("c:\\seiya\\ordenes");
        folder.mkdirs();
        String dir = "C:\\seiya\\ordenes\\Orden_" + codOrden + ".pdf";
        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream(dir);
        Rectangle pageSize = new Rectangle(792f, 612f);

        Document document = new Document(pageSize, 1, 1, 1, 1);
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
        document.open();

        PdfPTable table = new PdfPTable(40);
        PdfPCell cell = new PdfPCell();

        Image image = Image.getInstance("logo.png");
        //    String col = "jhon";
        cell = new PdfPCell(image);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(7);
        cell.setRowspan(7);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(direccion));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tel));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Correo));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tiq));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Orden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(codOrden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cliente));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(idClient));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(9);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ciudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValCiudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ref));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cant));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        table.addCell(new Phrase(num21));
        table.addCell(new Phrase(num22));
        table.addCell(new Phrase(num23));
        table.addCell(new Phrase(num24));
        table.addCell(new Phrase(num25));
        table.addCell(new Phrase(num26));
        table.addCell(new Phrase(num27));
        table.addCell(new Phrase(num28));
        table.addCell(new Phrase(num29));
        table.addCell(new Phrase(num30));
        table.addCell(new Phrase(num31));
        table.addCell(new Phrase(num32));
        table.addCell(new Phrase(num33));
        table.addCell(new Phrase(num34));
        table.addCell(new Phrase(num35));
        table.addCell(new Phrase(num36));
        table.addCell(new Phrase(num37));
        table.addCell(new Phrase(num38));
        table.addCell(new Phrase(num39));
        table.addCell(new Phrase(num40));
        table.addCell(new Phrase(num41));
        table.addCell(new Phrase(num42));
        table.addCell(new Phrase(num43));

        cell = new PdfPCell(new Phrase(Col1));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Col2));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(OBSER));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(5);
        cell.setRowspan(1);
        table.addCell(cell);

        ArrayList<String> resultat;
        resultat = nuevoTiquet.consultarTiquetporOrden(idOrden);
        Iterator<String> tiquetIterator = resultat.iterator();

        while (tiquetIterator.hasNext()) {

            String valorTiquet = tiquetIterator.next();
            System.out.print(valorTiquet + " ------ ");
            int tiq = Integer.parseInt(valorTiquet);
            ArrayList<tiquet> listaDatosTiquet;
            listaDatosTiquet = nuevoTiquet.conten(idOrden, tiq);//La consulta tiene que retornar un ArrayList

            for (tiquet ord : new tiquet().conten(idOrden, tiq)) {
                System.out.print("Referencia: " + nuevoTiquet.ConsultarReferencia(tiq, idOrden));
                c1 = ord.getTiquet();
                c2 = ord.getIdorden();
                observacion = ord.getObservacion();
                c4 = nuevoTiquet.ConsultarReferencia(tiq, idOrden);
                c5 = nuevoTiquet.ConsultarCantidad(tiq, idOrden);
                c8 = ord.getN21();
                c9 = ord.getN22();
                c10 = ord.getN23();
                c11 = ord.getN24();
                c12 = ord.getN25();
                c13 = ord.getN26();
                c14 = ord.getN27();
                c15 = ord.getN28();
                c16 = ord.getN29();
                c17 = ord.getN30();
                c18 = ord.getN31();
                c19 = ord.getN32();
                c20 = ord.getN33();
                c21 = ord.getN34();
                c22 = ord.getN35();
                c23 = ord.getN36();
                c24 = ord.getN37();
                c25 = ord.getN38();
                c26 = ord.getN39();
                c27 = ord.getN40();
                c28 = ord.getN41();
                c29 = ord.getN42();
                c30 = ord.getN43();

                String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ",
                        c09 = " ", c010 = " ", c011 = " ", c012 = " ";
                String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ",
                        c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " ";
                String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ",
                        c032 = " ", c033 = " ", c034 = " ";
                if (c1 != 0)
                    c01 = String.valueOf(c1);
                if (c2 != 0)
                    c02 = String.valueOf(c2);
                //    if(c3!=0) c03 = String.valueOf(c3);
                if (c4 != 0)
                    c04 = String.valueOf(c4);
                if (c5 != 0) {
                    c05 = String.valueOf(c5);
                    CanTotal += c5;
                }
                if (c8 != 0)
                    c08 = String.valueOf(c8);
                if (c9 != 0)
                    c09 = String.valueOf(c9);
                if (c10 != 0)
                    c010 = String.valueOf(c10);
                if (c11 != 0)
                    c011 = String.valueOf(c11);
                if (c12 != 0)
                    c012 = String.valueOf(c12);
                if (c13 != 0)
                    c013 = String.valueOf(c13);
                if (c14 != 0)
                    c014 = String.valueOf(c14);
                if (c15 != 0)
                    c015 = String.valueOf(c15);
                if (c16 != 0)
                    c016 = String.valueOf(c16);
                if (c17 != 0)
                    c017 = String.valueOf(c17);
                if (c18 != 0)
                    c018 = String.valueOf(c18);
                if (c19 != 0)
                    c019 = String.valueOf(c19);
                if (c20 != 0)
                    c020 = String.valueOf(c20);
                if (c21 != 0)
                    c021 = String.valueOf(c21);
                if (c22 != 0)
                    c022 = String.valueOf(c22);
                if (c23 != 0)
                    c023 = String.valueOf(c23);
                if (c24 != 0)
                    c024 = String.valueOf(c24);
                if (c25 != 0)
                    c025 = String.valueOf(c25);
                if (c26 != 0)
                    c026 = String.valueOf(c26);
                if (c27 != 0)
                    c027 = String.valueOf(c27);
                if (c28 != 0)
                    c028 = String.valueOf(c28);
                if (c29 != 0)
                    c029 = String.valueOf(c29);
                if (c30 != 0)
                    c030 = String.valueOf(c30);

                cell = new PdfPCell(new Phrase(String.valueOf(tiq)));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c04));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c05));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c08));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c09));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c010));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c011));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c012));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c013));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c014));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c015));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c016));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c017));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c018));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c019));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c020));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c021));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c022));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c023));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c024));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c025));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c026));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c027));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c028));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c029));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c030));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);

                colorUno = verColor.consultarNombreColorUno(ord.getIdcoloruno());
                colorDos = verColor.consultarNombreColorDos(ord.getIdcolordos());
                //  ob = verTiquet.ConsultaObservacion(tiquet);
                Chunk ValCol1 = new Chunk(colorUno,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValCol2 = new Chunk(colorDos,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValObserv = new Chunk(ord.getObservacion(),
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));

                cell = new PdfPCell(new Phrase(ValCol1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(ValObserv));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(5);
                cell.setRowspan(1);
                table.addCell(cell);

            }

        }
        cell = new PdfPCell(new Phrase("Cantidad Total de Pares Producidos "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(15);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(String.valueOf(CanTotal)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(25);
        cell.setRowspan(1);
        table.addCell(cell);

        table.setWidthPercentage(95f);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);
        document.add(table);

        document.close();

        return true;
    } catch (Exception x) {
        return false;
    }

}

From source file:modelo.impOrdenLegal.java

public boolean impOrden(int idOrden, String codOrden, int numRegTiq) {
    try {//from   ww  w  . ja  v a  2 s.  co m

        int id = 0;
        int numTiquet = 0;
        String ob = "";
        colores verColor = new colores();
        String colorUno = "";
        String colorDos = "";
        ArrayList<String> lista = new ArrayList<String>();
        int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0,
                c13 = 0, c14 = 0, c15 = 0;
        int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0,
                c27 = 0, c28 = 0, c29 = 0;
        int c30 = 0, c31 = 0, c32 = 0, c33 = 0;
        String observacion = "";
        int CanTotal = 0;

        int idCliente = 0;
        String ciu = "";
        String fecped = "";
        String fecent = "";

        for (orden ord : new orden().CargarDatosOrden(codOrden)) {
            idCliente = ord.getCliente();
            ciu = ord.getCiudad();
            fecped = ord.getPedido();
            fecent = ord.getEntrega();
        }
        String nomCliente = nuevaOrden.ConsultarNombreCliente(idCliente);

        Chunk idClient = new Chunk(nomCliente,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Tiq = new Chunk("TK",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValTiq = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tel = new Chunk("Tel: 5783364",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Ref = new Chunk("REF",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValRef = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Correo = new Chunk("calzadoseiya@gmail.com",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Cliente = new Chunk("CLIENTE",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecEnt = new Chunk("FECHA ENTREGA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecEnt = new Chunk(fecent,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecPed = new Chunk("FECHA PEDIDO",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecPed = new Chunk(fecped,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq2 = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Orden = new Chunk("ORDEN",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValOrd = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ciudad = new Chunk("CIUDAD",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValCiudad = new Chunk(ciu,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cant = new Chunk("CANT.",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cor = new Chunk("CORT",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk Guar = new Chunk("GUAR",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk Mon = new Chunk("MONT",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk Emp = new Chunk("EMP",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk OBSER = new Chunk("OBSERVACION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Col1 = new Chunk("Color 1",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Col2 = new Chunk("Color 2",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Encabezado = new Chunk("SEIYA",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK));
        Chunk num21 = new Chunk("21",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num22 = new Chunk("22",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num23 = new Chunk("23",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num24 = new Chunk("24",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num25 = new Chunk("25",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num26 = new Chunk("26",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num27 = new Chunk("27",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num28 = new Chunk("28",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num29 = new Chunk("29",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num30 = new Chunk("30",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num31 = new Chunk("31",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num32 = new Chunk("32",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num33 = new Chunk("33",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num34 = new Chunk("34",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num35 = new Chunk("35",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num36 = new Chunk("36",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num37 = new Chunk("37",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num38 = new Chunk("38",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num39 = new Chunk("39",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num40 = new Chunk("40",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num41 = new Chunk("41",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num42 = new Chunk("42",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num43 = new Chunk("43",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num44 = new Chunk("44",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));

        File folder = new File("c:\\seiya\\ordenes");
        folder.mkdirs();
        String dir = "C:\\seiya\\ordenes\\Orden_Legal_" + codOrden + ".pdf";
        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream(dir);
        Rectangle pageSize = new Rectangle(1008f, 612f);

        Document document = new Document(pageSize, 1, 1, 1, 1);
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
        document.open();

        PdfPTable table = new PdfPTable(50);
        PdfPCell cell = new PdfPCell();

        Image image = Image.getInstance("logo.png");
        //    String col = "jhon";
        cell = new PdfPCell(image);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(7);
        cell.setRowspan(7);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(direccion));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(43);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tel));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(43);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Correo));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(43);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(43);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tiq));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Orden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(codOrden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cliente));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(idClient));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(12);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ciudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValCiudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("ETAPA DEL PROCESO"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(8);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ref));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cant));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        table.addCell(new Phrase(num21));
        table.addCell(new Phrase(num22));
        table.addCell(new Phrase(num23));
        table.addCell(new Phrase(num24));
        table.addCell(new Phrase(num25));
        table.addCell(new Phrase(num26));
        table.addCell(new Phrase(num27));
        table.addCell(new Phrase(num28));
        table.addCell(new Phrase(num29));
        table.addCell(new Phrase(num30));
        table.addCell(new Phrase(num31));
        table.addCell(new Phrase(num32));
        table.addCell(new Phrase(num33));
        table.addCell(new Phrase(num34));
        table.addCell(new Phrase(num35));
        table.addCell(new Phrase(num36));
        table.addCell(new Phrase(num37));
        table.addCell(new Phrase(num38));
        table.addCell(new Phrase(num39));
        table.addCell(new Phrase(num40));
        table.addCell(new Phrase(num41));
        table.addCell(new Phrase(num42));
        table.addCell(new Phrase(num43));

        cell = new PdfPCell(new Phrase(Col1));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Col2));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(OBSER));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(8);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cor));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Guar));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Mon));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Emp));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        ArrayList<String> resultat;
        resultat = nuevoTiquet.consultarTiquetporOrden(idOrden);
        Iterator<String> tiquetIterator = resultat.iterator();

        while (tiquetIterator.hasNext()) {

            String valorTiquet = tiquetIterator.next();
            System.out.print(valorTiquet + " ------ ");
            int tiq = Integer.parseInt(valorTiquet);
            ArrayList<tiquet> listaDatosTiquet;
            listaDatosTiquet = nuevoTiquet.conten(idOrden, tiq);//La consulta tiene que retornar un ArrayList

            for (tiquet ord : new tiquet().conten(idOrden, tiq)) {
                System.out.print("Referencia: " + nuevoTiquet.ConsultarReferencia(tiq, idOrden));
                c1 = ord.getTiquet();
                c2 = ord.getIdorden();
                observacion = ord.getObservacion();
                c4 = nuevoTiquet.ConsultarReferencia(tiq, idOrden);
                c5 = nuevoTiquet.ConsultarCantidad(tiq, idOrden);
                c8 = ord.getN21();
                c9 = ord.getN22();
                c10 = ord.getN23();
                c11 = ord.getN24();
                c12 = ord.getN25();
                c13 = ord.getN26();
                c14 = ord.getN27();
                c15 = ord.getN28();
                c16 = ord.getN29();
                c17 = ord.getN30();
                c18 = ord.getN31();
                c19 = ord.getN32();
                c20 = ord.getN33();
                c21 = ord.getN34();
                c22 = ord.getN35();
                c23 = ord.getN36();
                c24 = ord.getN37();
                c25 = ord.getN38();
                c26 = ord.getN39();
                c27 = ord.getN40();
                c28 = ord.getN41();
                c29 = ord.getN42();
                c30 = ord.getN43();

                String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ",
                        c09 = " ", c010 = " ", c011 = " ", c012 = " ";
                String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ",
                        c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " ";
                String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ",
                        c032 = " ", c033 = " ", c034 = " ";
                if (c1 != 0)
                    c01 = String.valueOf(c1);
                if (c2 != 0)
                    c02 = String.valueOf(c2);
                //    if(c3!=0) c03 = String.valueOf(c3);
                if (c4 != 0)
                    c04 = String.valueOf(c4);
                if (c5 != 0) {
                    c05 = String.valueOf(c5);
                    CanTotal += c5;
                }
                if (c8 != 0)
                    c08 = String.valueOf(c8);
                if (c9 != 0)
                    c09 = String.valueOf(c9);
                if (c10 != 0)
                    c010 = String.valueOf(c10);
                if (c11 != 0)
                    c011 = String.valueOf(c11);
                if (c12 != 0)
                    c012 = String.valueOf(c12);
                if (c13 != 0)
                    c013 = String.valueOf(c13);
                if (c14 != 0)
                    c014 = String.valueOf(c14);
                if (c15 != 0)
                    c015 = String.valueOf(c15);
                if (c16 != 0)
                    c016 = String.valueOf(c16);
                if (c17 != 0)
                    c017 = String.valueOf(c17);
                if (c18 != 0)
                    c018 = String.valueOf(c18);
                if (c19 != 0)
                    c019 = String.valueOf(c19);
                if (c20 != 0)
                    c020 = String.valueOf(c20);
                if (c21 != 0)
                    c021 = String.valueOf(c21);
                if (c22 != 0)
                    c022 = String.valueOf(c22);
                if (c23 != 0)
                    c023 = String.valueOf(c23);
                if (c24 != 0)
                    c024 = String.valueOf(c24);
                if (c25 != 0)
                    c025 = String.valueOf(c25);
                if (c26 != 0)
                    c026 = String.valueOf(c26);
                if (c27 != 0)
                    c027 = String.valueOf(c27);
                if (c28 != 0)
                    c028 = String.valueOf(c28);
                if (c29 != 0)
                    c029 = String.valueOf(c29);
                if (c30 != 0)
                    c030 = String.valueOf(c30);

                cell = new PdfPCell(new Phrase(String.valueOf(tiq)));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c04));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c05));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c08));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c09));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c010));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c011));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c012));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c013));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c014));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c015));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c016));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c017));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c018));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c019));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c020));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c021));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c022));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c023));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c024));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c025));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c026));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c027));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c028));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c029));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c030));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);

                colorUno = verColor.consultarNombreColorUno(ord.getIdcoloruno());
                colorDos = verColor.consultarNombreColorDos(ord.getIdcolordos());
                //  ob = verTiquet.ConsultaObservacion(tiquet);
                Chunk ValCol1 = new Chunk(colorUno,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValCol2 = new Chunk(colorDos,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValObserv = new Chunk(ord.getObservacion(),
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));

                cell = new PdfPCell(new Phrase(ValCol1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(ValObserv));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(8);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(" "));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(" "));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(" "));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(" "));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

            }

        }
        cell = new PdfPCell(new Phrase("Cantidad Total de Pares Producidos "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(15);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(String.valueOf(CanTotal)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(35);
        cell.setRowspan(1);
        table.addCell(cell);

        table.setWidthPercentage(95f);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);
        document.add(table);

        document.close();

        return true;
    } catch (Exception x) {
        return false;
    }

}

From source file:modelo.pdfOrden.java

public String pdf(int tiquet, int idOrden, String codOrden, int numRegTiq) {
    try {// www.  j a v  a2 s.  c  o m

        int id = 0;
        int numTiquet = 0;
        String ob = "";
        tiquet verTiquet = new tiquet();
        colores verColor = new colores();
        String colorUno = "";
        String colorDos = "";
        System.out.print("id de la orden en el tiquet:" + idOrden);
        ArrayList<String> lista = new ArrayList<String>();
        int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0,
                c13 = 0, c14 = 0, c15 = 0;
        int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0,
                c27 = 0, c28 = 0, c29 = 0;
        int c30 = 0, c31 = 0, c32 = 0, c33 = 0;
        String observacion = "";
        String verificacion = "";

        int idCliente = 0;
        String ciu = "";
        String fecped = "";
        String fecent = "";

        for (orden ord : new orden().CargarDatosOrden(codOrden)) {
            idCliente = ord.getCliente();
            ciu = ord.getCiudad();
            fecped = ord.getPedido();
            fecent = ord.getEntrega();
        }

        //rs.last();
        // int cuantos = rs.getRow();
        //System.out.print("puestos:" + cuantos+ "orden: " + codOrden + "tiquet: " + tiquet);
        //Creamos el CHUNK definiendo su tipo de letra, tamao
        Chunk idClient = new Chunk("" + idCliente,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tiq = new Chunk("TK",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValTiq = new Chunk("" + tiquet,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tel = new Chunk("Tel: 5783364",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ref = new Chunk("REF",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValRef = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Correo = new Chunk("calzadoseiya@gmail.com",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Cliente = new Chunk("CLIENTE",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecEnt = new Chunk("FECHA ENTREGA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecEnt = new Chunk(fecent,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecPed = new Chunk("FECHA PEDIDO",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecPed = new Chunk(fecped,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq2 = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Orden = new Chunk("ORDEN",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValOrd = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ciudad = new Chunk("CIUDAD",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValCiudad = new Chunk(ciu,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cant = new Chunk("CANT.",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Mon = new Chunk("MONTADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Emp = new Chunk("EMPLANTILLADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk OBSER = new Chunk("OBSERVACION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Col1 = new Chunk("Color 1",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Col2 = new Chunk("Color 2",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Encabezado = new Chunk("SEIYA",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK));
        Chunk num21 = new Chunk("21",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num22 = new Chunk("22",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num23 = new Chunk("23",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num24 = new Chunk("24",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num25 = new Chunk("25",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num26 = new Chunk("26",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num27 = new Chunk("27",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num28 = new Chunk("28",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num29 = new Chunk("29",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num30 = new Chunk("30",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num31 = new Chunk("31",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num32 = new Chunk("32",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num33 = new Chunk("33",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num34 = new Chunk("34",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num35 = new Chunk("35",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num36 = new Chunk("36",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num37 = new Chunk("37",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num38 = new Chunk("38",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num39 = new Chunk("39",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num40 = new Chunk("40",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num41 = new Chunk("41",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num42 = new Chunk("42",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num43 = new Chunk("43",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num44 = new Chunk("44",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));

        //Fecha actual en formato completo:
        //Tue Sep 23 01:18:48 CEST 2014
        Date fechaActual = new Date();

        //Formateando la fecha:
        DateFormat formatoHora = new SimpleDateFormat("HH-mm-ss");
        DateFormat formatoFecha = new SimpleDateFormat("yyyy-MM-dd");
        DateFormat Fecha = new SimpleDateFormat("dd/MM/yyyy");
        //  System.out.println("Fecha: "+formatoFecha.format(fechaActual)+" Son las: "+formatoHora.format(fechaActual));
        String fe = Fecha.format(fechaActual);
        //Directorio destino para las descargas
        File folder = new File("c:\\seiya\\ordenes");

        //Crea el directorio de destino en caso de que no exista
        folder.mkdirs();

        int numeroAleatorio = (int) (Math.random() * 2500 + 1);
        //Nombre del fichero <strong>PDF</strong> Resultante de la ejecucion
        String dir = "C:\\seiya\\ordenes\\Orden_" + codOrden + ".pdf";
        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream(dir);
        Rectangle pageSize = new Rectangle(792f, 612f); //ancho y alto ->tamao carta
        //Creacion del documento con un tamao y unos margenes predeterminados

        Document document = new Document(pageSize, 1, 1, 1, 1);
        // Obtener la instancia del PdfWriter
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);

        //Opens the document.
        //You have to open the document before you can begin to add content to the body of the document.
        document.open();
        //**************************************************************

        //Ejemplos de TABLE
        titulo = new Chunk("", FontFactory.getFont(FontFactory.COURIER, 20, Font.UNDERLINE, BaseColor.BLACK));
        document.add(titulo);
        //Aadir tabla 5 columnas
        PdfPTable table = new PdfPTable(40);
        //Aadir CABECERA

        PdfPCell cell = new PdfPCell();

        /*table.addCell(createImageCell(IMG1));*/
        cell = new PdfPCell(new Phrase(Tiq));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Orden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(codOrden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cliente));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(9);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ciudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ref));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cant));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        table.addCell(new Phrase(num21));
        table.addCell(new Phrase(num22));
        table.addCell(new Phrase(num23));
        table.addCell(new Phrase(num24));
        table.addCell(new Phrase(num25));
        table.addCell(new Phrase(num26));
        table.addCell(new Phrase(num27));
        table.addCell(new Phrase(num28));
        table.addCell(new Phrase(num29));
        table.addCell(new Phrase(num30));
        table.addCell(new Phrase(num31));
        table.addCell(new Phrase(num32));
        table.addCell(new Phrase(num33));
        table.addCell(new Phrase(num34));
        table.addCell(new Phrase(num35));
        table.addCell(new Phrase(num36));
        table.addCell(new Phrase(num37));
        table.addCell(new Phrase(num38));
        table.addCell(new Phrase(num39));
        table.addCell(new Phrase(num40));
        table.addCell(new Phrase(num41));
        table.addCell(new Phrase(num42));
        table.addCell(new Phrase(num43));

        cell = new PdfPCell(new Phrase(Col1));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Col2));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(OBSER));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(5);
        cell.setRowspan(1);
        table.addCell(cell);
        /*          
                  ArrayList<String> resul;
              resul = nuevoTiquet.CargarComboTiquet(id);//La consulta tiene que retornar un ArrayList
                  Iterator<String> tiqIterator = resul.iterator();
              while(tiqIterator.hasNext()){
                    String valorTiq = tiqIterator.next();
                            
        //System.out.print(valorTiquet+" / ");
                     // this.impOrd.imp(valorTiq, idOrden, idCadOrden, numRegTiq );
              }
                      
              */

        ArrayList<String> resultat;
        resultat = nuevoTiquet.consultarTiquetporOrden(idOrden);
        Iterator<String> tiquetIterator = resultat.iterator();

        while (tiquetIterator.hasNext()) {
            String valorTiquet = tiquetIterator.next();
            System.out.print(valorTiquet + " ------ ");
            String sql = "Select * from tiquet where idorden = '" + idOrden + "' and tiquet='" + valorTiquet
                    + "'";
            rs = Consultar(sql);

            while (rs.next()) {

                c1 = rs.getInt(1);
                c2 = rs.getInt(2);
                c3 = rs.getInt(3);
                c4 = rs.getInt(4);
                c5 = rs.getInt(5);
                observacion = rs.getString(6);
                verificacion = rs.getString(7);
                c8 = rs.getInt(8);
                c9 = rs.getInt(9);
                c10 = rs.getInt(10);
                c11 = rs.getInt(11);
                c12 = rs.getInt(12);
                c13 = rs.getInt(13);
                c14 = rs.getInt(14);
                c15 = rs.getInt(15);
                c16 = rs.getInt(16);
                c17 = rs.getInt(17);
                c18 = rs.getInt(18);
                c19 = rs.getInt(19);
                c20 = rs.getInt(20);
                c21 = rs.getInt(21);
                c22 = rs.getInt(22);
                c23 = rs.getInt(23);
                c24 = rs.getInt(24);
                c25 = rs.getInt(25);
                c26 = rs.getInt(26);
                c27 = rs.getInt(27);
                c28 = rs.getInt(28);
                c29 = rs.getInt(29);
                c30 = rs.getInt(30);
                c31 = rs.getInt(31);
                c32 = rs.getInt(32);
                c33 = rs.getInt(33);

                String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ",
                        c09 = " ", c010 = " ", c011 = " ", c012 = " ";
                String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ",
                        c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " ";
                String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ",
                        c032 = " ", c033 = " ", c034 = " ";
                if (c1 != 0)
                    c01 = String.valueOf(c1);
                if (c2 != 0)
                    c02 = String.valueOf(c2);
                if (c3 != 0)
                    c03 = String.valueOf(c3);
                if (c4 != 0)
                    c04 = String.valueOf(c4);
                if (c5 != 0)
                    c05 = String.valueOf(c5);
                if (c8 != 0)
                    c08 = String.valueOf(c8);
                if (c9 != 0)
                    c09 = String.valueOf(c9);
                if (c10 != 0)
                    c010 = String.valueOf(c10);
                if (c11 != 0)
                    c011 = String.valueOf(c11);
                if (c12 != 0)
                    c012 = String.valueOf(c12);
                if (c13 != 0)
                    c013 = String.valueOf(c13);
                if (c14 != 0)
                    c014 = String.valueOf(c14);
                if (c15 != 0)
                    c015 = String.valueOf(c15);
                if (c16 != 0)
                    c016 = String.valueOf(c16);
                if (c17 != 0)
                    c017 = String.valueOf(c17);
                if (c18 != 0)
                    c018 = String.valueOf(c18);
                if (c19 != 0)
                    c019 = String.valueOf(c19);
                if (c20 != 0)
                    c020 = String.valueOf(c20);
                if (c21 != 0)
                    c021 = String.valueOf(c21);
                if (c22 != 0)
                    c022 = String.valueOf(c22);
                if (c23 != 0)
                    c023 = String.valueOf(c23);
                if (c24 != 0)
                    c024 = String.valueOf(c24);
                if (c25 != 0)
                    c025 = String.valueOf(c25);
                if (c26 != 0)
                    c026 = String.valueOf(c26);
                if (c27 != 0)
                    c027 = String.valueOf(c27);
                if (c28 != 0)
                    c028 = String.valueOf(c28);
                if (c29 != 0)
                    c029 = String.valueOf(c29);
                if (c30 != 0)
                    c030 = String.valueOf(c30);
                if (c31 != 0)
                    c031 = String.valueOf(c31);
                if (c32 != 0)
                    c032 = String.valueOf(c32);
                if (c33 != 0)
                    c033 = String.valueOf(c33);

                colorUno = verColor.consultarNombreColorUno(c4);
                colorDos = verColor.consultarNombreColorDos(c5);
                //  ob = verTiquet.ConsultaObservacion(tiquet);
                Chunk ValCol1 = new Chunk(colorUno,
                        FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValCol2 = new Chunk(colorDos,
                        FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValObserv = new Chunk(ob,
                        FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));

                System.out.print("Color Uno: " + colorUno);
                table.addCell(new Phrase(ValTiq));
                table.addCell("2");
                table.addCell("3");
                table.addCell("4");
                table.addCell("5");
                table.addCell("6");

                table.addCell("7");
                table.addCell("8");
                table.addCell("9");
                table.addCell("10");
                table.addCell("11");
                table.addCell("12");
                table.addCell("13");
                table.addCell("14");
                table.addCell("15");
                table.addCell("16");
                table.addCell("17");
                table.addCell("18");
                table.addCell("18");
                table.addCell("20");
                table.addCell("21");
                table.addCell("22");
                table.addCell("23");

                table.addCell("24");
                table.addCell("25");
                table.addCell("26");
                table.addCell("27");
                table.addCell("28");
                table.addCell("29");
                table.addCell("30");
                table.addCell("31");
                table.addCell("32");
                table.addCell("33");
                table.addCell("34");
                table.addCell("35");

                table.addCell("36");
                table.addCell("37");
                table.addCell("38");
                table.addCell("39");
                table.addCell("40");

                table.setWidthPercentage(100f);
                table.setHorizontalAlignment(Element.ALIGN_RIGHT);

                document.add(table);

            }

        }

        document.close();

        return "exito";

    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        return "Error al Generar el PDF";
    }

}

From source file:modelo.pruebapdf.java

public boolean impOrden(int idOrden, String codOrden, int numRegTiq) {
    try {/*from   ww w  .  j  a v  a2s  .  co m*/

        int id = 0;
        int numTiquet = 0;
        String ob = "";
        colores verColor = new colores();
        String colorUno = "";
        String colorDos = "";
        ArrayList<String> lista = new ArrayList<String>();
        int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0,
                c13 = 0, c14 = 0, c15 = 0;
        int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0,
                c27 = 0, c28 = 0, c29 = 0;
        int c30 = 0, c31 = 0, c32 = 0, c33 = 0;
        String observacion = "";
        int CanTotal = 0;

        int idCliente = 0;
        String ciu = "";
        String fecped = "";
        String fecent = "";

        for (orden ord : new orden().CargarDatosOrden(codOrden)) {
            idCliente = ord.getCliente();
            ciu = ord.getCiudad();
            fecped = ord.getPedido();
            fecent = ord.getEntrega();
        }
        String nomCliente = nuevaOrden.ConsultarNombreCliente(idCliente);

        Chunk idClient = new Chunk(nomCliente,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Tiq = new Chunk("TK",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValTiq = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Tel = new Chunk("Tel: 5783364",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Ref = new Chunk("REF",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValRef = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Correo = new Chunk("calzadoseiya@gmail.com",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK));
        Chunk Cliente = new Chunk("CLIENTE",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecEnt = new Chunk("FECHA ENTREGA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecEnt = new Chunk(fecent,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FecPed = new Chunk("FECHA PEDIDO",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValFecPed = new Chunk(fecped,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk FechaTiq2 = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Orden = new Chunk("ORDEN",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValOrd = new Chunk("",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Ciudad = new Chunk("CIUDAD",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk ValCiudad = new Chunk(ciu,
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Cant = new Chunk("CANT.",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Mon = new Chunk("MONTADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Emp = new Chunk("EMPLANTILLADA",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk OBSER = new Chunk("OBSERVACION",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK));
        Chunk Col1 = new Chunk("Color 1",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Col2 = new Chunk("Color 2",
                FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK));
        Chunk Encabezado = new Chunk("SEIYA",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK));
        Chunk num21 = new Chunk("21",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num22 = new Chunk("22",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num23 = new Chunk("23",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num24 = new Chunk("24",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num25 = new Chunk("25",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num26 = new Chunk("26",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num27 = new Chunk("27",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num28 = new Chunk("28",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num29 = new Chunk("29",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num30 = new Chunk("30",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num31 = new Chunk("31",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num32 = new Chunk("32",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num33 = new Chunk("33",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num34 = new Chunk("34",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num35 = new Chunk("35",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num36 = new Chunk("36",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num37 = new Chunk("37",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num38 = new Chunk("38",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num39 = new Chunk("39",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num40 = new Chunk("40",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num41 = new Chunk("41",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num42 = new Chunk("42",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num43 = new Chunk("43",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));
        Chunk num44 = new Chunk("44",
                FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK));

        File folder = new File("c:\\seiya\\ordenes");
        folder.mkdirs();
        String dir = "C:\\seiya\\ordenes\\Orden_" + codOrden + ".pdf";
        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream(dir);
        Rectangle pageSize = new Rectangle(792f, 612f);

        Document document = new Document(pageSize, 1, 1, 1, 1);
        PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream);
        document.open();

        PdfPTable table = new PdfPTable(40);
        PdfPCell cell = new PdfPCell();

        Image image = Image.getInstance("logo.png");
        //    String col = "jhon";
        cell = new PdfPCell(image);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(7);
        cell.setRowspan(7);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(direccion));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tel));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Correo));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(2);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(" "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(33);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Tiq));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Orden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(codOrden));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cliente));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(idClient));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(9);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ciudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValCiudad));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecPed));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(FecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(ValFecEnt));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(4);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Ref));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Cant));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(2);
        cell.setRowspan(1);
        table.addCell(cell);

        table.addCell(new Phrase(num21));
        table.addCell(new Phrase(num22));
        table.addCell(new Phrase(num23));
        table.addCell(new Phrase(num24));
        table.addCell(new Phrase(num25));
        table.addCell(new Phrase(num26));
        table.addCell(new Phrase(num27));
        table.addCell(new Phrase(num28));
        table.addCell(new Phrase(num29));
        table.addCell(new Phrase(num30));
        table.addCell(new Phrase(num31));
        table.addCell(new Phrase(num32));
        table.addCell(new Phrase(num33));
        table.addCell(new Phrase(num34));
        table.addCell(new Phrase(num35));
        table.addCell(new Phrase(num36));
        table.addCell(new Phrase(num37));
        table.addCell(new Phrase(num38));
        table.addCell(new Phrase(num39));
        table.addCell(new Phrase(num40));
        table.addCell(new Phrase(num41));
        table.addCell(new Phrase(num42));
        table.addCell(new Phrase(num43));

        cell = new PdfPCell(new Phrase(Col1));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(Col2));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(3);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(OBSER));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(5);
        cell.setRowspan(1);
        table.addCell(cell);

        ArrayList<String> resultat;
        resultat = nuevoTiquet.consultarTiquetporOrden(idOrden);
        Iterator<String> tiquetIterator = resultat.iterator();

        while (tiquetIterator.hasNext()) {

            String valorTiquet = tiquetIterator.next();
            System.out.print(valorTiquet + " ------ ");
            int tiq = Integer.parseInt(valorTiquet);
            ArrayList<tiquet> listaDatosTiquet;
            listaDatosTiquet = nuevoTiquet.conten(idOrden, tiq);//La consulta tiene que retornar un ArrayList

            for (tiquet ord : new tiquet().conten(idOrden, tiq)) {
                System.out.print("Referencia: " + nuevoTiquet.ConsultarReferencia(tiq, idOrden));
                c1 = ord.getTiquet();
                c2 = ord.getIdorden();
                observacion = ord.getObservacion();
                c4 = nuevoTiquet.ConsultarReferencia(tiq, idOrden);
                c5 = nuevoTiquet.ConsultarCantidad(tiq, idOrden);
                c8 = ord.getN21();
                c9 = ord.getN22();
                c10 = ord.getN23();
                c11 = ord.getN24();
                c12 = ord.getN25();
                c13 = ord.getN26();
                c14 = ord.getN27();
                c15 = ord.getN28();
                c16 = ord.getN29();
                c17 = ord.getN30();
                c18 = ord.getN31();
                c19 = ord.getN32();
                c20 = ord.getN33();
                c21 = ord.getN34();
                c22 = ord.getN35();
                c23 = ord.getN36();
                c24 = ord.getN37();
                c25 = ord.getN38();
                c26 = ord.getN39();
                c27 = ord.getN40();
                c28 = ord.getN41();
                c29 = ord.getN42();
                c30 = ord.getN43();

                String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ",
                        c09 = " ", c010 = " ", c011 = " ", c012 = " ";
                String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ",
                        c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " ";
                String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ",
                        c032 = " ", c033 = " ", c034 = " ";
                if (c1 != 0)
                    c01 = String.valueOf(c1);
                if (c2 != 0)
                    c02 = String.valueOf(c2);
                //    if(c3!=0) c03 = String.valueOf(c3);
                if (c4 != 0)
                    c04 = String.valueOf(c4);
                if (c5 != 0) {
                    c05 = String.valueOf(c5);
                    CanTotal += c5;
                }
                if (c8 != 0)
                    c08 = String.valueOf(c8);
                if (c9 != 0)
                    c09 = String.valueOf(c9);
                if (c10 != 0)
                    c010 = String.valueOf(c10);
                if (c11 != 0)
                    c011 = String.valueOf(c11);
                if (c12 != 0)
                    c012 = String.valueOf(c12);
                if (c13 != 0)
                    c013 = String.valueOf(c13);
                if (c14 != 0)
                    c014 = String.valueOf(c14);
                if (c15 != 0)
                    c015 = String.valueOf(c15);
                if (c16 != 0)
                    c016 = String.valueOf(c16);
                if (c17 != 0)
                    c017 = String.valueOf(c17);
                if (c18 != 0)
                    c018 = String.valueOf(c18);
                if (c19 != 0)
                    c019 = String.valueOf(c19);
                if (c20 != 0)
                    c020 = String.valueOf(c20);
                if (c21 != 0)
                    c021 = String.valueOf(c21);
                if (c22 != 0)
                    c022 = String.valueOf(c22);
                if (c23 != 0)
                    c023 = String.valueOf(c23);
                if (c24 != 0)
                    c024 = String.valueOf(c24);
                if (c25 != 0)
                    c025 = String.valueOf(c25);
                if (c26 != 0)
                    c026 = String.valueOf(c26);
                if (c27 != 0)
                    c027 = String.valueOf(c27);
                if (c28 != 0)
                    c028 = String.valueOf(c28);
                if (c29 != 0)
                    c029 = String.valueOf(c29);
                if (c30 != 0)
                    c030 = String.valueOf(c30);

                cell = new PdfPCell(new Phrase(String.valueOf(tiq)));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c04));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c05));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(2);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(c08));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c09));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c010));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c011));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c012));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c013));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c014));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c015));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c016));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c017));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c018));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c019));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c020));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c021));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c022));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c023));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c024));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c025));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c026));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c027));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c028));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c029));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(c030));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(1);
                cell.setRowspan(1);
                table.addCell(cell);

                colorUno = verColor.consultarNombreColorUno(ord.getIdcoloruno());
                colorDos = verColor.consultarNombreColorDos(ord.getIdcolordos());
                //  ob = verTiquet.ConsultaObservacion(tiquet);
                Chunk ValCol1 = new Chunk(colorUno,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValCol2 = new Chunk(colorDos,
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));
                Chunk ValObserv = new Chunk(ord.getObservacion(),
                        FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK));

                cell = new PdfPCell(new Phrase(ValCol1));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);
                cell = new PdfPCell(new Phrase(ValCol2));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(3);
                cell.setRowspan(1);
                table.addCell(cell);

                cell = new PdfPCell(new Phrase(ValObserv));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setColspan(5);
                cell.setRowspan(1);
                table.addCell(cell);

            }

        }
        cell = new PdfPCell(new Phrase("Cantidad Total de Pares Producidos "));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(15);
        cell.setRowspan(1);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(String.valueOf(CanTotal)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setColspan(25);
        cell.setRowspan(1);
        table.addCell(cell);

        table.setWidthPercentage(100f);
        table.setHorizontalAlignment(Element.ALIGN_RIGHT);
        document.add(table);

        document.close();

        return true;
    } catch (Exception x) {
        return false;
    }

}

From source file:net.vzurczak.timesheetgenerator.PdfGenerator.java

License:Apache License

/**
 * Adds a page for a given week.//from  w ww  . j a  v  a2s . c  o  m
 * @param i the week number
 * @param doc the document to update
 * @param bean a generation bean (not null)
 * @throws DocumentException
 */
private void addPageForWeek(int weekNumber, Document doc, GenerationDataBean bean) throws DocumentException {

    doc.newPage();
    final Font boldFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD);
    final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA);
    Calendar calendar = Utils.findCalendar(weekNumber);

    // Title
    Paragraph paragraph = new Paragraph("Bordereau de Dclaration des Temps", boldFont);
    paragraph.setAlignment(Element.ALIGN_CENTER);
    doc.add(paragraph);

    doc.add(new Paragraph(" "));
    doc.add(new Paragraph(" "));

    // Meta: week
    final PdfPTable metaTable = new PdfPTable(1);

    paragraph = new Paragraph();
    paragraph.add(new Chunk("Semaine : ", boldFont));
    paragraph.add(new Chunk(String.valueOf(weekNumber), normalFont));

    PdfPCell c = new PdfPCell(paragraph);
    c.setBorder(Rectangle.NO_BORDER);
    metaTable.addCell(c);

    // Meta: date
    Calendar endOfWeekCalendar = ((Calendar) calendar.clone());
    endOfWeekCalendar.add(Calendar.DATE, 4);
    String formattedDate = new SimpleDateFormat("dd/MM/yyyy").format(endOfWeekCalendar.getTime());

    paragraph = new Paragraph();
    paragraph.add(new Chunk("Date : ", boldFont));
    paragraph.add(new Chunk(formattedDate, normalFont));

    c = new PdfPCell(paragraph);
    c.setBorder(Rectangle.NO_BORDER);
    metaTable.addCell(c);

    doc.add(metaTable);
    doc.add(new Paragraph(" "));
    doc.add(new Paragraph(" "));

    // Signatures
    final PdfPTable signaturesTable = new PdfPTable(2);
    paragraph = new Paragraph();
    paragraph.add(new Chunk("Nom : ", boldFont));
    paragraph.add(new Chunk(bean.getName(), normalFont));

    c = new PdfPCell(paragraph);
    c.setBorder(Rectangle.NO_BORDER);
    signaturesTable.addCell(c);

    paragraph = new Paragraph();
    paragraph.add(new Chunk("Responsable : ", boldFont));
    paragraph.add(new Chunk(bean.getManagerName(), normalFont));

    c = new PdfPCell(paragraph);
    c.setBorder(Rectangle.NO_BORDER);
    signaturesTable.addCell(c);

    c = new PdfPCell(new Paragraph("Signature : ", boldFont));
    c.setBorder(Rectangle.NO_BORDER);
    signaturesTable.addCell(c);

    c = new PdfPCell(new Paragraph("Signature : ", boldFont));
    c.setBorder(Rectangle.NO_BORDER);
    signaturesTable.addCell(c);

    doc.add(signaturesTable);
    doc.add(new Paragraph(" "));
    doc.add(new Paragraph(" "));
    doc.add(new Paragraph(" "));
    doc.add(new Paragraph(" "));

    // Calendar
    final PdfPTable timeTable = new PdfPTable(7);
    timeTable.addCell(new PdfPCell());

    for (int i = 0; i < 5; i++) {
        final String date = this.sdf.format(calendar.getTime());
        timeTable.addCell(newCell(date, 10));
        calendar.add(Calendar.DATE, 1);
    }

    timeTable.addCell(newCell("Total", 10));
    timeTable.addCell(newCell("Heures Effectues", 20));

    for (int i = 0; i < 5; i++)
        timeTable.addCell(newCell("", 20));

    if (bean.getTotalHours() > 0)
        timeTable.addCell(newCell(bean.getTotalHours() + " h", 20));

    timeTable.completeRow();
    doc.add(timeTable);
}