Example usage for com.lowagie.text.pdf PdfPCell setMinimumHeight

List of usage examples for com.lowagie.text.pdf PdfPCell setMinimumHeight

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPCell setMinimumHeight.

Prototype

public void setMinimumHeight(float minimumHeight) 

Source Link

Document

Set a minimum height for the cell.

Usage

From source file:org.revager.export.PDFPageEventHelper.java

License:Open Source License

@Override
public void onEndPage(PdfWriter writer, Document document) {
    int columnNumber;

    try {/* ww w  . j  a va  2s .com*/
        Rectangle page = document.getPageSize();
        float pageWidth = page.getWidth() - document.leftMargin() - document.rightMargin();

        /*
         * Write marks
         */
        setMarks(writer, document);

        /*
         * Define fonts
         */
        headBaseFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
        Font headFont = new Font(headBaseFont, headFontSize);

        footBaseFont = BaseFont.createFont(BaseFont.HELVETICA_OBLIQUE, BaseFont.CP1252, BaseFont.EMBEDDED);
        Font footFont = new Font(footBaseFont, footFontSize);

        /*
         * Cell fill for space between head/foot and content
         */
        PdfPCell cellFill = new PdfPCell();
        cellFill.setMinimumHeight(PDFTools.cmToPt(0.8f));
        cellFill.setBorderWidth(0);

        /*
         * Write head
         */
        if (headLogoPath != null) {
            columnNumber = 2;
        } else {
            columnNumber = 1;
        }

        PdfPTable head = new PdfPTable(columnNumber);

        Phrase phraseTitle = new Phrase(headTitle, headFont);

        PdfPCell cellTitle = new PdfPCell(phraseTitle);
        cellTitle.setHorizontalAlignment(Element.ALIGN_LEFT);
        cellTitle.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cellTitle.setPaddingTop(0);
        cellTitle.setPaddingBottom(PDFTools.cmToPt(0.2f));
        cellTitle.setPaddingLeft(0);
        cellTitle.setPaddingRight(0);
        cellTitle.setBorderWidthTop(0);
        cellTitle.setBorderWidthBottom(0.5f);
        cellTitle.setBorderWidthLeft(0);
        cellTitle.setBorderWidthRight(0);

        head.addCell(cellTitle);

        if (headLogoPath != null) {
            Image headLogo = Image.getInstance(headLogoPath);
            headLogo.scaleToFit(PDFTools.cmToPt(5.0f), PDFTools.cmToPt(1.1f));

            PdfPCell cellLogo = new PdfPCell(headLogo);
            cellLogo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellLogo.setVerticalAlignment(Element.ALIGN_BOTTOM);
            cellLogo.setPaddingTop(0);
            cellLogo.setPaddingBottom(PDFTools.cmToPt(0.15f));
            cellLogo.setPaddingLeft(0);
            cellLogo.setPaddingRight(0);
            cellLogo.setBorderWidthTop(0);
            cellLogo.setBorderWidthBottom(0.5f);
            cellLogo.setBorderWidthLeft(0);
            cellLogo.setBorderWidthRight(0);

            head.addCell(cellLogo);

            head.addCell(cellFill);
        }

        head.addCell(cellFill);

        head.setTotalWidth(pageWidth);
        head.writeSelectedRows(0, -1, document.leftMargin(),
                page.getHeight() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());

        /*
         * Write foot
         */
        if (footText == null) {
            footText = " ";
        }

        PdfPTable foot = new PdfPTable(1);

        foot.addCell(cellFill);

        PdfPCell cellFootText = new PdfPCell(new Phrase(footText, footFont));
        cellFootText.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellFootText.setVerticalAlignment(Element.ALIGN_TOP);
        cellFootText.setPaddingTop(PDFTools.cmToPt(0.15f));
        cellFootText.setPaddingBottom(0);
        cellFootText.setPaddingLeft(0);
        cellFootText.setPaddingRight(0);
        cellFootText.setBorderWidthTop(0.5f);
        cellFootText.setBorderWidthBottom(0);
        cellFootText.setBorderWidthLeft(0);
        cellFootText.setBorderWidthRight(0);

        foot.addCell(cellFootText);

        /*
         * Print page numbers
         */
        PdfContentByte contentByte = writer.getDirectContent();
        contentByte.saveState();

        String text = MessageFormat.format(translate("Page {0} of") + " ", writer.getPageNumber());

        float textSize = footBaseFont.getWidthPoint(text, footFontSize);
        float textBase = document.bottom() - PDFTools.cmToPt(1.26f);
        contentByte.beginText();
        contentByte.setFontAndSize(footBaseFont, footFontSize);

        float adjust;
        if (footText.trim().equals("")) {
            adjust = (pageWidth / 2) - (textSize / 2) - footBaseFont.getWidthPoint("0", footFontSize);
        } else {
            adjust = 0;
        }

        contentByte.setTextMatrix(document.left() + adjust, textBase);
        contentByte.showText(text);
        contentByte.endText();
        contentByte.addTemplate(template, document.left() + adjust + textSize, textBase);

        contentByte.stroke();
        contentByte.restoreState();

        foot.setTotalWidth(pageWidth);
        foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
                writer.getDirectContent());
    } catch (Exception e) {
        /*
         * Not part of unit testing because this exception is only thrown if
         * an internal error occurs.
         */
        throw new ExceptionConverter(e);
    }
}

From source file:org.unitime.timetable.webutil.timegrid.PdfTimetableGridTable.java

License:Open Source License

