Example usage for com.itextpdf.text Rectangle TOP

List of usage examples for com.itextpdf.text Rectangle TOP

Introduction

In this page you can find the example usage for com.itextpdf.text Rectangle TOP.

Prototype

int TOP

To view the source code for com.itextpdf.text Rectangle TOP.

Click Source Link

Document

This represents one side of the border of the Rectangle.

Usage

From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java

License:Open Source License

private static Document personalCertification(Document document, PdfWriter writer, AddressBook addressbook) {
    // TODO Auto-generated method stub
    log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalCertification ");
    try {/*  w ww .  j  a v  a2 s.co m*/

        /*  New Page   */
        document.newPage();

        PdfPTable table = new PdfPTable(2);
        table.setSpacingBefore(10);
        table.setWidthPercentage(100f);
        int i = 0;

        for (Iterator itr = addressbook.getCandidateProfessionalCertifications().iterator(); itr.hasNext();) {
            CandidateProfessionalCertification procertification = (CandidateProfessionalCertification) itr
                    .next();
            if (i != 0) {
                PdfPCell c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);
            }
            i++;
            PdfPCell c1 = new PdfPCell(new Phrase("PERSONAL CERTIFICATION"));
            c1.setHorizontalAlignment(Element.ALIGN_LEFT);
            c1.setColspan(4);
            c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP);
            c1.setFixedHeight(30f);
            c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
            c1.setBorder(Rectangle.BOX);
            c1.setFixedHeight(25f);
            table.addCell(c1);
            table.setHeaderRows(1);

            for (int j = 0; j < 2; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(new Phrase("Certificate Name: " + procertification.getCertificateName(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Chrater Agency: " + procertification.getCharterAgency(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            for (int j = 0; j < 2; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(
                    new Phrase("Charter Date : " + format.format(procertification.getCharterDate()), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            //c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

        }

        document.add(table);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalCertification " + e.getMessage());
        e.printStackTrace();
        e.printStackTrace();
        LogsMaintenance logsMain = new LogsMaintenance();
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString());
    }

    return document;
}

From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java

License:Open Source License

private static Document Education(Document document, PdfWriter writer, AddressBook addressbook) {
    // TODO Auto-generated method stub
    log.log(Level.INFO, "ApplicationFormPDFMaintenance --> Education ");
    try {//from  ww  w.  java2  s  . c om

        /*  New Page   */
        document.newPage();

        PdfPTable table = new PdfPTable(2);
        table.setSpacingBefore(10);
        table.setWidthPercentage(100f);

        int i = 0;
        for (Iterator itr = addressbook.getCandidateEducations().iterator(); itr.hasNext();) {
            CandidateEducation candidateEducation = (CandidateEducation) itr.next();
            if (i != 0) {
                PdfPCell c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);
            }

            i++;
            PdfPCell c1 = new PdfPCell(new Phrase("EDUCATION"));
            c1.setHorizontalAlignment(Element.ALIGN_LEFT);
            c1.setColspan(4);
            c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP);
            c1.setFixedHeight(30f);
            c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
            c1.setBorder(Rectangle.BOX);
            c1.setFixedHeight(25f);
            table.addCell(c1);
            table.setHeaderRows(1);

            for (int j = 0; j < 2; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(
                    new Phrase("Start Date: " + format.format(candidateEducation.getStartDate()), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("End Date: " + format.format(candidateEducation.getEndDate()), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            for (int j = 0; j < 2; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(new Phrase("Witness : " + candidateEducation.getWitness(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Education : " + candidateEducation.getEducation(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            for (int j = 0; j < 2; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(new Phrase("Education Level : " + candidateEducation.getEducationLevel(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("School : " + candidateEducation.getSchool(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            for (int j = 0; j < 2; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(
                    new Phrase("Witness Contect Number : " + candidateEducation.getWitnessContactNo(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            //c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

        }
        document.add(table);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        log.log(Level.INFO, "ApplicationFormPDFMaintenance --> Education " + e.getMessage());
        e.printStackTrace();
        e.printStackTrace();
        LogsMaintenance logsMain = new LogsMaintenance();
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString());
    }

    return document;
}

From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java

License:Open Source License

private static Document workExperience(Document document, PdfWriter writer, AddressBook addressbook) {
    // TODO Auto-generated method stub
    log.log(Level.INFO, "ApplicationFormPDFMaintenance --> workExperience ");
    try {//from  www  .java  2 s .co m

        document.newPage();

        PdfPTable table = new PdfPTable(3);
        table.setSpacingBefore(10);
        table.setWidthPercentage(100f);

        int i = 0;

        for (Iterator itr = addressbook.getCandidateWorkExperiences().iterator(); itr.hasNext();) {
            CandidateWorkExperience candidateWorkExp = (CandidateWorkExperience) itr.next();
            if (i != 0) {

                PdfPCell c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);
            }
            i++;
            PdfPCell c1 = new PdfPCell(new Phrase("WORK EXPERIENCE"));
            c1.setHorizontalAlignment(Element.ALIGN_LEFT);
            c1.setColspan(4);
            c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP);
            c1.setFixedHeight(30f);
            c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
            c1.setBorder(Rectangle.BOX);
            c1.setFixedHeight(25f);
            table.addCell(c1);
            table.setHeaderRows(1);

            for (int j = 0; j < 3; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(
                    new Phrase("Start Date: " + format.format(candidateWorkExp.getStartDate()), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("End Date: " + format.format(candidateWorkExp.getEndDate()), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Witness: " + candidateWorkExp.getWitness(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            for (int j = 0; j < 3; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(new Phrase("Unit : " + candidateWorkExp.getUnit(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Occupation : " + candidateWorkExp.getOccupation(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Witness Contect Number : \n\n\n  \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
                    + candidateWorkExp.getWitnessContactNo(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(25f);
            //c1.setPaddingBottom(10f);
            c1.setBorder(Rectangle.BOTTOM);

            table.addCell(c1);

            for (int j = 0; j < 3; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }
            c1 = new PdfPCell(new Phrase("Income : " + candidateWorkExp.getIncome(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Possition : " + candidateWorkExp.getPosition(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

        }

        document.add(table);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        log.log(Level.INFO, "ApplicationFormPDFMaintenance --> workExperience " + e.getMessage());
        e.printStackTrace();
        e.printStackTrace();
        LogsMaintenance logsMain = new LogsMaintenance();
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString());
    }
    return document;
}

From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java

License:Open Source License

private static Document familyInformation(Document document, PdfWriter writer, AddressBook addressbook) {
    // TODO Auto-generated method stub
    log.log(Level.INFO, "ApplicationFormPDFMaintenance --> familyInformation ");
    try {/* w  w w  .  j  a va 2s .c om*/

        /*  New Page   */
        document.newPage();

        PdfPTable table = new PdfPTable(3);
        table.setSpacingBefore(10);
        table.setWidthPercentage(100f);
        //Set familylist=addressbook.getCandidateFamilyInfos();

        int i = 0;
        for (Iterator itr = addressbook.getCandidateFamilyInfos().iterator(); itr.hasNext();) {
            CandidateFamilyInfo candidateFamilyInfo = (CandidateFamilyInfo) itr.next();
            if (i != 0) {
                PdfPCell c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);
            }

            i++;
            PdfPCell c1 = new PdfPCell(new Phrase("FAMILY INFORMATION"));
            c1.setHorizontalAlignment(Element.ALIGN_LEFT);
            c1.setColspan(4);
            c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP);
            c1.setFixedHeight(30f);
            c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
            c1.setBorder(Rectangle.BOX);
            c1.setFixedHeight(25f);
            table.addCell(c1);
            table.setHeaderRows(1);

            for (int j = 0; j < 3; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(new Phrase("Name: " + candidateFamilyInfo.getName(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Unit: " + candidateFamilyInfo.getUnit(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Possition: " + candidateFamilyInfo.getPosition(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            for (int j = 0; j < 3; j++) {
                c1 = new PdfPCell(new Phrase(" ", font));
                c1.setBorder(Rectangle.NO_BORDER);
                c1.setLeading(4f, 0f);
                c1.setFixedHeight(15f);
                table.addCell(c1);

            }

            c1 = new PdfPCell(new Phrase("Relationship : " + candidateFamilyInfo.getRelationship(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Occupation : " + candidateFamilyInfo.getOccupation(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

            c1 = new PdfPCell(new Phrase("Phone : " + candidateFamilyInfo.getPhoneNo(), font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            c1.setBorder(Rectangle.BOTTOM);
            table.addCell(c1);

        }

        document.add(table);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        log.log(Level.INFO, "ApplicationFormPDFMaintenance --> familyInformation " + e.getMessage());
        e.printStackTrace();
        e.printStackTrace();
        LogsMaintenance logsMain = new LogsMaintenance();
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString());
    }
    return document;
}

From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java

License:Open Source License

private static Document personalInformation(Document document, PdfWriter writer, AddressBook addressbook,
        Font normalFontCH) {/*  w w  w . ja v  a 2s  .  c  o m*/
    // TODO Auto-generated method stub
    log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalInformation ");
    try {

        PdfPTable table = new PdfPTable(2);
        table.setSpacingBefore(10);
        table.setWidthPercentage(100f);

        PdfPCell c1 = new PdfPCell(new Phrase("PERSONAL INFORMATION"));
        c1.setHorizontalAlignment(Element.ALIGN_LEFT);
        c1.setColspan(4);
        c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP);
        c1.setFixedHeight(30f);
        c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
        c1.setBorder(Rectangle.BOX);
        c1.setFixedHeight(25f);
        table.addCell(c1);
        table.setHeaderRows(1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Candidate's Name: " + addressbook.getName(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("NRIC: " + addressbook.getNric(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("??*  ", normalFontCH));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("???(*) ", normalFontCH));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Date of Birth: " + format.format(addressbook.getBirthDate()), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Gender: " + addressbook.getGender(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Age: " + addressbook.getAge(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Place of Birth: " + addressbook.getBirthPlace(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("(*)", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Education: " + addressbook.getEducation(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Maritial Status: " + addressbook.getMarritalStatus(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Annual Income: " + addressbook.getYearlyIncome(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Work Experience:  " + addressbook.getWorkingYearExperience(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase(
                "Address : " + addressbook.getResidentialAddress1() + " ,"
                        + addressbook.getResidentialAddress2() + " , " + addressbook.getResidentialAddress3(),
                font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(" ", font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("??*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(" ", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Postal Code: " + addressbook.getResidentialPostalCode(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.NO_BORDER);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("Mobile Number: " + addressbook.getMobilePhoneNo(), font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase("??*", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(" ", normalFontCH));
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        for (int j = 0; j < 2; j++) {
            c1 = new PdfPCell(new Phrase(" ", font));
            c1.setBorder(Rectangle.NO_BORDER);
            c1.setLeading(4f, 0f);
            c1.setFixedHeight(15f);
            table.addCell(c1);

        }

        c1 = new PdfPCell(new Phrase("Email Address: " + addressbook.geteMailId(), font));
        c1.setBorder(Rectangle.NO_BORDER);
        c1.setLeading(4f, 0f);
        c1.setFixedHeight(15f);
        //c1.setPaddingLeft(30f);
        c1.setBorder(Rectangle.BOTTOM);
        table.addCell(c1);

        c1 = new PdfPCell(new Phrase(" ", font));
        c1.setFixedHeight(15f);
        c1.setBorder(Rectangle.BOTTOM);
        c1.setLeading(4f, 0f);
        table.addCell(c1);

        document.add(table);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalInformation " + e.getMessage());
        e.printStackTrace();
        e.printStackTrace();
        LogsMaintenance logsMain = new LogsMaintenance();
        StringWriter errors = new StringWriter();
        e.printStackTrace(new PrintWriter(errors));
        logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString());
    }
    return document;
}

From source file:com.softwaremagico.tm.pdf.complete.skills.MainSkillsTableFactory.java

License:Open Source License

public static PdfPTable getSkillsTable(CharacterPlayer characterPlayer, String language)
        throws InvalidXmlElementException {
    float[] widths = { 1f, 12f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);// w  w  w. ja v a2s  . c o m

    PdfPCell separator = createSeparator();
    separator.setPadding(PADDING);
    table.addCell(separator);
    table.addCell(separator);
    table.addCell(separator);

    PdfPCell vitalityCell = new PdfPCell(new VitalityTable(characterPlayer));
    vitalityCell.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP | Rectangle.LEFT);
    vitalityCell.setPadding(0);
    table.addCell(vitalityCell);

    PdfPCell skillsCell = new PdfPCell(CompleteSkillsTable.getSkillsTable(characterPlayer, language));
    skillsCell.setBorder(0);
    skillsCell.setPadding(0);
    skillsCell.setPaddingRight(FadingSunsTheme.DEFAULT_MARGIN);
    skillsCell.setPaddingLeft(FadingSunsTheme.DEFAULT_MARGIN);
    table.addCell(skillsCell);

    PdfPCell wyrdCell = new PdfPCell(new WyrdTable(characterPlayer));
    wyrdCell.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP | Rectangle.LEFT);
    wyrdCell.setPadding(0);
    table.addCell(wyrdCell);
    return table;
}

From source file:com.udec.utilidades.PdfTable.java

public PdfPTable tabla3(List<Nomina> no) throws DocumentException {
    //Instanciamos una tabla de 3 columnas
    PdfPTable tabla = new PdfPTable(4);
    tabla.setWidthPercentage(100);/*  w ww . j ava 2  s.c  o m*/
    tabla.setWidths(new float[] { 1, 3, 1, 1 });
    //Declaramos un objeto para manejar las celdas
    PdfPCell celda;
    celda = new PdfPCell(new Phrase("CODIGO"));
    celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    celda.setBorder(Rectangle.BOTTOM);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderWidth(1);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("DESCRIPCION"));
    celda.setBorder(Rectangle.BOTTOM);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderWidth(1);
    celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("VLR.DEVEN"));
    celda.setBorder(Rectangle.BOTTOM);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderWidth(1);
    celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    celda.setBorderWidth(1);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("VLR.DEDUC"));
    celda.setBorder(Rectangle.BOTTOM);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderWidth(1);
    celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    tabla.addCell(celda);
    double totalDev = 0, totalDed = 0;
    for (Nomina nomina : no) {
        celda = new PdfPCell(new Phrase("" + nomina.getConceptoIdconcepto().getCodigo()));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        tabla.addCell(celda);
        celda = new PdfPCell(new Phrase("" + nomina.getConceptoIdconcepto().getConcepto()));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
        tabla.addCell(celda);
        if (nomina.getConceptoIdconcepto().getTipo().equals("DEVENGADO")) {
            totalDev += nomina.getValor();
            celda = new PdfPCell(new Phrase("" + nomina.getValor()));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tabla.addCell(celda);
        } else {
            celda = new PdfPCell(new Phrase(""));
            celda.setBorder(Rectangle.NO_BORDER);
            tabla.addCell(celda);
        }
        if (nomina.getConceptoIdconcepto().getTipo().equals("DEDUCIDO")) {
            totalDed += nomina.getValor();
            celda = new PdfPCell(new Phrase("" + nomina.getValor()));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            tabla.addCell(celda);
        } else {
            celda = new PdfPCell(new Phrase(""));
            celda.setBorder(Rectangle.NO_BORDER);
            tabla.addCell(celda);
        }

    }

    celda = new PdfPCell(new Phrase(""));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("TOTALES"));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("" + totalDev));
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    celda.setBorder(Rectangle.TOP);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase(" " + totalDed));
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    celda.setBorder(Rectangle.TOP);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase(""));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase("NETO A PAGAR"));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase(" " + (totalDev - totalDed)));
    celda.setBorder(Rectangle.NO_BORDER);
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    tabla.addCell(celda);
    celda = new PdfPCell(new Phrase(" "));
    celda.setBorder(Rectangle.NO_BORDER);
    tabla.addCell(celda);

    return tabla;
}

From source file:comisionesafis.informes.LiquidacionComisiones.java

private void printCabeceraColumnas(PdfPTable table) {

    PdfPCell celda;/*from w  w w.j a va  2 s  .c  om*/

    Font font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
    celda = new PdfPCell(new Phrase("NUMERO DE PLIZA", font));
    celda.setBorder(Rectangle.TOP + Rectangle.BOTTOM + Rectangle.LEFT);
    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(celda);
    celda = new PdfPCell(new Phrase("FECHA DE VENCIMIENTO", font));
    celda.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(celda);
    celda = new PdfPCell(new Phrase("FORMA DE PAGO", font));
    celda.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(celda);
    celda = new PdfPCell(new Phrase("BASE COMISIN", font));
    celda.setBorder(Rectangle.TOP + Rectangle.BOTTOM);
    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(celda);
    celda = new PdfPCell(new Phrase("IMPORTE", font));
    celda.setBorder(Rectangle.TOP + Rectangle.BOTTOM + Rectangle.RIGHT);
    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(celda);

}

From source file:comisionesafis.informes.LiquidacionComisiones.java

private void printResumenContable(PdfPTable tabla, Double total, String codAgente) {

    ResultSet rsAgente;/* w  w w .ja  v  a 2  s  .c o m*/
    Statement stmt;
    String sSQL = "";
    Double retencion;
    Double liquido;
    String patron = "dd/MM/yyyy";
    SimpleDateFormat formato = new SimpleDateFormat(patron);
    String fecha = (formato.format(new Date()));
    String cuenta;

    try {
        // SELECT para extraer todos los cdigos de los agentes con Recibos
        sSQL = "SELECT * ";
        sSQL += "  FROM Agentes";
        sSQL += " WHERE CodAgente ='" + codAgente + "'";
        stmt = conexion.createStatement();
        rsAgente = stmt.executeQuery(sSQL);

        PdfPCell celda;
        Font font;

        // Primera fila de datos
        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase(" ", font));
        celda.setColspan(3);
        celda.setBorder(Rectangle.TOP);
        tabla.addCell(celda);

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase("TOTAL ", font));
        celda.setBorder(Rectangle.TOP);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        tabla.addCell(celda);

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase(Numeros.formateaDosDecimales(total), font));
        celda.setBorder(Rectangle.TOP);
        celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tabla.addCell(celda);

        // Segunda fila de datos
        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase(" ", font));
        celda.setColspan(3);
        celda.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda);

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase("I.R.P.F. " + rsAgente.getString("RetencionPorcentaje") + "%", font));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        tabla.addCell(celda);

        retencion = total * (Double.parseDouble(rsAgente.getString("RetencionPorcentaje")) / 100);
        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase(Numeros.formateaDosDecimales(retencion), font));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tabla.addCell(celda);

        // Tercera fila de datos
        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase(" ", font));
        celda.setColspan(3);
        celda.setBorder(Rectangle.BOTTOM);
        tabla.addCell(celda);

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase("L?QUIDO ", font));
        celda.setBorder(Rectangle.BOTTOM);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        tabla.addCell(celda);

        liquido = total - retencion;
        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase(Numeros.formateaDosDecimales(liquido), font));
        celda.setBorder(Rectangle.BOTTOM);
        celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tabla.addCell(celda);

        // Cuenta
        cuenta = rsAgente.getString("Banco") + " ";
        cuenta += rsAgente.getString("Sucursal") + " ";
        cuenta += rsAgente.getString("DC") + " ";
        cuenta += rsAgente.getString("Cuenta") + " ";

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase("CTA n " + cuenta, font));
        celda.setColspan(5);
        celda.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda);

        // Firma
        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase("En Madrid a " + fecha, font));
        celda.setColspan(5);
        celda.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda);

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase("V.Bo. ", font));
        celda.setColspan(5);
        celda.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda);

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase(" ", font));
        celda.setColspan(5);
        celda.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda);

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase(" ", font));
        celda.setColspan(5);
        celda.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda);

        font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        celda = new PdfPCell(new Phrase("PELAYO VIDA", font));
        celda.setColspan(5);
        celda.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda);

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

}

