Example usage for com.itextpdf.text.pdf PdfPTable setWidths

List of usage examples for com.itextpdf.text.pdf PdfPTable setWidths

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setWidths.

Prototype

public void setWidths(final int relativeWidths[]) throws DocumentException 

Source Link

Document

Sets the relative widths of the table.

Usage

From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java

public PdfPTable voyInfo(LclUnitSs lclUnitSs) throws DocumentException {
    StringBuilder originValues = new StringBuilder();
    if (CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getOrigin().getUnLocationName())) {
        originValues.append(lclUnitSs.getLclSsHeader().getOrigin().getUnLocationName()).append(",");
    }// w  w  w  .  j a v a2 s  .c om
    if (null != lclUnitSs.getLclSsHeader().getOrigin().getCountryId()
            && CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getOrigin().getCountryId().getCodedesc())) {
        originValues.append(lclUnitSs.getLclSsHeader().getOrigin().getCountryId().getCodedesc()).append("  ");
    }
    if (CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getOrigin().getUnLocationCode())) {
        originValues.append("(").append(lclUnitSs.getLclSsHeader().getOrigin().getUnLocationCode()).append(")");
    }

    StringBuilder fdValues = new StringBuilder();
    if (CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getDestination().getUnLocationName())) {
        fdValues.append(lclUnitSs.getLclSsHeader().getDestination().getUnLocationName()).append(",");
    }
    if (null != lclUnitSs.getLclSsHeader().getDestination().getStateId()
            && CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getDestination().getStateId().getCode())) {
        fdValues.append(lclUnitSs.getLclSsHeader().getDestination().getStateId().getCode()).append(" ");
    }
    if (CommonUtils.isNotEmpty(lclUnitSs.getLclSsHeader().getDestination().getUnLocationCode())) {
        fdValues.append("(").append(lclUnitSs.getLclSsHeader().getDestination().getUnLocationCode())
                .append(")");
    }
    Font fontCompSub = FontFactory.getFont("Arial", 9f, Font.BOLD);
    Paragraph pHeading = null;
    table = new PdfPTable(1);
    table.setWidthPercentage(100f);
    PdfPCell cell1 = new PdfPCell();
    cell1.setBorder(0);
    cell1.setColspan(2);
    cell1.setBorderColor(new BaseColor(00, 51, 153));
    cell1.setBorderWidthBottom(3f);
    cell1.setBorderWidthLeft(3f);
    cell1.setBorderWidthRight(3f);
    cell1.setBorderWidthTop(10f);
    cell1.setPadding(0f);
    //Heading
    pHeading = new Paragraph(8f, "Voyage Information", mainHeadingQuote);
    pHeading.setAlignment(Element.ALIGN_CENTER);
    cell1.addElement(pHeading);
    PdfPTable ntable1 = new PdfPTable(6);
    ntable1.setWidthPercentage(100f);
    ntable1.setWidths(new float[] { 0.1f, 1.15f, 0.09f, 4.09f, 1f, 2f });
    //company Name
    ntable1.addCell(createEmptyCell(0, 1f, 6));
    //Voyage Cell Origin
    ntable1.addCell(createEmptyCell(0, 1f, 0));
    ntable1.addCell(makeCellNoBorderValue("Voyage. . . . . . . . . .", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(lclUnitSs.getLclSsHeader().getScheduleNo().toUpperCase(), 4, 0f, 5f,
            fontgreenCont));
    //1Cell Origin
    ntable1.addCell(createEmptyCell(0, 1f, 0));
    ntable1.addCell(makeCellNoBorderValue("Origin. . . . . . . . . . .", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(originValues.toString().toUpperCase(), 4, 0f, 5f, fontgreenCont));
    ///2Cell Destination
    ntable1.addCell(createEmptyCell(0, 1f, 0));
    ntable1.addCell(makeCellNoBorderValue("Destination. . . . . .", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(fdValues.toString().toUpperCase(), 4, 0f, 5f, fontgreenCont));
    //3
    StringBuilder billValues = new StringBuilder();
    if (lclUnitSs.getLclSsHeader().getBillingTerminal().getTrmnum() != null) {
        billValues.append(lclUnitSs.getLclSsHeader().getBillingTerminal().getTrmnum()).append("-");
    }
    if (lclUnitSs.getLclSsHeader().getBillingTerminal().getTerminalLocation() != null) {
        billValues.append(lclUnitSs.getLclSsHeader().getBillingTerminal().getTerminalLocation());
    }
    ntable1.addCell(createEmptyCell(0, 1f, 0));
    ntable1.addCell(makeCellNoBorderValue("Billing Terminal. . ", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(billValues.toString().toUpperCase(), 4, 0f, 4f, fontgreenCont));

    ntable1.addCell(createEmptyCell(0, 1f, 6));
    cell1.addElement(ntable1);
    table.addCell(cell1);
    return table;
}

From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java

public PdfPTable unitInfo(LclUnitSs lclUnitSs) throws DocumentException, Exception {
    LclUnitSsImports lclUnitSsImports = lclUnitSs.getLclUnit().getLclUnitSsImportsList().get(0);
    StringBuilder cfsWarehs = new StringBuilder();
    if (lclUnitSsImports != null && lclUnitSsImports.getCfsWarehouseId() != null) {
        if (lclUnitSsImports.getCfsWarehouseId().getWarehouseName() != null) {
            cfsWarehs.append(lclUnitSsImports.getCfsWarehouseId().getWarehouseName()).append("-");
        }/* ww  w. j a v a  2s. c  om*/
        if (lclUnitSsImports.getCfsWarehouseId().getWarehouseNo() != null) {
            cfsWarehs.append(lclUnitSsImports.getCfsWarehouseId().getWarehouseNo());
        }
    }
    LclUnitSsManifest lclUnitSsManifest = lclUnitSs.getLclUnit().getLclUnitSsManifestList().get(0);
    Font fontCompSub = FontFactory.getFont("Arial", 9f, Font.BOLD);
    Paragraph pHeading = null;
    table = new PdfPTable(1);
    table.setWidthPercentage(100f);
    PdfPCell cell1 = new PdfPCell();
    cell1.setBorder(0);
    cell1.setColspan(2);
    cell1.setBorderColor(new BaseColor(00, 51, 153));
    cell1.setBorderWidthBottom(3f);
    cell1.setBorderWidthLeft(3f);
    cell1.setBorderWidthRight(3f);
    cell1.setBorderWidthTop(10f);
    cell1.setPadding(0f);
    //Heading
    pHeading = new Paragraph(8f, "Unit Information", mainHeadingQuote);
    pHeading.setAlignment(Element.ALIGN_CENTER);
    cell1.addElement(pHeading);
    PdfPTable ntable1 = new PdfPTable(6);
    ntable1.setWidthPercentage(100f);
    ntable1.setWidths(new float[] { 0.1f, 1.15f, 0.09f, 4.09f, 1f, 2f });
    //company Name
    ntable1.addCell(createEmptyCell(0, 1f, 6));
    //unit No Cell
    ntable1.addCell(createEmptyCell(0, 1f, 0));
    ntable1.addCell(makeCellNoBorderValue("Unit No . . . . . . . . .", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(
            makeCellNoBorderValue(lclUnitSs.getLclUnit().getUnitNo().toUpperCase(), 4, 0f, 4f, fontgreenCont));
    //3
    ntable1.addCell(createEmptyCell(0, 1f, 0));
    ntable1.addCell(makeCellNoBorderValue("CFS(Devanning). . ", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(cfsWarehs.toString().toUpperCase(), 4, 0f, 4f, fontgreenCont));
    //
    ntable1.addCell(createEmptyCell(0, 1f, 0));
    ntable1.addCell(makeCellNoBorderValue("Master BL. . . . . . . ", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(makeCellNoBorderValue(":", 0, 0f, 4f, fontCompSub));
    ntable1.addCell(
            makeCellNoBorderValue(lclUnitSsManifest.getMasterbl().toUpperCase(), 4, 0f, 4f, fontgreenCont));

    ntable1.addCell(createEmptyCell(0, 1f, 6));
    cell1.addElement(ntable1);
    table.addCell(cell1);
    return table;
}

From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java

public PdfPTable dispoInfo(LclUnitSs lclUnitSs) throws DocumentException, Exception {
    Paragraph pHeading = null;/* w w w. ja  va2s  .co m*/
    table = new PdfPTable(1);
    table.setWidthPercentage(100f);
    PdfPCell cell1 = null;
    cell1 = new PdfPCell();
    cell1.setBorder(0);
    cell1.setBorderColor(new BaseColor(00, 51, 153));
    cell1.setBorderWidthBottom(3f);
    cell1.setBorderWidthLeft(3f);
    cell1.setBorderWidthRight(3f);
    cell1.setBorderWidthTop(10f);
    cell1.setPadding(0f);
    //Heading
    pHeading = new Paragraph(8f, "Disposition Details", mainHeadingQuote);
    pHeading.setAlignment(Element.ALIGN_CENTER);
    cell1.addElement(pHeading);
    //company Name
    PdfPTable ntable1 = new PdfPTable(9);
    ntable1.setWidthPercentage(100f);
    ntable1.setWidths(new float[] { 0.2f, 2f, 0.25f, 1.5f, 0.25f, 4.5f, 1.5f, 5f, .5f });
    ntable1.addCell(createEmptyCell(0, 0.1f, 9));

    ntable1.addCell(createEmptyCell(0, 1f, 0));
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.06f);
    Chunk c1 = new Chunk("DATE", greenCourierFont9);
    cell.addElement(c1);
    ntable1.addCell(cell);

    ntable1.addCell(createEmptyCell(0, .5f, 0));

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.06f);
    c1 = new Chunk("TIME", greenCourierFont9);
    cell.addElement(c1);
    ntable1.addCell(cell);

    ntable1.addCell(createEmptyCell(0, .5f, 0));

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.06f);
    c1 = new Chunk("CONTAINER STATUS", greenCourierFont9);
    cell.addElement(c1);
    ntable1.addCell(cell);

    ntable1.addCell(createEmptyCell(0, .5f, 0));
    ntable1.addCell(createEmptyCell(0, .5f, 0));
    ntable1.addCell(createEmptyCell(0, .5f, 0));
    LclSsDetail lclSsDetail = lclUnitSs.getLclSsHeader().getVesselSsDetail();
    List<LclUnitSsDispo> dispositionList = new LclUnitSsDispoDAO()
            .getUnitDispoDetailsWithoutData(lclUnitSs.getLclUnit().getId(), lclSsDetail.getId());
    if (!dispositionList.isEmpty()) {
        for (int i = 0; i < dispositionList.size(); i++) {
            LclUnitSsDispo lclUnitSsDispo = (LclUnitSsDispo) dispositionList.get(i);
            String dateTimeV = DateUtils.formatDate(lclUnitSsDispo.getDispositionDatetime(),
                    "dd-MMM-yyyy hh:mm a");
            String[] dateTimeArray1 = dateTimeV.split(" ");
            ntable1.addCell(createEmptyCell(0, 1f, 0));
            cell = new PdfPCell();
            cell.setBorder(0);
            pHeading = new Paragraph(5f, "" + dateTimeArray1[0], greenCourierFont9);
            cell.addElement(pHeading);
            ntable1.addCell(cell);

            ntable1.addCell(createEmptyCell(0, .5f, 0));

            cell = new PdfPCell();
            cell.setBorder(0);
            pHeading = new Paragraph(5f, "" + dateTimeArray1[1] + " " + dateTimeArray1[2], greenCourierFont9);
            cell.addElement(pHeading);
            ntable1.addCell(cell);

            ntable1.addCell(createEmptyCell(0, .5f, 0));

            cell = new PdfPCell();
            cell.setBorder(0);
            if (lclUnitSsDispo.getDisposition() != null
                    && lclUnitSsDispo.getDisposition().getDescription() != null) {
                pHeading = new Paragraph(5f, "" + lclUnitSsDispo.getDisposition().getDescription(),
                        greenCourierFont9);
            } else {
                pHeading = new Paragraph(5f, "" + lclUnitSsDispo.getDisposition().getEliteCode(),
                        greenCourierFont9);
            }
            cell.addElement(pHeading);
            ntable1.addCell(cell);
            ntable1.addCell(createEmptyCell(0, .5f, 0));
            ntable1.addCell(createEmptyCell(0, .5f, 0));
            ntable1.addCell(createEmptyCell(0, .5f, 0));
        }
    }
    ntable1.addCell(createEmptyCell(0, 2f, 9));
    cell1.addElement(ntable1);
    table.addCell(cell1);
    return table;
}

From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java

public PdfPTable voyContent(String voyContent) throws DocumentException, Exception {
    Paragraph pHeading = null;//from  w w  w  .  ja  va 2 s. c o m
    table = new PdfPTable(1);
    table.setWidthPercentage(100f);
    PdfPCell cell1 = null;
    cell1 = new PdfPCell();
    cell1.setBorder(0);
    cell1.setBorderColor(new BaseColor(00, 51, 153));
    cell1.setBorderWidthBottom(3f);
    cell1.setBorderWidthLeft(3f);
    cell1.setBorderWidthRight(3f);
    cell1.setBorderWidthTop(10f);
    cell1.setPadding(0f);
    //Heading
    pHeading = new Paragraph(8f, "Voyage Comments", mainHeadingQuote);
    pHeading.setAlignment(Element.ALIGN_CENTER);
    cell1.addElement(pHeading);
    //company Name
    PdfPTable ntable1 = new PdfPTable(2);
    ntable1.setWidthPercentage(100f);
    ntable1.setWidths(new float[] { 0.1f, 5f });
    ntable1.addCell(createEmptyCell(0, 0.1f, 2));

    ntable1.addCell(createEmptyCell(0, 1f, 0));
    cell = new PdfPCell();
    cell.setBorder(0);
    pHeading = new Paragraph(8f, "" + voyContent.toUpperCase(), blackContentBoldFont);
    cell.addElement(pHeading);
    ntable1.addCell(cell);

    ntable1.addCell(createEmptyCell(0, 2f, 2));
    cell1.addElement(ntable1);
    table.addCell(cell1);
    return table;
}

From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java

public PdfPTable tablebodyOne(FclBl bl, String freeDate, String localDeliveryOrTransferBy, String po,
        String referenceNumbers, String realPath) throws Exception {

    PdfPTable table = new PdfPTable(4);
    table.setWidths(new float[] { 3f, 2f, 2f, 4f });
    table.setWidthPercentage(100);/*from  w  ww. j a  v  a 2 s  . com*/

    PdfPCell cell = null;
    Paragraph p = null;

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(8f, "IMPORTING CAREER:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    cell.setColspan(2);
    p = new Paragraph(8f, "LOCATION:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(9f, "FROM PORT OF ORIGIN AIRPORT:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getSslineName()) ? bl.getSslineName() : "", blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    cell.setColspan(2);
    p = new Paragraph(8f,
            CommonUtils.isNotEmpty(bl.getOnwardInlandRouting()) ? bl.getOnwardInlandRouting() : "", blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getTerminal()) ? bl.getTerminal() : "", blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(8f, "BILL OR AWB NO: ", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(8f, "ARRIVAL DATE:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(9f, "FREE TIME EXP:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(9f, "LOCAL DELIVERY OR TRANSFER BY:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getNewMasterBL()) ? bl.getNewMasterBL() : "", blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    if (bl.getEtaFd() != null) {
        p = new Paragraph(8f, "" + DateUtils.formatStringDateToAppFormatMMM(bl.getEtaFd()), blackFont);
    } else {
        p = new Paragraph(8f, "", blackFont);
    }
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, freeDate, blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, localDeliveryOrTransferBy, blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(8f, "PO#:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    cell.setColspan(2);
    p = new Paragraph(8f, "HAWB NO:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(8f, "REFERENCE NUMBERS:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, po, blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    cell.setColspan(2);
    p = new Paragraph(8f, CommonUtils.isNotEmpty(bl.getImportAMSHouseBl()) ? bl.getImportAMSHouseBl() : "",
            blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, referenceNumbers, blackFont);
    cell.addElement(p);
    table.addCell(cell);

    return table;
}

From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java

public PdfPTable tablebodyTwo(FclBl bl, String deliveryTo, String deliveryContact, String deliveryEmail,
        String deliveryPhone, String deliveryFax, String notify, String realPath) throws Exception {
    PdfPTable table = new PdfPTable(5);
    table.setWidths(new float[] { 2f, 2f, 2f, 2f, 2f });
    table.setWidthPercentage(100);/*from w  w  w.j av  a  2 s .  c  o m*/
    PdfPCell cell = null;
    Paragraph p = null;

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(8f, "FOR DELIVERY TO:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(8f, "NOTIFY:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, deliveryTo, blackFont);
    cell.addElement(p);
    p = new Paragraph(8f, "Contact Name: " + deliveryContact, blackFont);
    cell.addElement(p);
    p = new Paragraph(8f, "Phone: " + deliveryPhone, blackFont);
    cell.addElement(p);
    p = new Paragraph(8f, "Fax: " + deliveryFax, blackFont);
    cell.addElement(p);
    p = new Paragraph(8f, "Email: " + deliveryEmail, blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.setBorderWidthTop(0f);
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, notify, blackFont);
    cell.addElement(p);
    table.addCell(cell);

    return table;
}

From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java

public PdfPTable tablebodyThree(FclBl bl, FclDoorDelivery fclDoorDelivery, MessageResources messageResources,
        String realPath) throws Exception {
    PdfPTable table = new PdfPTable(4);
    table.setWidths(new float[] { 2f, 1f, 5f, 2f });
    table.setWidthPercentage(100);/*  ww w  . jav a 2s.c om*/

    PdfPCell cell = null;
    Paragraph p = null;

    cell = new PdfPCell();
    p = new Paragraph(8f, "MARKS AND NUMBERS", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    p = new Paragraph(8f, "PIECES", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    p = new Paragraph(8f, "DESCRIPTION OF PACKAGES AND GOODS", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    p = new Paragraph(8f, "GROSS WEIGHT LBS", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    FclBlContainerDAO fclBlContainerDAO = new FclBlContainerDAO();
    Set<FclBlContainer> containerSet = bl.getFclcontainer();
    for (Iterator iter = containerSet.iterator(); iter.hasNext();) {
        FclBlContainer fclBlContainer = (FclBlContainer) iter.next();
        StringBuilder tempSizeLegened = new StringBuilder();
        String sizeLegend = fclBlContainer.getSizeLegend() != null
                ? (fclBlContainer.getSizeLegend().getCodedesc() != null
                        ? fclBlContainer.getSizeLegend().getCodedesc()
                        : "")
                : "";
        int index = sizeLegend.indexOf("=");
        if (index != -1) {
            tempSizeLegened.append("1X");
            String tempSize = sizeLegend.substring(index + 1, sizeLegend.length());
            if (tempSize.equalsIgnoreCase(messageResources.getMessage("container40HC"))) {
                tempSize = "40" + "'" + "HC";
            } else if (tempSize.equalsIgnoreCase(messageResources.getMessage("container40NOR"))) {
                tempSize = "40" + "'" + "NOR";
            } else {
                tempSize = tempSize + "'";
            }
            tempSizeLegened.append(tempSize);
        } else {
            tempSizeLegened.append("");
        }

        StringBuilder marksNumber = new StringBuilder();
        if (null != bl.getPrintContainersOnBL() && bl.getPrintContainersOnBL().equalsIgnoreCase("Yes")) {
            marksNumber.append(tempSizeLegened);
            marksNumber.append("\n");
            marksNumber.append(fclBlContainer.getTrailerNo() != null ? fclBlContainer.getTrailerNo() : "");
            marksNumber.append("\n");
            marksNumber.append("SEAL: ");
            marksNumber.append(" " + fclBlContainer.getSealNo() != null ? fclBlContainer.getSealNo() : "");
        }
        //            HelperClass helperClass = new HelperClass();
        //
        //            List marksList = helperClass.splitDescrption(helperClass.wrapAddress(fclBlContainer.getMarks()), DESC_SIZE + 1);
        //            if (!marksList.isEmpty()) {
        //                marksNumber.append("\n");
        //                marksNumber.append(marksList.get(0).toString());
        //                marksList.remove(0);
        //            }

        List<FclBlMarks> fclMarksList = fclBlContainerDAO.getPakagesDetails(fclBlContainer.getTrailerNoId());
        if (fclMarksList != null && !fclMarksList.isEmpty()) {

            cell = new PdfPCell();
            cell.setBorderWidthBottom(0f);
            cell.setBorderWidthTop(0f);
            p = new Paragraph(8f, marksNumber.toString(), blackFont);
            cell.addElement(p);
            table.addCell(cell);

            cell = new PdfPCell();
            cell.setBorderWidthBottom(0f);
            cell.setBorderWidthTop(0f);
            table.addCell(cell);

            cell = new PdfPCell();
            cell.setBorderWidthBottom(0f);
            cell.setBorderWidthTop(0f);
            table.addCell(cell);

            cell = new PdfPCell();
            cell.setBorderWidthBottom(0f);
            cell.setBorderWidthTop(0f);
            table.addCell(cell);

            for (FclBlMarks fclBlmarks : fclMarksList) {

                cell = new PdfPCell();
                cell.setBorderWidthBottom(0f);
                cell.setBorderWidthTop(0f);
                table.addCell(cell);

                cell = new PdfPCell();
                cell.setBorderWidthBottom(0f);
                cell.setBorderWidthTop(0f);
                p = new Paragraph(8f, "" + fclBlmarks.getNoOfPkgs(), blackFont);
                cell.addElement(p);
                table.addCell(cell);

                cell = new PdfPCell();
                cell.setBorderWidthBottom(0f);
                cell.setBorderWidthTop(0f);
                p = new Paragraph(8f, fclBlmarks.getDescPckgs(), blackFont);
                cell.addElement(p);
                table.addCell(cell);

                cell = new PdfPCell();
                cell.setBorderWidthBottom(0f);
                cell.setBorderWidthTop(0f);
                p = new Paragraph(8f, "" + fclBlmarks.getNetweightLbs(), blackFont);
                cell.addElement(p);
                table.addCell(cell);
            }
        }
    }

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    table.addCell(cell);

    return table;
}

From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java

public PdfPTable tablebodyFour(FclBl bl, String billing, String realPath) throws Exception {
    PdfPTable table = new PdfPTable(5);
    table.setWidths(new float[] { 3f, 3f, 1f, 2f, 1f });
    table.setWidthPercentage(100);/*from  ww  w. j av  a2 s.  c  o m*/

    PdfPCell cell = null;
    Paragraph p = null;

    cell = new PdfPCell();
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthBottom(0f);
    p = new Paragraph(8f, "PRE-PAID/COLLECT/3rd PARTY", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.setBorder(0);
    p = new Paragraph(8f, "Received in Good Order By:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setFixedHeight(25f);
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorderWidthTop(0f);
    p = new Paragraph(8f, billing, blackFont);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.setBorder(0);
    p = new Paragraph(8f, "", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setColspan(3);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.setBorderWidthTop(0f);
    cell.setBorderWidthLeft(0f);
    cell.setBorderWidthRight(0f);
    p = new Paragraph(8f, "Signature:", blackFontForAR);
    cell.addElement(p);
    table.addCell(cell);

    return table;
}

From source file:com.grant.report.BillPdf.java

private void createTable(Paragraph preface) throws BadElementException, DocumentException {
    addEmptyLine(preface, 1);//from  www .  ja va2  s .  co  m
    PdfPTable table = new PdfPTable(6);

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);
    PdfPCell c1 = new PdfPCell(new Phrase("Item Code"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Description"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Qty"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Unit"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Rate"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Amount"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    table.setHeaderRows(1);
    float[] columnWidths = new float[] { 15f, 30f, 10f, 10f, 10f, 15f };
    table.setWidths(columnWidths);

    ItemDAO dao = new ItemDAO();

    String itemName;
    String itemNo;
    String description;
    String outwards;
    String unitPrice;
    String amount;
    String unit;

    Vector<Vector<String>> data;
    data = dao.getStockOutTbl(invoNo);
    String s = data.get(0).get(1);
    for (int i = 0; i < data.size(); i++) {
        Vector<String> data2 = data.get(i);

        itemName = data.get(i).get(0);
        description = data.get(i).get(3);
        outwards = data.get(i).get(5);
        itemNo = data.get(i).get(1);
        unit = data.get(i).get(6);
        unitPrice = data.get(i).get(8);
        amount = data.get(i).get(9);

        table.addCell(itemNo);
        table.addCell(description);
        table.addCell(outwards);
        table.addCell(unit);
        table.addCell(unitPrice);
        table.addCell(amount);
    }
    preface.add(table);
}

From source file:com.hrms.struts.Reportsaction.java

public String generateemployees() {
    //    System.out.println(pdf.getEmp_id());
    //    System.out.println(pdf.getName());

    HttpServletResponse res = ServletActionContext.getResponse();
    Rectangle envelope = new Rectangle(1300, 1300);
    Document d = new Document(envelope, 10f, 10f, 100f, 0f);
    ByteArrayOutputStream b = new ByteArrayOutputStream();
    d.addTitle("Salary Abstract For the Month of JUNE 2016");
    Font ffont = new Font(Font.FontFamily.TIMES_ROMAN, 25, Font.BOLD);

    try {/*from w w  w. j  av a2  s  .c  o m*/
        String date = object.getEmpdate();
        System.out.println("ssdff" + date);
        SimpleDateFormat s1 = new SimpleDateFormat("dd-MM-yy");
        Date d1 = s1.parse(date);
        System.out.println("Date is [[[[[[[[[[[[[[[" + d1);
        Calendar cal = Calendar.getInstance();
        cal.setTime(d1);
        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        System.out.println("Incentives year year isssssssss" + year);

        String[] monthNames = { "January", "February", "March", "April", "May", "June", "July", "August",
                "September", "October", "November", "December" };
        String newmonth = monthNames[month - 1];
        System.out.println("Incentives month isssssssss" + newmonth);

        Chunk reportTitle = new Chunk("Pay Sheet  For the Month of " + newmonth + year, ffont);

        Phrase p = new Phrase(reportTitle);
        //  p.add(reportTitle);
        Paragraph para = new Paragraph();
        para.add(p);
        para.setAlignment(Element.ALIGN_CENTER);
        PdfWriter.getInstance(d, b);

        PdfWriter.getInstance(d, b);

        Font boldFont = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD);
        Phrase two = new Phrase("Code No", boldFont);
        Phrase three = new Phrase("Name", boldFont);
        Phrase four = new Phrase("Status", boldFont);
        Phrase five = new Phrase("Dept", boldFont);
        Phrase six = new Phrase("Days", boldFont);
        Phrase seven = new Phrase("Wage", boldFont);
        Phrase eight = new Phrase("Inc", boldFont);
        Phrase nine = new Phrase("Earn", boldFont);
        Phrase ten = new Phrase("Inc Amt", boldFont);
        Phrase eleven = new Phrase("Gross Earn", boldFont);
        Phrase twelve = new Phrase("PF", boldFont);
        Phrase thirteen = new Phrase("PPP", boldFont);
        Phrase fourteen = new Phrase("PF No", boldFont);
        Phrase fifteen = new Phrase("Sal Advance", boldFont);

        PdfPCell pdfWordCell2 = new PdfPCell();
        PdfPCell pdfWordCell3 = new PdfPCell();
        PdfPCell pdfWordCell4 = new PdfPCell();
        PdfPCell pdfWordCell5 = new PdfPCell();
        PdfPCell pdfWordCell6 = new PdfPCell();
        PdfPCell pdfWordCell7 = new PdfPCell();
        PdfPCell pdfWordCell8 = new PdfPCell();
        PdfPCell pdfWordCell9 = new PdfPCell();
        PdfPCell pdfWordCell10 = new PdfPCell();
        PdfPCell pdfWordCell11 = new PdfPCell();
        PdfPCell pdfWordCell12 = new PdfPCell();
        PdfPCell pdfWordCell13 = new PdfPCell();
        PdfPCell pdfWordCell14 = new PdfPCell();
        PdfPCell pdfWordCell15 = new PdfPCell();
        PdfPCell pdfWordCell50 = new PdfPCell(new Phrase("Gas Loan", boldFont));
        PdfPCell pdfWordCell16 = new PdfPCell(new Phrase("Cash Loan", boldFont));
        PdfPCell pdfWordCell17 = new PdfPCell(new Phrase("Tra Loan", boldFont));
        PdfPCell pdfWordCell18 = new PdfPCell(new Phrase("Power", boldFont));
        PdfPCell pdfWordCell19 = new PdfPCell(new Phrase("Meals", boldFont));
        PdfPCell pdfWordCell20 = new PdfPCell(new Phrase("Tiffin", boldFont));
        PdfPCell pdfWordCell21 = new PdfPCell(new Phrase("Tea", boldFont));
        PdfPCell pdfWordCell22 = new PdfPCell(new Phrase("Store", boldFont));
        PdfPCell pdfWordCell23 = new PdfPCell(new Phrase("Medicine", boldFont));
        PdfPCell pdfWordCell24 = new PdfPCell(new Phrase("Cable", boldFont));
        PdfPCell pdfWordCell25 = new PdfPCell(new Phrase("Gas", boldFont));
        PdfPCell pdfWordCell26 = new PdfPCell(new Phrase("Adv2", boldFont));
        PdfPCell pdfWordCell27 = new PdfPCell(new Phrase("Eggs", boldFont));
        PdfPCell pdfWordCell28 = new PdfPCell(new Phrase("Uniform", boldFont));
        PdfPCell pdfWordCell29 = new PdfPCell(new Phrase("Total Deduction", boldFont));
        PdfPCell pdfWordCell30 = new PdfPCell(new Phrase("Net Salary", boldFont));
        //   PdfPCell pdfWordCell31= new PdfPCell(new Phrase("Signature", boldFont));

        pdfWordCell2.addElement(two);
        pdfWordCell3.addElement(three);
        pdfWordCell4.addElement(four);
        pdfWordCell5.addElement(five);
        pdfWordCell6.addElement(six);
        pdfWordCell7.addElement(seven);
        pdfWordCell8.addElement(eight);
        pdfWordCell9.addElement(nine);
        pdfWordCell10.addElement(ten);
        pdfWordCell11.addElement(eleven);
        pdfWordCell12.addElement(twelve);
        pdfWordCell13.addElement(thirteen);
        pdfWordCell14.addElement(fourteen);
        pdfWordCell15.addElement(fifteen);

        d.open();
        PdfPTable table = new PdfPTable(30);
        //     PdfPTable table1 = new PdfPTable(2);
        //    table.setWidths(new int[]{4,5,6,5,7,5,5,5,4,7,6,4,4,6,8,7,6,6,6,6,4,5,9,5,4,2,2,2,2,2,2});
        table.setTotalWidth(1250);
        table.setWidths(new int[] { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 45, 40, 40, 40, 40,
                40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 });
        table.setLockedWidth(true);
        //   table.addCell(  pdfWordCell );  

        //      table.setTotalWidth(1250);
        //      table.setLockedWidth(true);

        table.addCell(pdfWordCell2);
        table.addCell(pdfWordCell3);
        table.addCell(pdfWordCell4);
        table.addCell(pdfWordCell5);
        table.addCell(pdfWordCell6);
        table.addCell(pdfWordCell7);
        table.addCell(pdfWordCell8);
        table.addCell(pdfWordCell9);
        table.addCell(pdfWordCell10);
        table.addCell(pdfWordCell11);
        table.addCell(pdfWordCell12);
        table.addCell(pdfWordCell13);
        table.addCell(pdfWordCell14);
        table.addCell(pdfWordCell15);
        table.addCell(pdfWordCell50);
        table.addCell(pdfWordCell16);
        table.addCell(pdfWordCell17);
        table.addCell(pdfWordCell18);
        table.addCell(pdfWordCell19);
        table.addCell(pdfWordCell20);
        table.addCell(pdfWordCell21);
        table.addCell(pdfWordCell22);
        table.addCell(pdfWordCell23);
        table.addCell(pdfWordCell24);
        table.addCell(pdfWordCell25);
        table.addCell(pdfWordCell26);
        table.addCell(pdfWordCell27);
        table.addCell(pdfWordCell28);
        table.addCell(pdfWordCell29);
        table.addCell(pdfWordCell30);
        // table.addCell(pdfWordCell31);

        Connection connection = null;
        Class.forName("com.mysql.jdbc.Driver");
        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/hrmsdp_10", "root",
                "nivriti@123");
        //   Statement st=connection. createStatement(); 

        Statement st1 = connection.createStatement();
        CallableStatement st = null;
        String sql = "{Call emp_payslip123(?,?)}";
        st = connection.prepareCall(sql);

        st.setString(1, newmonth);
        st.setInt(2, year);
        //  String sql="Call calc(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        //  PreparedStatement st=connection.prepareStatement(sql);
        //    ResultSet rs= st.executeQuery("Call calc(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
        ResultSet rs = st.executeQuery();
        while (rs.next()) {

            table.addCell(rs.getString("emp_id"));
            table.addCell(rs.getString("emp_name"));
            table.addCell(rs.getString("status"));
            table.addCell(rs.getString("dept_name"));
            table.addCell(rs.getString("days"));
            table.addCell(rs.getString("wage"));
            table.addCell(rs.getString("inc"));
            table.addCell(rs.getString("earn"));
            table.addCell(rs.getString("inc_amount"));
            table.addCell(rs.getString("gross_salary"));
            table.addCell(rs.getString("pf"));
            table.addCell(rs.getString("ppp"));
            table.addCell(rs.getString("pf_no"));
            table.addCell(rs.getString("salary_advance"));
            table.addCell(rs.getString("sum(gas_loan)"));
            table.addCell(rs.getString("sum(cash_loan)"));
            table.addCell(rs.getString("sum(tra_loan)"));
            table.addCell(rs.getString("power"));
            table.addCell(rs.getString("meals"));
            table.addCell(rs.getString("tiffin"));
            table.addCell(rs.getString("tea"));
            table.addCell(rs.getString("store"));
            table.addCell(rs.getString("medicines"));
            table.addCell(rs.getString("cable"));
            table.addCell(rs.getString("gas"));
            table.addCell(rs.getString("adv2"));
            table.addCell(rs.getString("eggs"));
            table.addCell(rs.getString("uniform"));
            table.addCell(rs.getString("total_deductions"));
            table.addCell(rs.getString("net_salary"));
            //   table.addCell("");
            // table.addCell(image);
        }
        //ResultSet rs1=st1.executeQuery("SELECT   sum(days) as days , sum(wage) as wages, sum(earn) as earn ,sum(inc) as inc,sum(gros_earn) as gross_earn,sum(sal_advance) as sal_adv,sum(cash_loan) as cash_loan,sum(gas_loan) as gas_loan,sum(tra_loan) as tra_loan,sum(power) as power,sum(meals) as meals,sum(tiffin) as tiffin,sum(tea) as tea,sum(store) as store,sum(medicines) as medicines,sum(cable) as cable,sum(gas) as gas,sum(adv2) as adv2,sum(eggs) as eggs,sum(uniform) as uniform,sum(total_deduction) as totla_deduction  FROM caluclation ");
        //            ResultSet rs1=st1.executeQuery("select sum(days),sum(wage) from caluclation");
        //      String s1=rs1.getString(1);

        //   table.setTotalWidth(PageSize.LARGE_CROWN_OCTAVO.getWidth());   
        d.add(para);
        d.add(Chunk.NEWLINE);
        d.add(Chunk.NEWLINE);
        d.add(table);
        d.close();
    } catch (Exception e) {
        System.out.println(e);
    }
    byte[] bytes = null;
    bytes = b.toByteArray();
    res.setContentLength(bytes.length);
    if (bytes != null) {
        inputStream = new ByteArrayInputStream(bytes);
    }
    return "success";
}