public void printToPdf(TimetableGridModel model, int rowNumber) throws Exception {
    model.clearRendered();//from  w  w w .ja va  2 s.  c o m

    if (iTable.isDispModePerWeek()) {
        createTable();
        printHeader(model, 0);
    } else {
        if (rowNumber == 0) {
            createTable();
            printHeader(model, 0);
        }
    }

    if (iTable.isDispModeInRow()) {
        int maxIdx = model.getMaxIdxForDay(iDay, iTable.firstSlot(), iTable.lastSlot());
        for (int idx = 0; idx <= maxIdx; idx++) {
            PdfPCell c = createCell();
            c.setBorderWidthTop(0);
            if (idx == 0)
                addText(c, model.getName() + (model.getSize() > 0 ? " (" + model.getSize() + ")" : ""), true);
            c.setBorderWidthBottom(idx == maxIdx ? 1 : 0);
            c.setColspan(12);
            iPdfTable.addCell(c);
            for (int slot = iTable.firstSlot(); slot <= iTable.lastSlot(); slot++) {
                int slotsToEnd = iTable.lastSlot() - slot + 1;
                TimetableGridCell cell = model.getCell(iDay, slot, idx);
                int length = (cell == null ? 1 : cell.getLength() + cell.getSlot() - slot);
                int colSpan = (cell == null ? 1 : Math.min(length, slotsToEnd));
                if (cell == null) {
                    String bgColor = model.getBackground(iDay, slot);
                    if (bgColor == null && !model.isAvailable(iDay, slot))
                        bgColor = TimetableGridCell.sBgColorNotAvailable;
                    c = createCell();
                    c.setBorderWidthTop(0);
                    c.setBorderWidthBottom(
                            idx == maxIdx ? 1 : model.getCell(iDay, slot, idx + 1) != null ? 1 : 0);
                    c.setBorderWidthLeft(0);
                    boolean eod = (slot == iTable.lastSlot());
                    boolean in = !eod && model.getCell(iDay, slot + 1, idx) == null
                            && ((slot + 1 - iTable.firstSlot()) % iTable.nrSlotsPerPeriod()) != 0;
                    c.setBorderWidthRight(eod || !in ? 1 : 0);
                    c.setColspan(colSpan);
                    if (bgColor != null)
                        c.setBackgroundColor(getColor(bgColor));
                    iPdfTable.addCell(c);
                } else {
                    String bgColor = cell.getBackground();
                    if (iTable.getBgMode() == TimetableGridModel.sBgModeNone) {
                        for (int i = 0; i < length; i++)
                            if (!model.isAvailable(iDay, slot + i)) {
                                bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned;
                                break;
                            }
                    }
                    c = createCell();
                    c.setBorderWidthTop(0);
                    c.setBorderWidthLeft(0);
                    c.setColspan(colSpan);
                    c.setBackgroundColor(getColor(bgColor));
                    addText(c, cell.getName());
                    if (iTable.getShowTimes())
                        addText(c, cell.getTime());
                    if (iTable.getResourceType() != TimetableGridModel.sResourceTypeRoom)
                        addText(c, cell.getRoomName());
                    if (iTable.getResourceType() != TimetableGridModel.sResourceTypeInstructor
                            && iTable.getShowInstructors() && !cell.getInstructor().isEmpty())
                        addText(c, cell.getInstructor());
                    if (iTable.getShowComments())
                        addText(c,
                                cell.getShortCommentNoColors() == null ? null : cell.getShortCommentNoColors());
                    if (iTable.getWeek() == -100 && cell.hasDays()
                            && !cell.getDays().equals(iTable.getDefaultDatePatternName()))
                        addText(c, cell.getDays());
                    iPdfTable.addCell(c);
                    slot += length - 1;
                }
            }
        }
    } else if (iTable.isDispModePerWeekHorizontal()) {
        for (int day = iTable.startDay(); day <= iTable.endDay(); day++) {
            int maxIdx = model.getMaxIdxForDay(day, iTable.firstSlot(), iTable.lastSlot());
            for (int idx = 0; idx <= maxIdx; idx++) {
                PdfPCell c = createCell();
                c.setBorderWidthTop(0);
                if (idx == 0)
                    addText(c, Constants.DAY_NAME[day], true);
                c.setBorderWidthBottom(idx == maxIdx ? 1 : 0);
                c.setColspan(12);
                iPdfTable.addCell(c);
                for (int slot = iTable.firstSlot(); slot <= iTable.lastSlot(); slot++) {
                    int slotsToEnd = iTable.lastSlot() - slot + 1;
                    TimetableGridCell cell = model.getCell(day, slot, idx);
                    int length = (cell == null ? 1 : cell.getLength() + cell.getSlot() - slot);
                    int colSpan = (cell == null ? 1 : Math.min(length, slotsToEnd));
                    if (cell == null) {
                        String bgColor = model.getBackground(day, slot);
                        if (bgColor == null && !model.isAvailable(day, slot))
                            bgColor = TimetableGridCell.sBgColorNotAvailable;
                        c = createCell();
                        c.setBorderWidthTop(0);
                        c.setBorderWidthBottom(
                                idx == maxIdx ? 1 : model.getCell(day, slot, idx + 1) != null ? 1 : 0);
                        c.setBorderWidthLeft(0);
                        boolean eod = (slot == iTable.lastSlot());
                        boolean in = !eod && model.getCell(day, slot + 1, idx) == null
                                && ((slot + 1 - iTable.firstSlot()) % iTable.nrSlotsPerPeriod()) != 0;
                        c.setBorderWidthRight(eod || !in ? 1 : 0);
                        iPdfTable.addCell(c);
                    } else {
                        String bgColor = cell.getBackground();
                        if (iTable.getBgMode() == TimetableGridModel.sBgModeNone) {
                            for (int i = 0; i < length; i++)
                                if (!model.isAvailable(day, slot + i)) {
                                    bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned;
                                    break;
                                }
                        }
                        c = createCell();
                        c.setBorderWidthTop(0);
                        c.setBorderWidthLeft(0);
                        c.setColspan(colSpan);
                        if (bgColor != null)
                            c.setBackgroundColor(getColor(bgColor));
                        addText(c, cell.getName());
                        if (iTable.getShowTimes())
                            addText(c, cell.getTime());
                        if (iTable.getResourceType() != TimetableGridModel.sResourceTypeRoom)
                            addText(c, cell.getRoomName());
                        if (iTable.getResourceType() != TimetableGridModel.sResourceTypeInstructor
                                && iTable.getShowInstructors() && !cell.getInstructor().isEmpty())
                            addText(c, cell.getInstructor());
                        if (iTable.getShowComments())
                            addText(c, cell.getShortCommentNoColors() == null ? null
                                    : cell.getShortCommentNoColors());
                        if (iTable.getWeek() == -100 && cell.hasDays()
                                && !cell.getDays().equals(iTable.getDefaultDatePatternName()))
                            addText(c, cell.getDays());
                        iPdfTable.addCell(c);
                        slot += length - 1;
                    }
                }
            }
        }
    } else if (iTable.isDispModeWeekByWeekHorizontal()) {
        Calendar cal = Calendar.getInstance(Locale.US);
        cal.setTime(iTable.iFirstDate);
        for (int d = 0; d < 365; d++) {
            if (d > 0)
                cal.add(Calendar.DAY_OF_YEAR, 1);
            int date = d + iTable.iFirstDay;
            if (model.getFirstDay() >= 0 && (date < model.getFirstDay() || date > model.getFirstDay() + 6))
                continue;
            int day = d % 7;
            if (day < iTable.startDay() || day > iTable.endDay())
                continue;
            boolean hasClasses = false;
            for (int slot = iTable.firstSlot(); slot <= iTable.lastSlot(); slot++) {
                if (model.getCell(day, slot, 0, date) != null) {
                    hasClasses = true;
                    break;
                }
            }
            if (!hasClasses)
                continue;
            int maxIdx = model.getMaxIdxForDay(day, iTable.firstSlot(), iTable.lastSlot(), date);
            for (int idx = 0; idx <= maxIdx; idx++) {
                PdfPCell c = createCell();
                c.setBorderWidthTop(0);
                if (idx == 0)
                    addText(c, Constants.DAY_NAME[day] + " " + sDF.format(cal.getTime()), true);
                c.setBorderWidthBottom(idx == maxIdx ? 1 : 0);
                c.setColspan(12);
                iPdfTable.addCell(c);
                for (int slot = iTable.firstSlot(); slot <= iTable.lastSlot(); slot++) {
                    int slotsToEnd = iTable.lastSlot() - slot + 1;
                    TimetableGridCell cell = model.getCell(day, slot, idx, date);
                    int length = (cell == null ? 1 : cell.getLength() + cell.getSlot() - slot);
                    int colSpan = (cell == null ? 1 : Math.min(length, slotsToEnd));
                    if (cell == null) {
                        String bgColor = model.getBackground(day, slot);
                        if (bgColor == null && !model.isAvailable(day, slot))
                            bgColor = TimetableGridCell.sBgColorNotAvailable;
                        c = createCell();
                        c.setBorderWidthTop(0);
                        c.setBorderWidthBottom(
                                idx == maxIdx ? 1 : model.getCell(day, slot, idx + 1, date) != null ? 1 : 0);
                        c.setBorderWidthLeft(0);
                        boolean eod = (slot == iTable.lastSlot());
                        boolean in = !eod && model.getCell(day, slot + 1, idx, date) == null
                                && ((slot + 1 - iTable.firstSlot()) % iTable.nrSlotsPerPeriod()) != 0;
                        c.setBorderWidthRight(eod || !in ? 1 : 0);
                        iPdfTable.addCell(c);
                    } else {
                        String bgColor = cell.getBackground();
                        if (iTable.getBgMode() == TimetableGridModel.sBgModeNone) {
                            for (int i = 0; i < length; i++)
                                if (!model.isAvailable(day, slot + i)) {
                                    bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned;
                                    break;
                                }
                        }
                        c = createCell();
                        c.setBorderWidthTop(0);
                        c.setBorderWidthLeft(0);
                        c.setColspan(colSpan);
                        if (bgColor != null)
                            c.setBackgroundColor(getColor(bgColor));
                        addText(c, cell.getName());
                        if (iTable.getShowTimes())
                            addText(c, cell.getTime());
                        if (iTable.getResourceType() != TimetableGridModel.sResourceTypeRoom)
                            addText(c, cell.getRoomName());
                        if (iTable.getResourceType() != TimetableGridModel.sResourceTypeInstructor
                                && iTable.getShowInstructors() && !cell.getInstructor().isEmpty())
                            addText(c, cell.getInstructor());
                        if (iTable.getShowComments())
                            addText(c, cell.getShortCommentNoColors() == null ? null
                                    : cell.getShortCommentNoColors());
                        iPdfTable.addCell(c);
                        slot += length - 1;
                    }
                }
            }
        }
    } else { //isDispModePerWeekVertical
        for (int day = iTable.startDay(); day <= iTable.endDay(); day++) {
            int maxIdx = model.getMaxIdxForDay(day, iTable.firstSlot(), iTable.lastSlot());
            for (int idx = 0; idx <= maxIdx; idx++) {
                PdfPCell c = null;
                for (int slot = iTable.lastSlot(); slot >= iTable.firstSlot(); slot--) {
                    int slotsToEnd = slot + 1 - iTable.firstSlot();
                    TimetableGridCell cell = model.getCell(day, slot, idx);
                    int length = (cell == null ? 1 : 1 + slot - cell.getSlot());
                    int colSpan = (cell == null ? 1 : Math.min(length, slotsToEnd));
                    if (cell == null) {
                        String bgColor = model.getBackground(day, slot);
                        if (bgColor == null && !model.isAvailable(day, slot))
                            bgColor = TimetableGridCell.sBgColorNotAvailable;
                        c = createCell();
                        c.setBorderWidthTop(0);
                        c.setMinimumHeight(100f);
                        c.setBorderWidthBottom(
                                idx == maxIdx ? 1 : model.getCell(day, slot, idx + 1) != null ? 1 : 0);
                        c.setBorderWidthLeft(slot == iTable.lastSlot() ? 1 : 0);
                        boolean eod = (slot == iTable.firstSlot());
                        boolean in = !eod && model.getCell(day, slot - 1, idx) == null
                                && ((slot - iTable.firstSlot()) % iTable.nrSlotsPerPeriod()) != 0;
                        c.setBorderWidthRight(eod || !in ? 1 : 0);
                        iPdfTable.addCell(c);
                    } else {
                        String bgColor = cell.getBackground();
                        if (iTable.getBgMode() == TimetableGridModel.sBgModeNone) {
                            for (int i = 0; i < length; i++)
                                if (!model.isAvailable(day, slot - i)) {
                                    bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned;
                                    break;
                                }
                        }
                        c = createCell();
                        c.setBorderWidthTop(0);
                        c.setBorderWidthLeft(slot == iTable.lastSlot() ? 1 : 0);
                        c.setColspan(colSpan);
                        if (bgColor != null)
                            c.setBackgroundColor(getColor(bgColor));
                        if (iTable.getWeek() == -100 && cell.hasDays()
                                && !cell.getDays().equals(iTable.getDefaultDatePatternName()))
                            addTextVertical(c, cell.getDays());
                        if (iTable.getShowTimes())
                            addText(c, cell.getTime());
                        if (iTable.getResourceType() != TimetableGridModel.sResourceTypeRoom)
                            addTextVertical(c, cell.getRoomName());
                        if (iTable.getResourceType() != TimetableGridModel.sResourceTypeInstructor
                                && iTable.getShowInstructors() && !cell.getInstructor().isEmpty())
                            addTextVertical(c, cell.getInstructor());
                        if (iTable.getShowComments())
                            addTextVertical(c, cell.getShortCommentNoColors() == null ? null
                                    : cell.getShortCommentNoColors());
                        addTextVertical(c, cell.getName());
                        iPdfTable.addCell(c);
                        slot -= length - 1;
                    }
                }
                c = createCell();
                c.setBorderWidthTop(0);
                c.setBorderWidthLeft(0);
                if (idx == 0)
                    addTextVertical(c, Constants.DAY_NAME[day], true);
                c.setBorderWidthBottom(idx == maxIdx ? 1 : 0);
                c.setColspan(12);
                iPdfTable.addCell(c);
            }
        }
        /*
        int step = iTable.nrSlotsPerPeriod();
        for (int slot=iTable.firstSlot();slot<=iTable.lastSlot();slot+=step) {
           int time = slot * Constants.SLOT_LENGTH_MIN + Constants.FIRST_SLOT_TIME_MIN;
        int slotsToEnd = iTable.lastSlot()-slot+1;
        if ((slot%iTable.nrSlotsPerPeriod()) == 0) {
        c = createCell("TimetableHeadCell"+(slot==iTable.firstSlot()?"":"In")+"Vertical");
        addText(c, Constants.toTime(time), true);
        iPdfTable.addCell(c);
        } else {
           c = createCell("TimetableHeadCellInVertical");
           iPdfTable.addCell(c);
        }
        for (int day=iTable.startDay();day<=iTable.endDay();day++) {
           int maxIdx = model.getMaxIdxForDay(day,iTable.firstSlot(),iTable.lastSlot());
           for (int idx=0;idx<=maxIdx;idx++) {
               TimetableGridCell cell = model.getCell(day,slot, idx);
               if (model.isRendered(day,slot,idx)) continue;
          int rowSpan = (cell==null?1:Math.min(cell.getLength()+cell.getSlot()-slot,slotsToEnd));
          int colSpan = (iTable.getResourceType()==TimetableGridModel.sResourceTypeDepartment && cell!=null?1:model.getDepth(day,slot,idx,maxIdx,rowSpan)); 
          model.setRendered(day,slot,idx,colSpan,rowSpan);
          int rowSpanDivStep = (int)Math.ceil(((double)rowSpan)/step);
                       
               if (cell==null) {
             String bgColor = model.getBackground(day,slot);
             if (bgColor==null && !model.isAvailable(day,slot))
                bgColor=TimetableGridCell.sBgColorNotAvailable;
                    boolean eol = (day==iTable.endDay() && (idx+colSpan-1)==maxIdx);
             c = createCell("TimetableCell"+(slot==iTable.firstSlot()?"":"In")+"Vertical"+(eol?"EOL":""));
             c.setColspan(colSpan);
             //c.setRowspan(rowSpanDivStep);
             if (bgColor!=null)
                c.setBackgroundColor(getColor(bgColor));
             iPdfTable.addCell(c);
               } else {
                  String bgColor = cell.getBackground();
                  if (iTable.getBgMode()==TimetableGridModel.sBgModeNone) {
                      for (int i=0;i<cell.getLength();i++)
                         if (!model.isAvailable(day,slot+i)) {
                            bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned;
                            break;
                         }
                  }
                  boolean eol = (day==iTable.endDay());
                  c = createCell("TimetableCell"+(slot==iTable.firstSlot()?"":"In")+"Vertical" + (eol?"EOL":""));
             c.setColspan(colSpan);
             //c.setRowspan(rowSpanDivStep);
             if (bgColor!=null)
                c.setBackgroundColor(getColor(bgColor));
             addText(c, cell.getName());
             if (iTable.getResourceType()!=TimetableGridModel.sResourceTypeRoom)
                addText(c, cell.getRoomName());
             if (iTable.getShowComments())
                addText(c, cell.getShortComment()==null?"":cell.getShortComment());
             if (iTable.getWeek()==-100 && cell.hasDays() && !cell.getDays().equals(iTable.getDefaultDatePatternName()))
                addText(c, cell.getDays());
             iPdfTable.addCell(c);
               }
            }
        }
        }
        */
    }

    if (iTable.isDispModePerWeek()) {
        flushTable();
    }
}