From source file:Compras.Formatos.java

public void prefactura() {
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);/*  w w w . j  a v  a2  s  . c  om*/
    session = HibernateUtil.getSessionFactory().openSession();
    ord = (Orden) session.get(Orden.class, ord.getIdOrden());
    //factura=(Factura)session.get(Factura.class, factura.getIdFactura());
    try {
        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.000");
        formatoPorcentaje.setMinimumFractionDigits(2);

        //session.beginTransaction().begin();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);

        PDF reporte = new PDF();
        Date fecha = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
        String valor = dateFormat.format(fecha);
        File folder = new File("reportes/" + ord.getIdOrden());
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER, "Pedido", "reportes/" + ord.getIdOrden() + "/" + valor + "-preFac.pdf");
        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        float tam[] = new float[] { 40, 40, 350, 70, 70 };
        PdfPTable tabla = reporte.crearTabla(5, tam, 100, Element.ALIGN_LEFT);

        //Pedido ord = (Pedido)session.get(Pedido.class, Integer.parseInt(this.no_ped));
        cabeceraPre(reporte, bf, tabla);

        Partida[] cuentas = (Partida[]) session.createCriteria(Partida.class)
                .add(Restrictions.eq("ordenByIdOrden.idOrden", ord.getIdOrden()))
                .add(Restrictions.eq("facturado", true)).add(Restrictions.eq("incluida", false))
                .addOrder(Order.asc("idEvaluacion")).addOrder(Order.asc("subPartida")).list()
                .toArray(new Partida[0]);
        Partida[] enlazadas = (Partida[]) session.createCriteria(Partida.class)
                .add(Restrictions.eq("ordenByEnlazada.idOrden", ord.getIdOrden()))
                .add(Restrictions.eq("facturado", true)).addOrder(Order.asc("idEvaluacion"))
                .addOrder(Order.asc("subPartida")).list().toArray(new Partida[0]);
        Adicionales[] externas = (Adicionales[]) session.createCriteria(Adicionales.class)
                .add(Restrictions.eq("orden.idOrden", ord.getIdOrden())).addOrder(Order.asc("idAdicionales"))
                .list().toArray(new Adicionales[0]);

        //**********agregamos la mano de obra*******************
        double tot_mo = 0.0d;
        Query query = session.createQuery("SELECT SUM( " + "(CASE WHEN dm>0 THEN (dm*cant) ELSE 0 END) + "
                + "(CASE WHEN cam>0 THEN (cam*cant) ELSE 0 END) + "
                + "(CASE WHEN repMin>0 THEN (repMin*cant) ELSE 0 END) + "
                + "(CASE WHEN repMed>0 THEN (repMed*cant) ELSE 0 END) + "
                + "(CASE WHEN repMax>0 THEN (repMax*cant) ELSE 0 END) + "
                + "(CASE WHEN pint>0 THEN (pint*cant) ELSE 0 END) " + ") from Partida "
                + " where ordenByIdOrden.idOrden =" + ord.getIdOrden() + " OR ordenByEnlazada.idOrden ="
                + ord.getIdOrden());
        Object ent = query.uniqueResult();
        if (ent != null) {
            tot_mo = Double.parseDouble(ent.toString()) * ord.getCompania().getImporteHora();
        }
        if (ord.getMoDirecta() > 0d)
            tot_mo = ord.getMoDirecta();
        tabla.addCell(reporte.celda("1", font, contenido, derecha, 0, 1, 12));
        tabla.addCell(reporte.celda("NA", font, contenido, izquierda, 0, 1, 12));
        tabla.addCell(reporte.celda("MANO DE OBRA", font, contenido, izquierda, 0, 1, 12));
        tabla.addCell(reporte.celda("" + formatoPorcentaje.format(tot_mo), font, contenido, derecha, 0, 1, 12));
        tabla.addCell(reporte.celda("" + formatoPorcentaje.format(tot_mo), font, contenido, derecha, 0, 1, 12));
        int ren = 0;
        double total = tot_mo;
        if (cuentas.length > 0) {
            for (int i = 0; i < cuentas.length; i++) {
                tabla.addCell(reporte.celda("" + cuentas[i].getCantidadFactura(), font, contenido, derecha, 0,
                        1, 12));
                tabla.addCell(reporte.celda(cuentas[i].getMed(), font, contenido, izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda(cuentas[i].getDescripcionFactura().toUpperCase(), font, contenido,
                        izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda("" + formatoPorcentaje.format(cuentas[i].getPrecioFactura()), font,
                        contenido, derecha, 0, 1, 12));
                double tot = cuentas[i].getPrecioFactura() * cuentas[i].getCantidadFactura();
                total += tot;
                tabla.addCell(
                        reporte.celda("" + formatoPorcentaje.format(tot), font, contenido, derecha, 0, 1, 12));
                /*if(ren==30)
                {
                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda(">> continua en la siguente hoja <<", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                reporte.agregaObjeto(tabla);
                reporte.writer.newPage();
                tabla=reporte.crearTabla(5, tam, 100, Element.ALIGN_LEFT);
                this.cabeceraPre(reporte, bf, tabla);
                ren=-1;
                }
                ren++;*/
            }
        }
        if (enlazadas.length > 0) {
            for (int i = 0; i < enlazadas.length; i++) {
                tabla.addCell(reporte.celda("" + enlazadas[i].getCantidadFactura(), font, contenido, derecha, 0,
                        1, 12));
                tabla.addCell(reporte.celda(enlazadas[i].getMed(), font, contenido, izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda(enlazadas[i].getDescripcionFactura().toUpperCase(), font, contenido,
                        izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda("" + formatoPorcentaje.format(enlazadas[i].getPrecioFactura()),
                        font, contenido, derecha, 0, 1, 12));
                double tot = enlazadas[i].getPrecioFactura() * enlazadas[i].getCantidadFactura();
                total += tot;
                tabla.addCell(
                        reporte.celda("" + formatoPorcentaje.format(tot), font, contenido, derecha, 0, 1, 12));
                /*if(ren==30)
                {
                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda(">> continua en la siguente hoja <<", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                reporte.agregaObjeto(tabla);
                reporte.writer.newPage();
                tabla=reporte.crearTabla(17, tam, 100, Element.ALIGN_LEFT);
                this.cabeceraPre(reporte, bf, tabla);
                ren=-1;
                }
                ren++;*/
            }
        }
        if (externas.length > 0) {
            for (int ex = 0; ex < externas.length; ex++) {
                tabla.addCell(
                        reporte.celda("" + externas[ex].getCantidad(), font, contenido, derecha, 0, 1, 12));
                tabla.addCell(reporte.celda(externas[ex].getMedida(), font, contenido, izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda(externas[ex].getDescripcion().toUpperCase(), font, contenido,
                        izquierda, 0, 1, 12));
                tabla.addCell(reporte.celda("" + formatoPorcentaje.format(externas[ex].getPrecio()), font,
                        contenido, derecha, 0, 1, 12));
                double tot = externas[ex].getPrecio() * externas[ex].getCantidad();
                total += tot;
                tabla.addCell(
                        reporte.celda("" + formatoPorcentaje.format(tot), font, contenido, derecha, 0, 1, 12));
                /*if(ren==30)
                {
                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda(">> continua en la siguente hoja <<", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                tabla.addCell(reporte.celda("", font, contenido, derecha, 0,1,12));
                reporte.agregaObjeto(tabla);
                reporte.writer.newPage();
                tabla=reporte.crearTabla(17, tam, 100, Element.ALIGN_LEFT);
                this.cabeceraPre(reporte, bf, tabla);
                ren=-1;
                }
                ren++;*/
            }
        }
        PdfPTable tabla1 = reporte.crearTabla(5, tam, 100, Element.ALIGN_LEFT);
        tabla1.addCell(reporte.celda("Metodo de Pago: NO IDENTIFICADO", font, contenido, izquierda, 3, 1,
                Rectangle.TOP));
        tabla1.addCell(reporte.celda("SUB-TOTAL:", font, contenido, derecha, 0, 1,
                Rectangle.TOP + Rectangle.BOTTOM + 12));
        tabla1.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.TOP + Rectangle.BOTTOM + 12));
        tabla1.addCell(
                reporte.celda("Lugar de Expedicin: ", font, contenido, izquierda, 3, 1, Rectangle.NO_BORDER));
        tabla1.addCell(reporte.celda("IVA:", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);
        double iva = total * (con.getIva() * 0.01);
        tabla1.addCell(reporte.celda(formatoPorcentaje.format(iva), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla1.addCell(
                reporte.celda("(CANTIDAD CON LETRA)", font, contenido, izquierda, 3, 2, Rectangle.NO_BORDER));
        tabla1.addCell(reporte.celda("DEDUCIBLE:", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
        tabla1.addCell(reporte.celda("$0.00", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
        tabla1.addCell(reporte.celda("TOTAL:", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
        total += iva;
        tabla1.addCell(reporte.celda(formatoPorcentaje.format(total), font, contenido, derecha, 0, 1,
                Rectangle.RECTANGLE));
        tabla1.addCell(reporte.celda("PAGO EN UNA SOLA EXHIBICIN", font, contenido, izquierda, 3, 1,
                Rectangle.NO_BORDER));
        tabla1.addCell(
                reporte.celda("EFECTOS FISCALES AL PAGO", font, contenido, centro, 2, 1, Rectangle.NO_BORDER));
        session.beginTransaction().rollback();

        tabla.setHeaderRows(2);
        reporte.agregaObjeto(tabla);
        float tam1[] = new float[] { 180, 180, 180, 180 };
        PdfPTable tabla2 = reporte.crearTabla(4, tam1, 100, Element.ALIGN_LEFT);
        tabla2.addCell(
                reporte.celda(reporte.Imagen("imagenes/rq.png"), contenido, centro, 0, 8, Rectangle.NO_BORDER));
        tabla2.addCell(reporte.celda("Regimen Fiscal:REGIMEN GENERAL DE LEY DE PERSONAS MORALES", font,
                contenido, centro, 3, 1, Rectangle.BOTTOM));
        tabla2.addCell(reporte.celda("Sello Digital del SAT:", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda(" ", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda("Sello Digital del Emisor:", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda(" ", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda("Cadena original del complemento de certificacin digital del SAT:", font,
                contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda(" ", font, contenido, izquierda, 3, 1, 12));
        tabla2.addCell(reporte.celda("Este documento es una representacin impresa de un CFDI", font,
                contenido, izquierda, 3, 1, Rectangle.TOP));

        reporte.agregaObjeto(tabla1);
        reporte.agregaObjeto(tabla2);
        reporte.cerrar();
        reporte.visualizar("reportes/" + ord.getIdOrden() + "/" + valor + "-preFac.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
}