From source file:recite18th.controller.Controller.java

License:Open Source License

public void print(String action) {
    /** thanks to http://www.java2s.com/Code/Java/PDF-RTF/DemonstratesthecreatingPDFinportraitlandscape.htm
     * QUICK FIX : do landscape//from w  ww. j  a  v a 2s  .co  m
     */
    response.setContentType("application/pdf"); // Code 1
    if (action.equals("download")) {
        response.setHeader("Content-Transfer-Encoding", "binary");
        response.setHeader("Content-Disposition",
                "attachment; filename=\"" + "Report " + controllerName + ".pdf\"");
    }
    Document document = new Document(PageSize.A1.rotate());
    try {
        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // Code 2
        document.open();

        // various fonts
        BaseFont bf_helv = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false);
        BaseFont bf_times = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", false);
        BaseFont bf_courier = BaseFont.createFont(BaseFont.COURIER, "Cp1252", false);
        BaseFont bf_symbol = BaseFont.createFont(BaseFont.SYMBOL, "Cp1252", false);

        String headerImage = Config.base_path + "images/report-logo.gif";

        Image imghead = Image.getInstance(headerImage);
        imghead.setAbsolutePosition(0, 0);
        PdfContentByte cbhead = writer.getDirectContent();
        PdfTemplate tpLogo = cbhead.createTemplate(600, 300);
        tpLogo.addImage(imghead);

        PdfTemplate tpTitle = cbhead.createTemplate(1100, 300);
        String txtHeader = "BADAN KEPEGAWAIAN DAERAH PEMERINTAH DAERAH";//Config.application_title;
        tpTitle.beginText();
        tpTitle.setFontAndSize(bf_times, 36);
        tpTitle.showText(txtHeader);
        tpTitle.endText();

        PdfTemplate tpTitle2 = cbhead.createTemplate(900, 300);
        String txtHeader2 = "         KABUPATEN BANTUL YOGYAKARTA";
        tpTitle2.beginText();
        tpTitle2.setFontAndSize(bf_times, 36);
        tpTitle2.showText(txtHeader2);
        tpTitle2.endText();

        PdfTemplate tpAlamat = cbhead.createTemplate(1000, 400);
        tpAlamat.beginText();
        tpAlamat.setFontAndSize(bf_times, 24);
        tpAlamat.showText(
                "Alamat : Jln. R. W. Monginsidi No. 01 Kompleks Parasamya Bantul, Telp. (0274) 367509");
        tpAlamat.endText();

        DateFormat df = new SimpleDateFormat("dd MMM yyyy");
        java.util.Date dt = new java.util.Date();
        PdfTemplate tp3 = cbhead.createTemplate(600, 300);
        tp3.beginText();
        tp3.setFontAndSize(bf_times, 16);

        tp3.showText("Tanggal : " + df.format(dt));
        tp3.endText();

        cbhead.addTemplate(tpLogo, 800, 1500);//logo
        cbhead.addTemplate(tpTitle, 1000, 1580);
        cbhead.addTemplate(tpTitle2, 1000, 1540);
        cbhead.addTemplate(tpAlamat, 1000, 1500);//alamat
        cbhead.addTemplate(tp3, 270, 1500);//tanggal

        HeaderFooter header = new HeaderFooter(new Phrase(cbhead + "", new Font(bf_helv)), false);
        header.setAlignment(Element.ALIGN_CENTER);

        document.setHeader(header);

        //PdfContentByte cb = writer.getDirectContent();
        Paragraph par = new Paragraph(
                "\n\n\n\n\n\n\nLAPORAN DATA SELURUH " + controllerName.toUpperCase() + "\n");
        par.getFont().setStyle(Font.BOLD);
        par.getFont().setSize(18);
        par.setAlignment("center");
        document.add(par);
        document.add(new Paragraph("\n\n"));

        // get data
        initSqlViewDataPerPage();
        if (sqlViewDataPerPageForReport == null) {
            sqlViewDataPerPageForReport = sqlViewDataPerPage;
        }
        PreparedStatement pstmt = Db.getCon().prepareStatement(sqlViewDataPerPageForReport,
                ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = pstmt.executeQuery();
        ResultSetMetaData metaColumn = resultSet.getMetaData();
        int nColoumn = metaColumn.getColumnCount();
        // thanks to set cell width http://www.jexp.ru/index.php/Java/PDF_RTF/Table_Cell_Size#Setting_Cell_Widths
        if (nColoumn > 0) {
            Model model = initModel();
            String tableName = model.getTableName();
            // create table header
            //     float[] widths = {1, 4};
            PdfPTable table;// = new PdfPTable(nColoumn);
            PdfPCell cell = new PdfPCell(new Paragraph("Daftar " + controllerName));

            Hashtable hashModel = TableCustomization.getTable(model.getTableName());

            int ncolumnHeader = nColoumn + 1; // +1 because of row. number
            if (hashModel != null) {
                ncolumnHeader = Integer.parseInt("" + hashModel.get("columnCount")) + 1;
            }
            table = new PdfPTable(ncolumnHeader);
            cell.setColspan(ncolumnHeader);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);

            Paragraph p2 = new Paragraph("No.");
            p2.getFont().setSize(20);
            PdfPCell cellColNo = new PdfPCell(p2);
            cellColNo.setNoWrap(true);
            cellColNo.setMinimumHeight(50);
            cellColNo.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cellColNo);

            if (hashModel != null) {
                Enumeration k = hashModel.keys();
                while (k.hasMoreElements()) {
                    String key = (String) k.nextElement();
                    if (key.equals("columnCount")) {
                        continue;
                    }
                    PdfPCell cellCol = new PdfPCell(new Paragraph(hashModel.get(key) + ""));
                    cellCol.setNoWrap(true);
                    cellCol.setMinimumHeight(50);
                    cellCol.setHorizontalAlignment(Element.ALIGN_CENTER);

                    table.addCell(cellCol);
                }
            } else {
                for (int i = 1; i < ncolumnHeader; i++) {
                    System.out.println("DATA = " + metaColumn.getColumnName(i));
                    Paragraph p1 = new Paragraph(metaColumn.getColumnName(i) + "");
                    p1.getFont().setSize(20);
                    PdfPCell cellCol = new PdfPCell(p1);
                    cellCol.setHorizontalAlignment(Element.ALIGN_CENTER);
                    table.addCell(cellCol);
                }
            }

            //iterate all columns : table data
            resultSet.beforeFirst();
            int row = 1;
            while (resultSet.next()) {
                System.out.println(row);
                Paragraph p3 = new Paragraph(row + "");
                p3.getFont().setSize(20);
                cell = new PdfPCell(p3);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell);
                if (hashModel != null) {//skip dulu u/ kasus ga pny class kustomasi table
                    Enumeration k = hashModel.keys();
                    while (k.hasMoreElements()) {
                        String key = (String) k.nextElement();
                        if (key.equals("columnCount")) {
                            continue;
                        }
                        table.addCell(resultSet.getObject(key) + "");
                    }
                } else {
                    for (int i = 1; i < ncolumnHeader; i++) {
                        System.out.println("DATA = " + metaColumn.getColumnName(i));
                        Paragraph p1 = new Paragraph(resultSet.getObject(metaColumn.getColumnName(i)) + "");
                        p1.getFont().setSize(18);
                        PdfPCell cellCol = new PdfPCell(p1);
                        cellCol.setHorizontalAlignment(Element.ALIGN_CENTER);
                        table.addCell(cellCol);
                    }
                }

                row++;
            }

            document.add(table);
            document.add(new Paragraph("\n\n"));
            par = new Paragraph("Mengetahui");
            par.setAlignment("center");
            document.add(par);
            par = new Paragraph("Kepada Badan Kepegawaian");
            par.setAlignment("center");
            document.add(par);
            par = new Paragraph("\n\n\n");

            document.add(par);
            par = new Paragraph("Drs. Maman Permana");
            par.setAlignment("center");
            document.add(par);
            par = new Paragraph("Nip: 197802042006041013");
            par.setAlignment("center");

            document.add(par);

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

From source file:uk.ac.ox.oucs.vle.resources.PDFWriter.java

License:Educational Community License

private PdfPCell headCell(String name, Font font) {

    PdfPCell pdfCell = new PdfPCell(new Phrase(name, font));
    pdfCell.setMinimumHeight(font.getSize() * 2f);
    pdfCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    pdfCell.setVerticalAlignment(Element.ALIGN_CENTER);
    pdfCell.setPaddingBottom(font.getSize() * 0.5f);
    pdfCell.setPaddingTop(font.getSize() * 0.5f);
    pdfCell.setPaddingLeft(font.getSize());
    pdfCell.setPaddingRight(font.getSize());
    return pdfCell;
}

From source file:uk.ac.ox.oucs.vle.resources.PDFWriter.java

License:Educational Community License

private PdfPCell nameCell(String name, String webauthId, String department) {

    Phrase phrase = new Phrase();
    phrase.add(new Chunk(name, tableNameFont));
    phrase.add(Chunk.NEWLINE);//from www.j  a  v  a 2s  .  c  o m
    StringBuilder otherDetails = new StringBuilder();
    if (webauthId != null && webauthId.trim().length() > 0) {
        otherDetails.append(webauthId);
    }
    if (department != null && department.trim().length() > 0) {
        if (otherDetails.length() > 0) {
            otherDetails.append(" ");
        }
        otherDetails.append(department);
    }
    phrase.add(new Chunk(otherDetails.toString(), tableOtherFont));

    PdfPCell pdfCell = new PdfPCell(phrase);
    pdfCell.setMinimumHeight(tableNameFont.getSize() * 2f);
    pdfCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    pdfCell.setVerticalAlignment(Element.ALIGN_CENTER);
    pdfCell.setPaddingBottom(tableNameFont.getSize() * 0.5f);
    pdfCell.setPaddingTop(tableNameFont.getSize() * 0.5f);
    pdfCell.setPaddingLeft(tableNameFont.getSize());
    pdfCell.setPaddingRight(tableNameFont.getSize());
    return pdfCell;
}

From source file:vistas.reportes.procesos.rptAsistenciaTotal.java

public PdfPTable crearTabla(List<String> dnis, Date fechaInicio, Date fechaFin, boolean isSelectedComp,
        boolean isSelectedHoraM, String tipo) throws DocumentException {
    /**/*w w  w  .  j a  v  a  2 s. co  m*/
     * Procesamiento para info para generar tablas
     */
    /**
     * Procesamiento para elaborar tabla con datos
     */
    int nroColumnas;
    if (isSelectedComp) {
        nroColumnas = 9;
    } else {
        nroColumnas = 8;
    }
    if (tipo == "P") {
        nroColumnas -= 2;
    }
    //int nroColumnas = 8;
    PdfPTable tabla = new PdfPTable(nroColumnas);
    tabla.setWidthPercentage(100);
    //Asignamos los tamaos a las columnas 
    //MOdifique para tomar en cuenta la nueva columna de dewscuento
    int[] widthColumna = new int[nroColumnas];
    if (tipo == "P") {
        widthColumna[0] = 1;
        widthColumna[1] = 1;
        widthColumna[2] = 1;
        widthColumna[3] = 1;
        widthColumna[4] = 2;
        widthColumna[5] = 1;
        if (isSelectedComp) {
            widthColumna[6] = 1;
        }
    } else {
        widthColumna[0] = 1;
        widthColumna[1] = 4;
        widthColumna[2] = 1;
        widthColumna[3] = 1;
        widthColumna[4] = 1;
        widthColumna[5] = 1;
        widthColumna[6] = 2;
        widthColumna[7] = 1;
        if (isSelectedComp) {
            widthColumna[8] = 1;
        }
    }

    tabla.setWidths(widthColumna);

    //Definimos celdas iniciales
    Font fontCabecera = new Font(Font.HELVETICA, 8, Font.BOLD);
    Font fontCelda = new Font(Font.HELVETICA, 7);
    //        HeaderFooter cabecera = new HeaderFooter(new Phrase("This is a header."), false);
    //        cabecera.

    if (tipo != "P") {
        PdfPCell h0 = new PdfPCell(new Phrase("DNI", fontCabecera));
        h0.setHorizontalAlignment(1);
        h0.setGrayFill(0.7f);
        h0.setColspan(1);
        tabla.addCell(h0);

        PdfPCell h1 = new PdfPCell(new Phrase("NOMBRE EMPLEADO", fontCabecera));
        h1.setHorizontalAlignment(1);
        h1.setGrayFill(0.7f);
        h1.setColspan(1);
        tabla.addCell(h1);
    }

    PdfPCell h2 = new PdfPCell(new Phrase("FECHA", fontCabecera));
    h2.setHorizontalAlignment(1);
    h2.setGrayFill(0.7f);
    h2.setColspan(1);
    tabla.addCell(h2);

    PdfPCell h3 = new PdfPCell(new Phrase("MARC. ENTR.", fontCabecera));
    h3.setHorizontalAlignment(1);
    h3.setGrayFill(0.7f);
    h3.setColspan(1);
    tabla.addCell(h3);

    PdfPCell h4 = new PdfPCell(new Phrase("MARC. SAL.", fontCabecera));
    h4.setHorizontalAlignment(1);
    h4.setGrayFill(0.7f);
    h4.setColspan(1);
    tabla.addCell(h4);

    PdfPCell h5 = new PdfPCell(new Phrase("ESTADO", fontCabecera));
    h5.setHorizontalAlignment(1);
    h5.setGrayFill(0.7f);
    h5.setColspan(1);
    tabla.addCell(h5);

    PdfPCell h6 = new PdfPCell(new Phrase("OBSERV.", fontCabecera));
    h6.setHorizontalAlignment(1);
    h6.setGrayFill(0.7f);
    h6.setColspan(1);
    tabla.addCell(h6);

    PdfPCell h7 = new PdfPCell(new Phrase("PER. VAC", fontCabecera));
    h7.setHorizontalAlignment(1);
    h7.setGrayFill(0.7f);
    h7.setColspan(1);
    tabla.addCell(h7);

    if (isSelectedComp) {
        PdfPCell h8 = new PdfPCell(new Phrase("COMPENSA", fontCabecera));
        h8.setHorizontalAlignment(1);
        h8.setGrayFill(0.7f);
        h8.setColspan(1);
        tabla.addCell(h8);
    }
    //Hacemos que la primera fila sea la cabecera
    tabla.setHeaderRows(1);
    /**
     * Procesamiento de los datos para generar los registros de la entrada
     */

    Calendar calC = Calendar.getInstance();
    for (String dni : dnis) {
        Calendar iterador = Calendar.getInstance();
        iterador.setTime(fechaInicio);
        while (iterador.getTime().compareTo(fechaFin) <= 0) {
            Date fecha = iterador.getTime();
            //Descartar si es sabado o domingo
            System.out.println("Dni: " + dni + " Fecha: " + fecha.toString());
            Empleado empleado = ec.buscarPorDni(dni);
            boolean isFeriado = false;
            String feriado = "";
            //Para inicio de contrato
            if (empleado.getFechaInicioContrato().compareTo(fecha) <= 0) {
                System.out.println("OK");
            } else {
                iterador.add(Calendar.DATE, 1);
                continue;
            }
            /**
             * Generacion de permiso por onomastico
             */
            if (isOnosmatico(fecha, empleado)) {
                Calendar fechaPermisoOno = Calendar.getInstance();
                fechaPermisoOno.setTime(fecha);

                while (fc.buscarXDia(fechaPermisoOno.getTime()) != null) {
                    fechaPermisoOno.add(Calendar.DATE, 1);
                }
                while (!ReporteUtil.isDiaLaboral(fechaPermisoOno.getTime())) {
                    fechaPermisoOno.add(Calendar.DATE, 1);
                }
                if (ReporteUtil.isDiaLaboral(fechaPermisoOno.getTime())) {
                    //busca onomastico
                    if (aspc.buscarXDiaOnosmatico(dni, fechaPermisoOno.getTime()) != null) {
                        System.out.println("Hay cumpleaosd d_d");
                    } else {
                        System.out.println("Crear Cumple");
                        crearOnomastico(fechaPermisoOno.getTime(), empleado);
                    }
                }
            } else {
                System.out.println("No cumple");
            }

            if (!ReporteUtil.isDiaLaboral(fecha)) {
                iterador.add(Calendar.DATE, 1);
                continue;
            }
            if (fc.buscarXDia(fecha) != null) {
                isFeriado = true;
                feriado = fc.buscarXDia(fecha).getNombre();
            }
            //Marcaciones del dia a procesar
            List<Marcacion> marcaciones = mc.buscarXFecha(dni, fecha);
            String Asistencia = "";
            String Permiso = "";
            String Vacaciones = "";
            String marcacion = "";
            String marcacion2 = "";
            String condicion = "";
            String compensacion = "";
            Marcacion primeraMarcacion = new Marcacion();
            Marcacion ultimaMarcacion = new Marcacion();

            List<EmpleadoOpcionInfo> infoEmpleado = eoc.buscarTodos(Integer.parseInt(dni));
            if (!infoEmpleado.isEmpty()) {
                if (infoEmpleado.get(0).getSFieldValue5().equals("0")
                        || infoEmpleado.get(0).getSFieldValue5().equals("")
                        || infoEmpleado.get(0).getSFieldValue5().equals(" ")) {
                    condicion = "NORMAL";
                } else if (infoEmpleado.get(0).getSFieldValue5().equals("1")) {
                    condicion = "Exonerado";
                } else if (infoEmpleado.get(0).getSFieldValue5().equals("2")) {
                    condicion = "Designado";
                } else if (infoEmpleado.get(0).getSFieldValue5().equals("3")) {
                    condicion = "Otra sede";
                }
            } else {
                condicion = "Sin dato";
            }
            System.out.println("Condicion: " + condicion);
            //Datos de horario, jornada, empleado
            List<DetalleGrupoHorario> detallesGrupos = dc.buscarXEmpleado(empleado);
            if (condicion.equals("NORMAL")) {
                if (!marcaciones.isEmpty()) {
                    primeraMarcacion = marcaciones.get(0);
                    if (marcaciones.size() > 1) {
                        ultimaMarcacion = marcaciones.get(marcaciones.size() - 1);
                        marcacion2 = ultimaMarcacion.getHora().toString();
                    } else {
                        marcacion2 = "---";
                    }
                    //ultimaMarcacion = marcaciones.get(marcaciones.size()-1);
                    /**
                     *Codigo para el manejo de asignaciones de horario
                     */

                    if (!detallesGrupos.isEmpty()) {
                        DetalleGrupoHorario detalleGrupoEmpleado = detallesGrupos.get(0);

                        List<AsignacionHorario> asignaciones = ashc
                                .buscarXGrupo(detalleGrupoEmpleado.getGrupoHorario());
                        //List<AsignacionHorario> asignacionesHorario = ashc.bus
                        List<AsignacionHorario> asignacionesHorarios = ashc.buscarXEmpleadosXAll(dni, fecha);
                        //Declaramos la variable asighorario q usaremos
                        /**
                         * Vemos si tiene una asignacion horario en particular para asignar la jornada q le corresponde, sino la tiene se asigna la jornada por 
                         * defecto del grupo horario general
                         */
                        AsignacionHorario asignacionEmpleado;
                        if (!asignacionesHorarios.isEmpty()) {
                            asignacionEmpleado = asignacionesHorarios.get(0);
                        } else {
                            asignacionEmpleado = asignaciones.get(0);
                        }
                        //AsignacionHorario asignacionEmpleado = asignaciones.get(0);
                        Horario horarioEmpleado = asignacionEmpleado.getHorario();
                        Jornada jornadaEmpleado = horarioEmpleado.getJornada();

                        //Validacion de asistencia
                        if (ultimaMarcacion.getHora() != null) {
                            if (!isSelectedHoraM) {
                                marcacion2 = jornadaEmpleado.getTurnoHS().toString();
                            }
                            if (primeraMarcacion.getHora().compareTo(ultimaMarcacion.getHora()) < 0) {
                                if ((primeraMarcacion.getHora().compareTo(jornadaEmpleado.getTurnoHE()) == 0
                                        || primeraMarcacion.getHora()
                                                .compareTo(jornadaEmpleado.getTurnoHE()) < 0)
                                        && (ultimaMarcacion.getHora()
                                                .compareTo(jornadaEmpleado.getTurnoHS()) == 0
                                                || ultimaMarcacion.getHora()
                                                        .compareTo(jornadaEmpleado.getTurnoHS()) > 0)) {
                                    Asistencia = " ";
                                    //marcacion2 = jornadaEmpleado.getTurnoHS().toString();
                                } else if (primeraMarcacion.getHora()
                                        .compareTo(jornadaEmpleado.getTardanzaHE()) < 0
                                        && primeraMarcacion.getHora()
                                                .compareTo(jornadaEmpleado.getTurnoHE()) > 0) {
                                    Asistencia = "TARDANZA";
                                    //marcacion2 = jornadaEmpleado.getTurnoHS().toString();
                                } else if (primeraMarcacion.getHora()
                                        .compareTo(jornadaEmpleado.getTardanzaHE()) > 0
                                        && ultimaMarcacion.getHora()
                                                .compareTo(jornadaEmpleado.getTurnoHS()) < 0) {
                                    Asistencia = "FALTA";
                                    //Cambio hasta tener directiva
                                    //Asistencia = "TARDANZA";
                                } else if (primeraMarcacion.getHora()
                                        .compareTo(jornadaEmpleado.getTardanzaHE()) < 0
                                        && ultimaMarcacion.getHora()
                                                .compareTo(jornadaEmpleado.getTurnoHS()) < 0) {
                                    System.out.println("Hora de salida jornada: "
                                            + jornadaEmpleado.getTurnoHS().toString());
                                    Asistencia = "FALTA";
                                    //Cambio hasta tener directiva
                                    //Asistencia = "TARDANZA";
                                } else if (primeraMarcacion.getHora()
                                        .compareTo(jornadaEmpleado.getTardanzaHE()) < 0
                                        && ultimaMarcacion.getHora()
                                                .compareTo(jornadaEmpleado.getTurnoHS()) > 0) {
                                    //Asistencia = "Falta";
                                    //Cambio hasta tener directiva
                                    Asistencia = "TARDANZA";
                                    //marcacion2 = jornadaEmpleado.getTurnoHS().toString();
                                } else if (primeraMarcacion.getHora()
                                        .compareTo(jornadaEmpleado.getTardanzaHE()) > 0
                                        && ultimaMarcacion.getHora()
                                                .compareTo(jornadaEmpleado.getTurnoHS()) > 0) {
                                    //Asistencia = "Falta";
                                    //Cambio hasta tener directiva
                                    Asistencia = "TARDANZA";
                                    //marcacion2 = jornadaEmpleado.getTurnoHS().toString();
                                }
                                //Para la compensacion
                                if (isSelectedComp) {
                                    if (ultimaMarcacion.getHora().compareTo(jornadaEmpleado.getTurnoHS()) > 0) {
                                        calC.setTime(ultimaMarcacion.getHora());
                                        int horaUM = calC.get(Calendar.HOUR_OF_DAY);
                                        int minUM = calC.get(Calendar.MINUTE);
                                        calC.setTime(jornadaEmpleado.getTurnoHS());
                                        int horaHS = calC.get(Calendar.HOUR_OF_DAY);
                                        int minHS = calC.get(Calendar.MINUTE);
                                        System.out.println("Horas: " + " " + horaUM + " " + minUM + " " + horaHS
                                                + " " + minHS);
                                        if (horaUM > horaHS) {
                                            if (minUM > minHS) {
                                                compensacion = "" + (horaUM - horaHS) + " H";
                                            } else {
                                                compensacion = (horaUM - (horaHS + 1)) + " H";
                                            }
                                        } else {
                                            compensacion = "0 H";
                                        }
                                    }
                                }
                            } else {
                                Asistencia = "FALTA";
                            }
                        } else {
                            Asistencia = "FALTA";
                        }
                        if (primeraMarcacion.getHora().compareTo(jornadaEmpleado.getTurnoHS()) >= 0) {
                            marcacion2 = primeraMarcacion.getHora().toString();
                            marcacion = "---";
                        } else {
                            marcacion = primeraMarcacion.getHora().toString();
                        }

                    } else {
                        Asistencia = "No tiene grupo horario";
                    }
                } else {
                    marcacion = "---";
                    marcacion2 = "---";
                    Asistencia = "FALTA";
                }
            } else if (condicion.equals("Exonerado")) {
                if (!marcaciones.isEmpty()) {
                    primeraMarcacion = marcaciones.get(0);
                    ultimaMarcacion = marcaciones.get(marcaciones.size() - 1);
                    //marcacion = primeraMarcacion.getHora().toString();
                    //marcacion2 = ultimaMarcacion.getHora().toString();
                    marcacion = "---";
                    marcacion2 = "---";
                    Asistencia = condicion.toUpperCase();
                } else {
                    marcacion = "---";
                    marcacion2 = "---";
                    Asistencia = condicion.toUpperCase();
                }
            } else if (condicion.equals("Designado")) {
                if (!marcaciones.isEmpty()) {
                    primeraMarcacion = marcaciones.get(0);
                    ultimaMarcacion = marcaciones.get(marcaciones.size() - 1);
                    //marcacion = primeraMarcacion.getHora().toString();
                    //marcacion2 = ultimaMarcacion.getHora().toString();
                    marcacion = "---";
                    marcacion2 = "---";
                    Asistencia = condicion.toUpperCase();
                } else {
                    marcacion = "---";
                    marcacion2 = "---";
                    Asistencia = condicion.toUpperCase();
                }
            } else if (condicion.equals("Otra sede")) {
                if (!marcaciones.isEmpty()) {
                    primeraMarcacion = marcaciones.get(0);
                    ultimaMarcacion = marcaciones.get(marcaciones.size() - 1);
                    //marcacion = primeraMarcacion.getHora().toString();
                    //marcacion2 = ultimaMarcacion.getHora().toString();
                    marcacion = "---";
                    marcacion2 = "---";
                    Asistencia = condicion.toUpperCase();
                } else {
                    marcacion = "---";
                    marcacion2 = "---";
                    Asistencia = condicion.toUpperCase();
                }
            } else {
                marcacion = "---";
                marcacion2 = "---";
                Asistencia = "Condicin sin especificar".toUpperCase();
            }

            //Validacion de permiso
            //Procesar permisos con horas tbm si no encuentra permisos por fechas 
            AsignacionPermiso asignacionPermisoEmpleadoDia = aspc.buscarXDia(dni, fecha);
            Calendar horaESinCero = Calendar.getInstance();
            Calendar horaFSinCero = Calendar.getInstance();
            if (primeraMarcacion.getHora() != null) {
                horaESinCero.setTime(primeraMarcacion.getHora());
                horaESinCero.set(Calendar.SECOND, 0);
            }
            if (ultimaMarcacion.getHora() != null) {
                horaFSinCero.setTime(ultimaMarcacion.getHora());
                horaFSinCero.set(Calendar.SECOND, 0);
            }

            AsignacionPermiso asigPerEntrada = aspc.buscarOnlyHora(dni, horaESinCero.getTime(), fecha);
            AsignacionPermiso asigPerSalida = aspc.buscarOnlyHora(dni, horaFSinCero.getTime(), fecha);
            if (asignacionPermisoEmpleadoDia != null) {
                Permiso = asignacionPermisoEmpleadoDia.getPermiso().getDocumento().toUpperCase();
                Asistencia = asignacionPermisoEmpleadoDia.getPermiso().getTipoPermiso().getNombre()
                        .toUpperCase();
            } else if (asigPerEntrada != null) {
                Permiso = asigPerEntrada.getPermiso().getDocumento().toUpperCase();
                Asistencia = asigPerEntrada.getPermiso().getTipoPermiso().getNombre().toLowerCase();
            } else if (asigPerSalida != null) {
                Permiso = asigPerSalida.getPermiso().getDocumento().toUpperCase();
                Asistencia = asigPerSalida.getPermiso().getTipoPermiso().getNombre().toUpperCase();
            } else {
                Permiso = "";
            }
            //Validacion de Vacaciones
            Vacacion vacacionEmpleado = vc.buscarXDia(dni, fecha);
            if (vacacionEmpleado != null) {
                Vacaciones = ReporteUtil.obtenerFechaDiaMes(vacacionEmpleado.getFechaInicio()) + " al "
                        + ReporteUtil.obtenerFechaDiaMes(vacacionEmpleado.getFechaFin());
                Asistencia = "VACACIONES";
                Permiso = vacacionEmpleado.getDocumento().toUpperCase();
            } else {
                Vacaciones = "";
            }
            if (isFeriado) {
                Asistencia = feriado;
            }
            PdfPCell celdaNombre = new PdfPCell(new Phrase(empleado.getNroDocumento(), fontCelda));
            celdaNombre.setMinimumHeight(15f);
            if (tipo != "P") {
                //DNI
                celdaNombre.setHorizontalAlignment(1);
                tabla.addCell(celdaNombre);
                //Nombre
                String celda0 = empleado.getApellidoPaterno() + " " + empleado.getApellidoMaterno() + " "
                        + empleado.getNombre();
                celdaNombre.setPhrase(new Phrase(celda0, fontCelda));
                celdaNombre.setHorizontalAlignment(0);
                tabla.addCell(celdaNombre);
            }
            //Fecha
            String celdaA = ReporteUtil.obtenerFechaFormateada(fecha, "/");
            celdaNombre.setPhrase(new Phrase(celdaA, fontCelda));
            celdaNombre.setHorizontalAlignment(1);
            tabla.addCell(celdaNombre);
            //Hora Marcacion de entrada
            String celda = marcacion;
            celdaNombre.setPhrase(new Phrase(celda, fontCelda));
            celdaNombre.setHorizontalAlignment(1);
            tabla.addCell(celdaNombre);
            //Hora Marcacion de Salida
            String celdaM = marcacion2;
            celdaNombre.setPhrase(new Phrase(celdaM, fontCelda));
            celdaNombre.setHorizontalAlignment(1);
            tabla.addCell(celdaNombre);
            //Asistencia
            String celda1 = Asistencia;
            celdaNombre.setPhrase(new Phrase(celda1, fontCelda));
            celdaNombre.setHorizontalAlignment(1);
            tabla.addCell(celdaNombre);
            //Permiso
            String celda2 = Permiso;
            celdaNombre.setPhrase(new Phrase(celda2, fontCelda));
            celdaNombre.setHorizontalAlignment(1);
            tabla.addCell(celdaNombre);
            //Vacacion
            String celda3 = Vacaciones;
            celdaNombre.setPhrase(new Phrase(celda3, fontCelda));
            celdaNombre.setHorizontalAlignment(1);
            tabla.addCell(celdaNombre);
            //Compensacion
            if (isSelectedComp) {
                String celda4 = compensacion;
                celdaNombre.setPhrase(new Phrase(celda4, fontCelda));
                celdaNombre.setHorizontalAlignment(1);
                tabla.addCell(celdaNombre);
            }
            iterador.add(Calendar.DATE, 1);
        }
    }
    return tabla;
}