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:com.geek.tutorial.itext.acroform.TextFieldForm.java

License:Open Source License

public TextFieldForm() throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TextFieldForm.pdf"));
    document.open();// www .  ja v  a  2 s.  c o  m

    PdfPTable table = new PdfPTable(2);
    table.getDefaultCell().setPadding(5f); // Code 1, will only affect empty field
    table.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell;

    // Code 2, add name TextField      
    table.addCell("Name");
    TextField nameField = new TextField(writer, new Rectangle(0, 0, 200, 10), "nameField");
    nameField.setBackgroundColor(Color.WHITE);
    nameField.setBorderColor(Color.BLACK);
    nameField.setBorderWidth(1);
    nameField.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
    nameField.setText("");
    nameField.setAlignment(Element.ALIGN_LEFT);
    nameField.setOptions(TextField.REQUIRED);
    cell = new PdfPCell();
    cell.setMinimumHeight(10);
    cell.setCellEvent(new FieldCell(nameField.getTextField(), 200, writer));
    table.addCell(cell);

    // force upper case javascript
    writer.addJavaScript("var nameField = this.getField('nameField');" + "nameField.setAction('Keystroke',"
            + "'forceUpperCase()');" + "" + "function forceUpperCase(){"
            + "if(!event.willCommit)event.change = " + "event.change.toUpperCase();" + "}");

    // Code 3, add empty row
    table.addCell("");
    table.addCell("");

    // Code 4, add age TextField
    table.addCell("Age");
    TextField ageComb = new TextField(writer, new Rectangle(0, 0, 30, 10), "ageField");
    ageComb.setBorderColor(Color.BLACK);
    ageComb.setBorderWidth(1);
    ageComb.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
    ageComb.setText("12");
    ageComb.setAlignment(Element.ALIGN_RIGHT);
    ageComb.setMaxCharacterLength(2);
    ageComb.setOptions(TextField.COMB | TextField.DO_NOT_SCROLL);
    cell = new PdfPCell();
    cell.setMinimumHeight(10);
    cell.setCellEvent(new FieldCell(ageComb.getTextField(), 30, writer));
    table.addCell(cell);

    // validate age javascript
    writer.addJavaScript("var ageField = this.getField('ageField');"
            + "ageField.setAction('Validate','checkAge()');" + "function checkAge(){" + "if(event.value < 12){"
            + "app.alert('Warning! Applicant\\'s age can not" + " be younger than 12.');" + "event.value = 12;"
            + "}}");

    // add empty row
    table.addCell("");
    table.addCell("");

    // Code 5, add age TextField
    table.addCell("Comment");
    TextField comment = new TextField(writer, new Rectangle(0, 0, 200, 100), "commentField");
    comment.setBorderColor(Color.BLACK);
    comment.setBorderWidth(1);
    comment.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
    comment.setText("");
    comment.setOptions(TextField.MULTILINE | TextField.DO_NOT_SCROLL);
    cell = new PdfPCell();
    cell.setMinimumHeight(100);
    cell.setCellEvent(new FieldCell(comment.getTextField(), 200, writer));
    table.addCell(cell);

    // check comment characters length javascript
    writer.addJavaScript("var commentField = " + "this.getField('commentField');" + "commentField"
            + ".setAction('Keystroke','checkLength()');" + "function checkLength(){"
            + "if(!event.willCommit && " + "event.value.length > 100){" + "app.alert('Warning! Comment can not "
            + "be more than 100 characters.');" + "event.change = '';" + "}}");

    // add empty row
    table.addCell("");
    table.addCell("");

    // Code 6, add submit button   
    PushbuttonField submitBtn = new PushbuttonField(writer, new Rectangle(0, 0, 35, 15), "submitPOST");
    submitBtn.setBackgroundColor(Color.GRAY);
    submitBtn.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
    submitBtn.setText("POST");
    submitBtn.setOptions(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT);
    PdfFormField submitField = submitBtn.getField();
    submitField.setAction(PdfAction.createSubmitForm("http://www.geek-tutorials.com/java/itext/submit.php",
            null, PdfAction.SUBMIT_HTML_FORMAT));
    cell = new PdfPCell();
    cell.setMinimumHeight(15);
    cell.setCellEvent(new FieldCell(submitField, 35, writer));
    table.addCell(cell);

    // Code 7, add reset button
    PushbuttonField resetBtn = new PushbuttonField(writer, new Rectangle(0, 0, 35, 15), "reset");
    resetBtn.setBackgroundColor(Color.GRAY);
    resetBtn.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
    resetBtn.setText("RESET");
    resetBtn.setOptions(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT);
    PdfFormField resetField = resetBtn.getField();
    resetField.setAction(PdfAction.createResetForm(null, 0));
    cell = new PdfPCell();
    cell.setMinimumHeight(15);
    cell.setCellEvent(new FieldCell(resetField, 35, writer));
    table.addCell(cell);

    document.add(table);
    document.close();
}

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

public void createImportFreightPdf(String realPath, String unitSsId, String fileId, String fileNumber,
        String outputFileName, String documentName, String voyNotiemailId, User loginUser) throws Exception {
    ImportPortConfigurationDAO importPortConfigurationDAO = new ImportPortConfigurationDAO();
    LclUnitSsDispoDAO lclUnitSsDispoDAO = new LclUnitSsDispoDAO();
    LclUnitSsDAO lclUnitSsDAO = new LclUnitSsDAO();
    LclRemarksDAO lclRemarksDAO = new LclRemarksDAO();
    LclBookingPieceDAO lclBookingPieceDAO = new LclBookingPieceDAO();
    String trmname = "";
    String trmAddress = "";
    String trmZip = "";
    String customerPo = "";
    String unitNo = "";
    String masterBl = "";
    StringBuilder originValues = new StringBuilder();
    StringBuilder destinationValues = new StringBuilder();
    String subHouseBl = "";
    String amsHouseBl = "";
    String shipName = "";
    String consName = "";
    String notyName = "";
    String forwName = "";
    String billToParty = "";
    String billToPartyAc = "";
    Date pickUpDate = null;/*from  w  w  w .j a  v a  2  s .  c o  m*/
    Date vesselEtd = null;
    String billToPartyAcctName = "";
    StringBuilder consAddress = new StringBuilder();

    LclBooking lclBooking = new LCLBookingDAO().findById(Long.valueOf(fileId));
    shipName = null != lclBooking.getShipAcct() ? lclBooking.getShipContact().getCompanyName() : "";
    consName = null != lclBooking.getConsAcct() ? lclBooking.getConsContact().getCompanyName() : "";
    notyName = null != lclBooking.getNotyAcct() ? lclBooking.getNotyContact().getCompanyName() : "";
    forwName = null != lclBooking.getFwdAcct() ? lclBooking.getFwdAcct().getAccountName() : "";

    billToParty = null != lclBooking.getBillToParty() ? lclBooking.getBillToParty() : "";
    if (billToParty.equalsIgnoreCase("C")) {
        billToPartyAc = null != lclBooking.getConsAcct() ? lclBooking.getConsAcct().getAccountno() : "";
        billToPartyAcctName = null != lclBooking.getConsAcct() ? lclBooking.getConsContact().getCompanyName()
                : "";
    } else if (billToParty.equalsIgnoreCase("A")) {
        billToPartyAc = null != lclBooking.getSupAcct() ? lclBooking.getSupAcct().getAccountno() : "";
        billToPartyAcctName = null != lclBooking.getSupAcct() ? lclBooking.getSupAcct().getAccountName() : "";
    } else if (billToParty.equalsIgnoreCase("N")) {
        billToPartyAc = null != lclBooking.getNotyAcct() ? lclBooking.getNotyAcct().getAccountno() : "";
        billToPartyAcctName = null != lclBooking.getNotyAcct() ? lclBooking.getNotyContact().getCompanyName()
                : "";
    } else if (billToParty.equalsIgnoreCase("T")) {
        billToPartyAc = null != lclBooking.getThirdPartyAcct() ? lclBooking.getThirdPartyAcct().getAccountno()
                : "";
        billToPartyAcctName = null != lclBooking.getThirdPartyAcct()
                ? lclBooking.getThirdPartyAcct().getAccountName()
                : "";
    }

    originValues.append(lclUtils.getConcatenatedOriginByUnlocation(lclBooking.getPortOfLoading()));
    destinationValues.append(lclUtils.getConcatenatedOriginByUnlocation(lclBooking.getPortOfDestination()));
    if (lclBooking.getTerminal() != null) {
        RefTerminal terminal = new TerminalDAO()
                .findByTerminalNo(String.valueOf(lclBooking.getTerminal().getTrmnum()));
        trmname = null != terminal ? terminal.getTerminalLocation() : "";
        if (trmname.equalsIgnoreCase("IMPRTS LOS ANGELES")) {
            trmname = "Los Angeles";
        }
        trmAddress = null != terminal ? terminal.getAddres1() : "";
        trmZip = null != terminal ? terminal.getZipcde() : "";
    }
    customerPo = new Lcl3pRefNoDAO().getCustomerPo(fileId);
    CustAddress custAddress = new CustAddressDAO().findByAccountNo(billToPartyAc);
    if (custAddress != null) {
        consAddress.append(billToPartyAcctName).append("\n");
        consAddress.append(custAddress.getAddress1()).append("\n");
        consAddress.append(custAddress.getCity1()).append(" ").append(custAddress.getState()).append(" ")
                .append(custAddress.getZip());
    }
    List<LclBookingPiece> lclBookingPiece = lclBookingPieceDAO.findByProperty("lclFileNumber.id",
            Long.parseLong(fileId));
    LclFileNumber lclFileNumber = new LclFileNumberDAO().getByProperty("id", Long.parseLong(fileId));
    if (lclBookingPiece != null && !lclBookingPiece.isEmpty()
            && CommonUtils.isNotEmpty(lclBookingPiece.get(0).getLclBookingPieceUnitList())) {
        unitNo = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclUnit()
                .getUnitNo();
        masterBl = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclUnit()
                .getLclUnitSsManifestList().get(0).getMasterbl();
        vesselEtd = lclBookingPiece.get(0).getLclBookingPieceUnitList().get(0).getLclUnitSs().getLclSsHeader()
                .getLclSsDetailList().get(0).getSta();
    }
    Boolean isSegregationFlag = new LclBookingSegregationDao().isCheckedSegregationDr(Long.parseLong(fileId));
    if (isSegregationFlag) {
        amsHouseBl = new LclBookingImportAmsDAO().getAmsNo(fileId);
    } else {
        amsHouseBl = new LclBookingImportAmsDAO().getAmsNoGroup(fileId);
    }
    if (lclFileNumber.getLclBookingImport() != null) {
        subHouseBl = lclFileNumber.getLclBookingImport().getSubHouseBl();
        pickUpDate = lclFileNumber.getLclBookingImport().getPickupDateTime();
    }
    PdfPCell cell = new PdfPCell();
    PdfPTable mainTable = makeTable(2);
    mainTable.setWidthPercentage(100f);
    PdfPTable clientPTable = new PdfPTable(5);
    clientPTable.setWidthPercentage(100f);
    clientPTable.setWidths(new float[] { 25, 25, 17, 11, 22 });
    clientPTable.setKeepTogether(true);
    cell = makeCell("BILL TO ACCOUNT NO.", Element.ALIGN_LEFT, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    clientPTable.addCell(cell);
    cell = makeCell("" + billToPartyAc, Element.ALIGN_LEFT, blackFontForFclAr, 0);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    clientPTable.addCell(cell);

    cell = makeCell("INVOICE NO.", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    clientPTable.addCell(cell);
    cell = makeCell("DATE", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthBottom(0.06f);
    clientPTable.addCell(cell);
    cell = makeCell("BILLING TM", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthBottom(0.06f);
    clientPTable.addCell(cell);

    cell = makeCell("" + consAddress.toString(), Element.ALIGN_LEFT, blackFontForFclAr, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    clientPTable.addCell(cell);

    //INVOICE NO
    cell = makeCell(fileNumber, Element.ALIGN_CENTER, blackFontForFclBl, 0);
    clientPTable.addCell(cell);

    //DATE
    String acctNumber = checkPayment(billToPartyAc);
    if (!acctNumber.equals("noCredit")) {
        if (CommonFunctions.isNotNull(acctNumber) && !acctNumber.equals("") && pickUpDate != null) {
            cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(pickUpDate), Element.ALIGN_CENTER,
                    blackFontForFclBl, 0);
        } else if (pickUpDate == null && vesselEtd != null) {
            cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(vesselEtd), Element.ALIGN_CENTER,
                    blackFontForFclBl, 0);
        } else {
            cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        }
    } else if (acctNumber.equals("noCredit") && vesselEtd != null) {
        cell = makeCell(DateUtils.formatStringDateToAppFormatMMM(vesselEtd), Element.ALIGN_CENTER,
                blackFontForFclBl, 0);
    } else {
        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    }
    cell.setBorderWidthLeft(0.06f);
    clientPTable.addCell(cell);

    //BILLING TM
    cell = makeCell(trmname, Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setBorderWidthLeft(0.06f);
    clientPTable.addCell(cell);

    cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    clientPTable.addCell(cell);

    cell = makeCell("CUSTOMER REF NO.", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setColspan(3);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    clientPTable.addCell(cell);

    cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    clientPTable.addCell(cell);
    //CUSTOMER REF NO.
    cell = makeCell(customerPo, Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setColspan(3);
    cell.setMinimumHeight(15f);
    cell.setBorderWidthLeft(0.06f);
    clientPTable.addCell(cell);

    cell = new PdfPCell();
    cell.addElement(clientPTable);
    cell.setColspan(5);
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    mainTable.addCell(cell);

    PdfPTable othersTable = makeTable(4);
    othersTable.setWidthPercentage(100f);
    othersTable.setWidths(new float[] { 25, 25, 25, 25 });
    cell = makeCell("CONTAINER NO.", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("ECI SHIPMENT FILE NO.", Element.ALIGN_CENTER, blackBoldFontSize6, 0,
            Color.decode("#c5d9f1"));
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("ORIGIN", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("DESTINATION", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthTop(0.06f);
    othersTable.addCell(cell);
    //CONTAINER NO
    cell = makeCell("" + unitNo, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //ECI SHIPMENT FILE NO
    cell = makeCell("IMP-" + fileNumber, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //ORIGIN
    cell = makeCell("" + originValues, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //DESTINATION
    cell = makeCell("" + destinationValues, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);

    cell = makeCell("MBL / AWB NUMBER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("AMS HOUSE BL", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("SUB HOUSE BL", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    //MBL / AWB NUMBER
    cell = makeCell("" + masterBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //amsHouseBl
    cell = makeCell(amsHouseBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //subHouseBl
    cell = makeCell(subHouseBl, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);

    cell = makeCell("SHIPPER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    cell = makeCell("FORWARDER", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    //SHIPPER
    cell = makeCell(shipName, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //FORWARDER
    cell = makeCell(forwName, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);

    cell = makeCell("CONSIGNEE", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);

    cell = makeCell("NOTIFY PARTY", Element.ALIGN_CENTER, blackBoldFontSize6, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    othersTable.addCell(cell);
    //CONSIGNEE
    cell = makeCell(consName, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);
    //NOTIFY PARTY
    cell = makeCell(notyName, Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(2);
    cell.setMinimumHeight(20f);
    cell.setBorderWidthRight(0.06f);
    othersTable.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(2);
    cell.addElement(othersTable);
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    mainTable.addCell(cell);

    Font boldHeadingFon = FontFactory.getFont("Arial", 7f, Font.BOLD);
    Paragraph p = null;

    PdfPTable othersTable1 = makeTable(5);
    othersTable1.setWidthPercentage(100f);
    othersTable1.setWidths(new float[] { 2f, 1f, 4f, 1.3f, 1.3f });
    //marks     
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    p = new Paragraph(7f, "MARKS AND NUMBERS", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);
    //no of pkgs
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "NO.OF.PKGS", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);
    //desc
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "DESCRIPTION OF PACKAGES AND GOODS", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);
    //grossweight
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "GROSS WEIGHT", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);
    //measure
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "MEASURE", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    othersTable1.addCell(cell);

    //        List<LclBookingPiece> lclBookingPiecesList = null;
    //        lclBookingPiecesList = lclBookingPieceDAO.findByProperty("lclFileNumber.id", Long.parseLong(fileId));
    if (lclBookingPiece != null && lclBookingPiece.size() > 0) {
        for (LclBookingPiece lclBookingPieces : lclBookingPiece) {
            //MARKS AND NUMBERS
            cell = new PdfPCell();
            cell.setBorder(0);
            if (lclBookingPieces != null && lclBookingPieces.getMarkNoDesc() != null
                    && !lclBookingPieces.getMarkNoDesc().equals("")) {
                p = new Paragraph(7f, "" + lclBookingPieces.getMarkNoDesc().toUpperCase(),
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
            //NO.OF.PKGS
            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedPieceCount() != null
                    && lclBookingPieces.getPackageType().getAbbr01() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedPieceCount() + " "
                        + lclBookingPieces.getPackageType().getAbbr01(), blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
            //DESCRIPTION OF PACKAGES AND GOODS
            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getPieceDesc() != null
                    && !lclBookingPieces.getPieceDesc().equals("")) {
                p = new Paragraph(7f, "" + lclBookingPieces.getPieceDesc().toUpperCase(),
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            //grossweight
            cell = new PdfPCell();

            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedWeightMetric() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedWeightMetric() + " KGS",
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
            //measure
            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedVolumeMetric() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedVolumeMetric() + " CBM",
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
            //2nd cell
            cell = new PdfPCell();
            cell.setBorder(0);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);

            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            //3rd cell
            cell = new PdfPCell();
            cell.setBorder(0);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            p = new Paragraph(7f, "", blackNormalCourierFont8f);
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedWeightImperial() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedWeightImperial() + " LBS",
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);

            cell = new PdfPCell();
            cell.setBorder(0);
            cell.setBorderWidthLeft(0.6f);
            if (lclBookingPieces != null && lclBookingPieces.getBookedVolumeImperial() != null) {
                p = new Paragraph(7f, "" + lclBookingPieces.getBookedVolumeImperial() + " CFT",
                        blackNormalCourierFont8f);
            } else {
                p = new Paragraph(7f, "", blackNormalCourierFont8f);
            }
            p.setAlignment(Element.ALIGN_CENTER);
            cell.addElement(p);
            othersTable1.addCell(cell);
        }

    }

    cell = new PdfPCell();
    cell.setColspan(5);
    cell.addElement(othersTable1);
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthTop(0.06f);
    mainTable.addCell(cell);

    PdfPTable chargesTable = makeTable(4);
    chargesTable.setWidthPercentage(100.5f);
    chargesTable.setWidths(new float[] { 45, 35, 5, 15 });
    cell = makeCell("DESCRIPTION", Element.ALIGN_CENTER, headingFont, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthBottom(0.06f);
    cell.setColspan(2);
    chargesTable.addCell(cell);
    cell = makeCell("CHARGES", Element.ALIGN_CENTER, headingFont, 0, Color.decode("#c5d9f1"));
    cell.setColspan(2);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    chargesTable.addCell(cell);

    NumberFormat number = new DecimalFormat("###,###,##0.00");
    String code = "";
    //        double totalCharges = 0.00;
    double lateFee = 0.00;
    double payAmount = 0.00;
    int chargeCount = 0;
    double total = 0.00;
    String[] billToPartyA;
    billToPartyA = new String[] { "C", "N", "T" };
    List<String> billtoPartyList = Arrays.asList(billToPartyA);
    List<BookingChargesBean> lclBookingAcList = null;
    lclBookingAcList = new LclCostChargeDAO().findBybookingAcId(fileId, billtoPartyList);
    for (int j = 0; j < lclBookingAcList.size(); j++) {
        chargeCount++;
        BookingChargesBean lclBookingAc = (BookingChargesBean) lclBookingAcList.get(j);

        String codeDesc = "";

        code = CommonUtils.isNotEmpty(lclBookingAc.getChargeCode()) ? lclBookingAc.getChargeCode() : "";
        codeDesc = new GenericCodeDAO().getGenericCodeDesc(code);

        if (CommonUtils.isNotEmpty(lclBookingAc.getChargeCode())) {
            //                    String desc = lclBookingAc.getChargeCode().toUpperCase();

            cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl);
            cell.setBorderWidthRight(0.0f);
        }

        if (chargeCount == 1) {
            cell.setBorderWidthTop(0.0f);
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthLeft(0.0f);
            cell.setBorderWidthBottom(0.0f);
        } else {
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthLeft(0.0f);
            cell.setBorderWidthBottom(0.0f);
        }
        chargesTable.addCell(cell);

        if (CommonUtils.isNotEmpty(codeDesc)) {
            cell = makeCell("" + codeDesc, Element.ALIGN_LEFT, blackFontForFclBl, 0.06f);
            cell.setBorderWidthLeft(0.0f);
        } else {
            cell = makeCell("" + code, Element.ALIGN_LEFT, blackFontForFclBl, 0.06f);
            cell.setBorderWidthLeft(0.0f);
        }
        if (chargeCount == 1) {
            cell.setBorderWidthTop(0.0f);
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        } else {
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        }

        chargesTable.addCell(cell);

        cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f);//3
        if (chargeCount == 1) {
            cell.setBorderWidthTop(0.0f);
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        } else {
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        }
        chargesTable.addCell(cell);
        cell = makeCell(number.format(lclBookingAc.getTotalAmt().doubleValue()), Element.ALIGN_RIGHT,
                blackFontForFclBl, Rectangle.BOX);//4
        if (chargeCount == 1) {
            cell.setBorderWidth(0.0f);
        } else {
            cell.setBorderWidthLeft(0.0f);
            cell.setBorderWidthRight(0.0f);
            cell.setBorderWidthBottom(0.0f);
        }
        chargesTable.addCell(cell);
        total = total + lclBookingAc.getTotalAmt().doubleValue();

    }

    for (int i = 0; i < (14 - chargeCount); i++) {
        //            chargesTable.addCell(makeCellLeftNoBorderFclBL(""));
        //            chargesTable.addCell(makeCellRightNoBorderFclBL(""));
        cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0.06f);
        cell.setBorderWidthRight(0.0f);
        cell.setBorderWidthBottom(0.0f);
        cell.setBorderWidthLeft(0.0f);
        chargesTable.addCell(cell);

        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f);
        cell.setBorderWidthRight(0.0f);
        cell.setBorderWidthBottom(0.0f);
        cell.setBorderWidthLeft(0.0f);
        chargesTable.addCell(cell);
        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0.06f);
        cell.setBorderWidthRight(0.0f);
        cell.setBorderWidthBottom(0.0f);
        chargesTable.addCell(cell);
        cell = makeCell("", Element.ALIGN_RIGHT, blackFontForFclBl, 0.06f);
        cell.setBorderWidthLeft(0.0f);
        cell.setBorderWidthRight(0.0f);
        cell.setBorderWidthBottom(0.0f);
        cell.setMinimumHeight(10f);
        chargesTable.addCell(cell);
    }
    cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0);
    cell.setBorderWidthTop(0.06f);
    chargesTable.addCell(cell);
    cell = makeCell("INVOICE TOTAL", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    //        cell.setPaddingLeft(-15f);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthRight(0.06f);
    chargesTable.addCell(cell);
    cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    chargesTable.addCell(cell);
    cell = makeCell(number.format(total), Element.ALIGN_RIGHT, blackFontForFclBl, 0);//4
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthBottom(0.06f);
    chargesTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setColspan(4);
    chargesTable.addCell(cell);
    chargesTable.setKeepTogether(true);
    cell = new PdfPCell();
    cell.setColspan(2);
    cell.addElement(chargesTable);
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    mainTable.addCell(cell);
    //        
    payAmount = total;
    //        String acctNumber = checkPayment(billToPartyAc);
    boolean lateFeeFlag = false;
    TradingPartnerBC tradingPartnerBC = new TradingPartnerBC();
    TradingPartner tradingPartner = null;
    //        SimpleDateFormat simpDate = new SimpleDateFormat("dd-MMM-yyyy");
    PdfPTable paidTable = makeTable(6);
    paidTable.setWidthPercentage(100.5f);
    paidTable.setWidths(new float[] { 30, 15, 25, 10, 5, 15 });
    if (CommonFunctions.isNotNull(acctNumber) && !acctNumber.equals("") && !acctNumber.equals("noCredit")) {
        tradingPartner = tradingPartnerBC.findTradingPartnerById(acctNumber);
        if (CommonFunctions.isNotNullOrNotEmpty(tradingPartner.getAccounting())) {
            for (Iterator accountingList = tradingPartner.getAccounting().iterator(); accountingList
                    .hasNext();) {
                CustomerAccounting customerAccounting = (CustomerAccounting) accountingList.next();
                if (null != customerAccounting.getLclApplyLateFee()
                        && customerAccounting.getLclApplyLateFee().equals("on")) {
                    lateFeeFlag = true;
                }
                break;
            }
        }
    }

    cell = makeCell("ARRIVAL DATE", Element.ALIGN_CENTER, headingFontSize8, 0, Color.decode("#c5d9f1"));
    cell.setBorderWidthTop(0.06f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthBottom(0.06f);
    paidTable.addCell(cell);

    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
    String outDate = "";
    String crtDate = "";

    if (vesselEtd != null) { //vessel arrivalDate         
        outDate = sdf.format(vesselEtd);
    }
    cell = makeCell("", Element.ALIGN_LEFT, blackFontForFclBl, 0);
    paidTable.addCell(cell);
    CustomerAccounting customerAccounting = new CustomerAccountingDAO().findByProperty("accountNo",
            billToPartyAc);

    if (customerAccounting != null && (customerAccounting.getCreditRate() != null
            && (CommonUtils.isNotEmpty(outDate)) && !acctNumber.equals("noCredit"))) {
        Calendar c = Calendar.getInstance();
        //            c.setTime(new Date(outDate)); //  Removed Deprecated Warning
        c.setTime(sdf.parse(outDate)); //   Now use previous date.
        if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 7 Days")) {
            c.add(Calendar.DATE, 7);
            crtDate = sdf.format(c.getTime());// Adding 7 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 15 Days")) {
            c.add(Calendar.DATE, 15);
            crtDate = sdf.format(c.getTime());// Adding 15 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("NET 21 DAYS")) {
            c.add(Calendar.DATE, 21);
            crtDate = sdf.format(c.getTime());// Adding 21 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 30 Days")) {
            c.add(Calendar.DATE, 30);
            crtDate = sdf.format(c.getTime());// Adding 30 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 45 Days")) {
            c.add(Calendar.DATE, 45);
            crtDate = sdf.format(c.getTime());// Adding 45 days
        } else if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Net 60 Days")) {
            c.add(Calendar.DATE, 60);
            crtDate = sdf.format(c.getTime());// Adding 60 days
        }
    }

    if (lateFeeFlag) {
        lateFee = total * 0.015; // 1.5percent calculate
        payAmount = total + lateFee;
        cell = makeCell("LATE FEE IF NOT PAID BY - " + crtDate, Element.ALIGN_LEFT, blackFontForFclBl, 0);
        cell.setColspan(2);
        cell.setBorderWidthTop(0.06f);
        cell.setBorderWidthLeft(0.06f);
        paidTable.addCell(cell);

        cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setBorderWidthTop(0.06f);
        cell.setBorderWidthLeft(0.06f);
        paidTable.addCell(cell);
        cell = makeCell(number.format(lateFee), Element.ALIGN_RIGHT, blackFontForFclBl, 0);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);

        cell = makeCell(outDate, Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setMinimumHeight(10f);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthRight(0.06f);
        paidTable.addCell(cell);

        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        paidTable.addCell(cell);

        cell = makeCell("PAY THIS AMOUNT IF NOT PAID BY DUE DATE", Element.ALIGN_LEFT, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        cell.setColspan(2);
        paidTable.addCell(cell);
        cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);
        cell = makeCell(number.format(payAmount), Element.ALIGN_RIGHT, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);
    } else {
        //            String dueDate = "";
        //            if(arRedInvoice.getDueDate() != null){
        //            SimpleDateFormat sdfa = new SimpleDateFormat("dd-MMM-yyyy");
        //            dueDate = sdfa.format(arRedInvoice.getDueDate());
        //        }

        //            cell = makeCell(!"".equals(dueDate) ? "PAY THIS AMOUNT IF NOT PAID BY - " + dueDate : "PLEASE PAY THIS AMOUNT",Element.ALIGN_LEFT, blackFontForFclBl, 0);
        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setColspan(4);
        paidTable.addCell(cell);

        cell = makeCell(outDate, Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setMinimumHeight(10f);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthRight(0.06f);
        paidTable.addCell(cell);

        cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        paidTable.addCell(cell);

        cell = makeCell("PLEASE PAY THIS AMOUNT - " + crtDate, Element.ALIGN_LEFT, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        cell.setColspan(2);
        paidTable.addCell(cell);
        cell = makeCell("$", Element.ALIGN_CENTER, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthLeft(0.06f);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);
        cell = makeCell(number.format(total), Element.ALIGN_RIGHT, blackFontForFclBl, 0);
        cell.setBorderWidthBottom(0.06f);
        cell.setBorderWidthTop(0.06f);
        paidTable.addCell(cell);
    }
    cell = makeCell("", Element.ALIGN_CENTER, blackFontForFclBl, 0);
    cell.setColspan(5);
    paidTable.addCell(cell);

    //paidTable.setKeepTogether(true);
    cell = new PdfPCell();
    cell.setColspan(2);
    cell.addElement(paidTable);
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    mainTable.addCell(cell);

    ///end of description & charges
    //        String paymentStatment = "";
    //        paymentStatment = checkPayment(arRedInvoice);
    PdfPTable commandTable = new PdfPTable(1);
    commandTable.setWidthPercentage(100);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);

    if (customerAccounting != null
            && (customerAccounting.getCreditRate() != null && (CommonUtils.isNotEmpty(outDate)))) {
        if ((customerAccounting.getCreditRate().getCodedesc()).equalsIgnoreCase("Due Upon Receipt")) {
            cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT", Element.ALIGN_CENTER, blackFontForFclBl, 0,
                    Color.decode("#FFFF00"));
            commandTable.addCell(cell);
        } else {
            cell = makeCell("INVOICE PAYABLE ON OR BEFORE  " + (crtDate), Element.ALIGN_CENTER,
                    new Font(Font.HELVETICA, 10, Font.BOLDITALIC, Color.BLACK), Rectangle.NO_BORDER);
            commandTable.addCell(cell);
        }
    } else {
        cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT", Element.ALIGN_CENTER, blackFontForFclBl, 0,
                Color.decode("#FFFF00"));
        commandTable.addCell(cell);
    }
    //        if (lateFeeFlag == false) {//if(paymentStatment.equals("noCredit") || lateFeeFlag == false){
    //            cell = makeCell("INVOICE IS PAYABLE UPON RECEIPT OR INVOICE PAYABLE WITHIN 30 DAYS FROM DEPARTURE/ARRIVAL DATE", Element.ALIGN_LEFT, blackFontForFclBl, 0, Color.decode("#FFFF00"));
    //            commandTable.addCell(cell);
    //        } else {
    //            cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    //            commandTable.addCell(cell);
    //        }
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = makeCell("", Element.ALIGN_CENTER, headingFont, Rectangle.NO_BORDER);
    commandTable.addCell(cell);
    cell = new PdfPCell();
    cell.setColspan(2);
    cell.addElement(commandTable);
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setExtraParagraphSpace(10f);
    mainTable.addCell(cell);

    PdfPTable bankDetailsTable = makeTable(4);
    bankDetailsTable.setWidthPercentage(100f);
    bankDetailsTable.setWidths(new float[] { 3f, 1f, 4f, 2.6f });

    //
    //        SystemRulesDAO systemRulesDAO = new SystemRulesDAO();
    //        String eftBank = systemRulesDAO.getSystemRulesByCode("EFTBank");
    //        String eftBankAddress = systemRulesDAO.getSystemRulesByCode("EFTBankAddress");
    //        String eftABANo = systemRulesDAO.getSystemRulesByCode("EFTABANo");
    //        String eftAcctName = systemRulesDAO.getSystemRulesByCode("EFTAcctName");
    //        String eftAccountNo = systemRulesDAO.getSystemRulesByCode("EFTAccountNo");
    //        CompanyModel company = systemRulesDAO.getCompanyDetails();

    //PAYMENT METHODS
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthRight(0.6f);
    cell.setBorderWidthTop(0.6f);
    p = new Paragraph(7f, "PAYMENT METHODS", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    bankDetailsTable.addCell(cell);
    // Empty

    cell = makeCell("", Element.ALIGN_CENTER, blackBoldFontSize6, 0);
    cell.setColspan(3);
    cell.setBorderWidthBottom(0.06f);
    bankDetailsTable.addCell(cell);

    //Via Check
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setColspan(2);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "Via Check", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    bankDetailsTable.addCell(cell);
    //Via ACH or Wire Transfer
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "Via ACH or Wire Transfer", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    bankDetailsTable.addCell(cell);
    //Credit Card Payments
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthBottom(0.6F);
    cell.setBorderWidthLeft(0.6f);
    p = new Paragraph(7f, "Credit Card Payments", boldHeadingFon);
    p.setAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(Color.decode("#c5d9f1"));
    cell.addElement(p);
    bankDetailsTable.addCell(cell);

    // Via Check Details
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthBottom(0.06f);
    cell.setColspan(2);
    p = new Paragraph(10f, "PLEASE REMIT PAYMENT TO", boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);

    p = new Paragraph(10f, companyName, boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    String creditStatusDomain = "";
    if (null != customerAccounting && null != customerAccounting.getCreditStatus()) {//no credit
        creditStatusDomain = customerAccounting.getCreditStatus().getCodedesc();
        if (!("No Credit").equalsIgnoreCase(creditStatusDomain)) {
            p = new Paragraph(10f, "2401 N.W. 69TH STREET", boldHeadingFon);
            p.setAlignment(Element.ALIGN_LEFT);
            cell.addElement(p);
            p = new Paragraph(10f, "Miami, FL  33147", boldHeadingFon);
            p.setAlignment(Element.ALIGN_LEFT);
            cell.addElement(p);
            bankDetailsTable.addCell(cell);
        } else {
            p = new Paragraph(10f, "" + trmAddress, boldHeadingFon);
            p.setAlignment(Element.ALIGN_LEFT);
            cell.addElement(p);
            p = new Paragraph(10f, "" + trmname + " " + trmZip, boldHeadingFon);
            p.setAlignment(Element.ALIGN_LEFT);
            cell.addElement(p);
            bankDetailsTable.addCell(cell);
        }
    }

    //Via ACH or Wire Transfer Details

    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    p = new Paragraph(10f, "Bank: " + company.getBankName(), boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, company.getBankAddress(), boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, "ABA: " + company.getBankAbaNumber(), boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, "ACCT: " + companyName, boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, "ACCOUNT NO: " + company.getBankAccountNumber(), boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    bankDetailsTable.addCell(cell);

    //Credit Card Payments Details
    cell = new PdfPCell();
    cell.setBorder(0);
    cell.setBorderWidthRight(0.06f);
    p = new Paragraph(10f, "If paying via Credit card", boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, " Please go to:", boldHeadingFon);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    p = new Paragraph(10f, webSite, fileNoFont);
    p.setAlignment(Element.ALIGN_LEFT);
    cell.addElement(p);
    bankDetailsTable.addCell(cell);

    cell = new PdfPCell();
    cell.setColspan(4);
    cell.addElement(bankDetailsTable);
    cell.setBorder(0);
    cell.setPadding(0f);
    cell.setBorderWidthRight(0.06f);
    cell.setBorderWidthLeft(0.06f);
    cell.setBorderWidthBottom(0.06f);
    mainTable.addCell(cell);

    document.add(mainTable);

}

From source file:com.krawler.esp.servlets.ExportMPXServlet.java

License:Open Source License

public static void addPdfRowToTable(String[] values, PdfPTable tab, Font fnt, int lvl) {
    for (int i = 0; i < values.length; i++) {
        PdfPCell cell = new PdfPCell(new Paragraph(values[i], fnt));
        if (values[i].compareTo("") == 0) {
            cell.setMinimumHeight(16); // Setting minimum height for cell when no data is present
        }//from ww  w.j  a  v a 2  s.c  o m
        if (i == 1 && lvl != 0) {
            cell.setIndent((lvl * 10));
        }
        tab.addCell(cell);
    }
}

From source file:com.krawler.esp.servlets.ExportProjectReportServlet.java

License:Open Source License

private int addTableTimeLine(int stcol, int stpcol, int strow, int stprow, JSONArray store, String[] colwidth2,
        int maxlevel, Document document) throws JSONException, DocumentException {
    float[] f = new float[(stpcol - stcol) + 1];
    for (int k = 0; k < f.length; k++) {
        f[k] = 20;/* w ww  . j  a v a2 s. c om*/
    }
    f[0] = f[0] + 10 * maxlevel;
    PdfPTable table = new PdfPTable(f);

    java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));

    Font font = FontFactory.getFont("Helvetica", 8, Font.BOLD, tColor);
    Font font1 = FontFactory.getFont("Helvetica", 8, Font.NORMAL, tColor);
    Font f1;

    table.setWidthPercentage(90);
    PdfPCell h2 = new PdfPCell(new Paragraph("Name", font)); // new
    if (config.getBoolean("gridBorder"))
        h2.setBorder(PdfPCell.BOX);
    else
        h2.setBorder(0);
    h2.setPadding(2);
    //                h2.setHorizontalAlignment(Element.ALIGN_UNDEFINED);
    // Paragraph(colwidth2[hcol],font);
    table.addCell(h2);
    int stpcol1 = 0;
    for (int hcol = stcol; hcol < stpcol; hcol++) {
        PdfPCell h1 = new PdfPCell(new Paragraph(colwidth2[hcol], font)); // new
        h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
        if (config.getBoolean("gridBorder"))
            h1.setBorder(PdfPCell.BOX);
        else
            h1.setBorder(0);
        h1.setPadding(2);
        // Paragraph(colwidth2[hcol],font);
        table.addCell(h1);
    }
    table.setHeaderRows(1);

    for (int row = strow; row < stprow; row++) {
        if (row % 62 == 61) {
            document.add(table);
            table.deleteBodyRows();
            table.setSkipFirstHeader(true);
        }
        if (store.getJSONObject(row).getBoolean("flag"))
            f1 = font;
        else
            f1 = font1;
        if (store.getJSONObject(row).getString("info").compareTo("") != 0) {
            h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1));
            //                    h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5);
        } else {
            h2 = new PdfPCell(new Paragraph(store.getJSONObject(row).getString("info"), f1));
            //                    h2.setPaddingTop(9);
            //                    h2.setPaddingLeft((Integer.parseInt(store.getJSONObject(row).getString("level")) * 10) + 5);
        }

        //                h2.setBorder(0);
        //                h2.setPadding(1);
        //                Color bColor = Color.decode("DDDDDD");

        if (config.getBoolean("gridBorder")) {
            if (store.getJSONObject(row).getBoolean("flag")) {
                h2.setBackgroundColor(new Color(0xEEEEEE));
                h2.setBorder(PdfPCell.LEFT | PdfPCell.BOTTOM);
            } else
                h2.setBorder(PdfPCell.BOX);
        } else {
            h2.setBorder(0);
        }
        h2.setPadding(2);
        h2.setBorderColor(Color.GRAY);
        if (store.getJSONObject(row).getBoolean("flag"))
            h2.setHorizontalAlignment(Element.ALIGN_LEFT);
        else
            h2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        h2.setVerticalAlignment(Element.ALIGN_CENTER);
        table.addCell(h2);
        for (int col = stcol; col < stpcol; col++) {
            Paragraph para = new Paragraph(store.getJSONObject(row).getString(colwidth2[col]), f1);
            PdfPCell h1 = new PdfPCell(para);
            //                    h1.setBorder(0);
            //                    h1.setPadding(1);

            h1.setMinimumHeight(15);
            h1.setHorizontalAlignment(Element.ALIGN_RIGHT);
            h1.setVerticalAlignment(Element.ALIGN_CENTER);
            if (config.getBoolean("gridBorder")) {
                if (store.getJSONObject(row).getBoolean("flag")) {
                    h1.setBorder(PdfPCell.BOTTOM);
                    h1.setBackgroundColor(new Color(0xEEEEEE));
                    if (col == stpcol - 1)
                        h1.setBorder(PdfPCell.BOTTOM | PdfPCell.RIGHT);
                } else
                    h1.setBorder(PdfPCell.BOX);
            } else {
                h1.setBorder(0);
            }
            h1.setPadding(2);
            h1.setBorderColor(Color.GRAY);
            table.addCell(h1);
            //               table.addCell(new Paragraph(store.getJSONObject(row)
            //                     .getString(colwidth2[col]), f1));
        }

    }
    document.add(table);
    document.newPage();
    if (stpcol != colwidth2.length) {
        if ((colwidth2.length - stpcol) > 5) // column limit
            stpcol1 = stpcol + 5;
        else
            stpcol1 = (colwidth2.length - stpcol) + stpcol;
        addTableTimeLine(stpcol, stpcol1, strow, stprow, store, colwidth2, maxlevel, document);
    }

    return stpcol;
}

From source file:fr.opensagres.xdocreport.itext.extension.TableWithVerticalAlignment.java

License:Open Source License

public static void main(String[] args) {
    Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    try {/*from  ww  w  .j  ava2 s.co  m*/
        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream("TableWithVerticalAlignment.pdf"));

        document.open();

        PdfPTable table = new PdfPTable(1);
        // PdfPCell cell1 = new PdfPCell();
        // cell1.setVerticalAlignment( Element.ALIGN_BOTTOM );
        // //cell1.setMinimumHeight( 100f );
        // cell1.addElement( new Chunk( "cell1" ) );
        // table.addCell( cell1 );

        PdfPCell cell2 = new PdfPCell();
        Paragraph p = new Paragraph();
        p.add(new Chunk("cellp&"));

        cell2.addElement(p);
        cell2.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell2.setMinimumHeight(38f);
        table.addCell(cell2);

        document.add(table);
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:open.dolphin.hiro.PrescriptionPDFMaker.java

/**
 * ??/*  w  ww . ja va 2 s.  c  o  m*/
 */
public String output() {
    BufferedOutputStream bos;
    PdfWriter pw = null;
    Document document = null;

    try {
        Date dateNow = new Date();

        // ID
        String patientId = pkg.getPatientId();

        // ???
        String name = pkg.getPatientName();
        name = name.replaceAll(" ", "");
        name = name.replaceAll("", "");

        String iNum; // ??
        String piNum = null; // ?
        String rNum = null; // ??

        String piNum2 = null; // ?
        String rNum2 = null; // ??

        String div = ""; // ?
        String payRatio = ""; // ?

        String mNum = ""; // ???

        char[] iNumC = new char[8]; // ???
        char[] piNumC = new char[8]; // ??
        char[] rNumC = new char[7]; // ??
        char[] piNumC2 = new char[8]; // ??
        char[] rNumC2 = new char[7]; // ??
        DecimalFormat df = new DecimalFormat("#0.#"); // ??
        String paymentRatio = ""; // ?
        String paymentRatio2 = ""; // ?

        if (pkg.getApplyedInsurance().getInsuranceNumber() != null) {

            // ??
            iNum = pkg.getApplyedInsurance().getInsuranceNumber();

            // ? null ??
            if (iNum.toLowerCase().startsWith("z") || iNum.equals("9999")) {
                iNum = null;
            }

            // 
            if (pkg.getApplyedInsurance().getPVTPublicInsuranceItem() != null) {
                PVTPublicInsuranceItemModel[] pubItems = pkg.getApplyedInsurance().getPVTPublicInsuranceItem();
                for (int i = 0; i < pubItems.length; i++) {
                    PVTPublicInsuranceItemModel pm = pubItems[i];
                    if (i == 0) {
                        // ?
                        piNum = pm.getProvider();
                        piNum = ("mikinyu".equals(piNum)) ? "" : piNum;

                        // ??
                        rNum = pm.getRecipient();
                        rNum = ("mikinyu".equals(rNum)) ? "" : rNum;

                        // ???
                        paymentRatio = pm.getPaymentRatio();
                    } else if (i == 1) {
                        piNum2 = pm.getProvider();
                        piNum2 = ("mikinyu".equals(piNum2)) ? "" : piNum2;

                        rNum2 = pm.getRecipient();
                        rNum2 = ("mikinyu".equals(rNum2)) ? "" : rNum2;

                        paymentRatio2 = pm.getPaymentRatio();
                        break;
                    }
                }
            }

            // ? ?? ?
            StringBuilder sb = new StringBuilder();

            // ? ?
            if (pkg.getApplyedInsurance().getClientGroup() != null
                    && !pkg.getApplyedInsurance().getClientGroup().equals("??")) {
                sb.append(pkg.getApplyedInsurance().getClientGroup()).append("");
            }
            // ??
            if (pkg.getApplyedInsurance().getClientNumber() != null
                    && !pkg.getApplyedInsurance().getClientNumber().equals("??")) {
                sb.append(pkg.getApplyedInsurance().getClientNumber());
            }
            mNum = sb.length() > 0 ? sb.toString() : "";

            // 
            if ("?".equals(pkg.getApplyedInsurance().getInsuranceClass())) {
                div = "";
                payRatio = paymentRatio;
            } else {
                // ?
                div = "true".equals(pkg.getApplyedInsurance().getFamilyClass()) ? "?"
                        : "";
                payRatio = pkg.getApplyedInsurance().getPayOutRatio();
            }
            if (payRatio != null && !("".equals(payRatio))) {
                payRatio = df.format(Double.valueOf(payRatio) * 10);
            }

            if (DEBUG) {
                System.err.println("iNum=" + iNum);
                System.err.println("piNum=" + piNum);
                System.err.println("rNum=" + rNum);
                System.err.println("piNum2=" + piNum2);
                System.err.println("rNum2=" + rNum2);
                System.err.println("mNum=" + mNum);
                System.err.println("?=" + div);
                System.err.println("=" + payRatio);
            }

            // ???
            iNumC = partitionPadRL(iNum, 8, "R"); // ??
            piNumC = partitionPadRL(piNum, 8, "L"); // ?
            rNumC = partitionPadRL(rNum, 7, "L"); // ??
            piNumC2 = partitionPadRL(piNum2, 8, "L"); // ?2
            rNumC2 = partitionPadRL(rNum2, 7, "L"); // ??2
        }
        /*****  *****/

        document = new Document(PageSize.A5, 10, 10, 2, 2);
        // @002 2009/11/17 
        // ?PDF????????
        if (getDocumentDir() == null) {
            StringBuilder sb = new StringBuilder();
            sb.append(System.getProperty("user.dir"));
            sb.append(File.separator);
            sb.append(DIR_NAME);
            setDocumentDir(sb.toString());
        }
        File dir = new File(getDocumentDir());
        dir.mkdir();

        // ??(?-ID_???_.pdf)
        StringBuilder sb = new StringBuilder();
        sb.append(FILE_NAME_PRE);
        sb.append(patientId).append("_").append(name).append("_");
        sb.append(new SimpleDateFormat("yyyyMMddHHmmss").format(dateNow));
        sb.append(FILE_EXTENTION);
        setFileName(sb.toString());

        sb = new StringBuilder();
        if (getDocumentDir() != null) {
            sb.append(getDocumentDir());
            sb.append(File.separator);
        }
        sb.append(getFileName());
        pathToPDF = sb.toString();

        //minagawa^ ???water mark?????????? byte[]???            
        ByteArrayOutputStream byteo = new ByteArrayOutputStream();
        bos = new BufferedOutputStream(byteo);
        //minagawa$             
        pw = PdfWriter.getInstance(document, bos);

        // font setting
        bfm = BaseFont.createFont(FONT_HEISEI_MIN3, CODE_UNIJIS_H, BaseFont.NOT_EMBEDDED);
        bfg = BaseFont.createFont(FONT_HEISEI_KAKU5, CODE_UNIJIS_H, BaseFont.NOT_EMBEDDED);
        min_6 = new Font(bfm, 6);
        min_7 = new Font(bfm, 7);
        min_8 = new Font(bfm, 8);
        min_9 = new Font(bfm, 9);
        min_10 = new Font(bfm, 10);
        min_12 = new Font(bfm, 12);
        min_14 = new Font(bfm, 14);
        min_15 = new Font(bfm, 15);
        min_4 = new Font(bfm, 4); // @009

        // 
        document.open();
        document.addAuthor(pkg.getPhysicianName());
        document.addTitle(PROPERTY_TITLE);
        document.addSubject(PROPERTY_SUB_TITLE);

        // ???
        List<PdfPTable> list = createPrescriptionTbl2();
        Iterator<PdfPTable> ite = list.iterator();

        // ?
        int pageNo = 0;
        int totalPageNo = list.size();

        // ?????????
        do {
            PdfPTable ptbl = new PdfPTable(1);
            ptbl.setWidthPercentage(100f);
            ptbl.getDefaultCell().setPadding(0f);
            PdfPCell pcell = new PdfPCell(new Paragraph(REPORT_TITLE, min_15));
            pcell.setBorder(Table.NO_BORDER);
            setAlignCenter(pcell);
            ptbl.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(REPORT_SUB_TITLE, min_7));
            pcell.setBorder(Table.NO_BORDER);
            setAlignCenter(pcell);
            ptbl.addCell(pcell);
            document.add(ptbl);

            ptbl = new PdfPTable(3);
            ptbl.setWidthPercentage(100f);
            ptbl.getDefaultCell().setPadding(0f);
            ptbl.getDefaultCell().setBorder(Table.NO_BORDER);
            float[] widths = { 43.5f, 2f, 54.5f };
            ptbl.setWidths(widths);
            // ?
            pcell = new PdfPCell(new Paragraph(patientId, min_9));
            pcell.setBorder(Table.NO_BORDER);
            pcell.setColspan(10);
            ptbl.addCell(pcell);

            PdfPTable ptblL = new PdfPTable(9);
            ptblL.setSpacingBefore(10f);
            ptblL.setWidthPercentage(100f);
            float[] widthsL = { 33, 8, 8, 8, 8, 8, 8, 8, 8 };
            ptblL.setWidths(widthsL);
            ptblL.getDefaultCell().setPadding(0f);
            pcell = new PdfPCell(new Paragraph("?", min_7));
            pcell.setMinimumHeight(CELL_HIGHT_0);
            setAlignJustifiedAll(pcell);
            setAlignMiddle(pcell);
            pcell.setBorderWidth(LINE_WIDTH_1);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[0]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[1]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[2]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[3]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[4]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_2);
            pcell.setBorderWidthRight(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[5]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthTop(LINE_WIDTH_2);
            pcell.setBorderWidthBottom(LINE_WIDTH_2);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[6]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_2);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setBorderWidthLeft(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[7]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph("???", min_7));
            pcell.setPaddingTop(0.3f);
            setAlignJustifiedAll(pcell);
            pcell.setBorderWidth(LINE_WIDTH_1);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[0]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[1]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[2]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[3]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[4]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[5]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[6]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell();
            pcell.setBorderWidth(LINE_WIDTH_0);
            ptblL.addCell(pcell);

            PdfPTable patientTbl = new PdfPTable(2);
            patientTbl.setWidthPercentage(100f);
            float[] widthsPa = { 7.8f, 92.2f };
            patientTbl.setWidths(widthsPa);
            patientTbl.getDefaultCell().setPadding(0f);
            patientTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell pcellP = new PdfPCell(new Paragraph("", min_7));
            pcellP.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pcellP);
            patientTbl.addCell(pcellP);
            // 
            PdfPTable desc = new PdfPTable(5);
            desc.setWidthPercentage(100f);
            float[] widthsD = { 28.5f, 41.5f, 7, 16, 7 };
            desc.setWidths(widthsD);
            // ???(??)
            PdfPCell patientInfo = new PdfPCell(new Paragraph("???", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(patientInfo);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            PdfPTable nameTbl = new PdfPTable(1);
            nameTbl.setWidthPercentage(100f);
            nameTbl.setSpacingAfter(3f);
            PdfPCell nameCell = new PdfPCell(new Paragraph(pkg.getPatientKana(), min_7));
            nameCell.setBorderWidth(LINE_WIDTH_0);
            nameTbl.addCell(nameCell);
            nameCell = new PdfPCell(new Paragraph(pkg.getPatientName(), min_9));
            nameCell.setBorderWidth(LINE_WIDTH_0);
            nameTbl.addCell(nameCell);
            patientInfo = new PdfPCell(nameTbl);
            patientInfo.setColspan(4);
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            desc.addCell(patientInfo);
            // 
            patientInfo = new PdfPCell(new Paragraph("", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(patientInfo);
            desc.addCell(patientInfo);
            String birthDay = ModelUtils.convertToGengo(pkg.getPatientBirthday());
            patientInfo = new PdfPCell(new Paragraph(birthDay, min_9));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            patientInfo.setColspan(3);
            patientInfo.setPaddingTop(0.5f);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph(pkg.getPatientSex(), min_8));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(patientInfo);
            desc.addCell(patientInfo);
            // 
            patientInfo = new PdfPCell(new Paragraph("", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(patientInfo);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph(div, min_8));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph("?", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph(payRatio, min_9));
            setAlignRightMiddle(patientInfo);
            patientInfo.setBorderWidth(LINE_WIDTH_0);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph("", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_0);
            patientInfo.setVerticalAlignment(Element.ALIGN_BOTTOM);
            setAlignRight(patientInfo);
            desc.addCell(patientInfo);
            patientTbl.addCell(desc);
            pcell = new PdfPCell(patientTbl);
            pcell.setColspan(9);
            pcell.setBorderWidth(LINE_WIDTH_1);
            ptblL.addCell(pcell);
            // 
            pcell = new PdfPCell(new Paragraph("", min_7));
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(pcell);
            setAlignMiddle(pcell);
            ptblL.addCell(pcell);
            // @003 2010/02/15 ???????????????
            String issueDate = ModelUtils.convertToGengo(
                    ModelUtils.getDateAsFormatString(pkg.getIssuanceDate(), IInfoModel.DATE_WITHOUT_TIME));
            pcell = new PdfPCell(new Paragraph(issueDate, min_9));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPaddingTop(0.5f);
            setAlignMiddle(pcell);
            pcell.setColspan(8);
            ptblL.addCell(pcell);

            ptbl.addCell(ptblL);
            ptbl.addCell("");

            PdfPTable ptblR = new PdfPTable(10);
            ptblR.setSpacingBefore(10f);
            ptblR.setWidthPercentage(100f);
            float[] widthsR = { 30, 7, 7, 7, 7, 7, 7, 7, 7, 14 };
            ptblR.setWidths(widthsR);
            pcell = new PdfPCell(new Paragraph("??", min_7));
            pcell.setMinimumHeight(CELL_HIGHT_0);
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(pcell);
            setAlignMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[0]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[1]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_2);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[2]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[3]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_2);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[4]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthTop(LINE_WIDTH_2);
            pcell.setBorderWidthBottom(LINE_WIDTH_2);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[5]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthTop(LINE_WIDTH_2);
            pcell.setBorderWidthBottom(LINE_WIDTH_2);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[6]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_2);
            pcell.setBorderWidthLeft(LINE_WIDTH_1);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[7]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell();
            pcell.setBorderWidth(LINE_WIDTH_0);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(
                    new Paragraph("?????", min_7));
            pcell.setPaddingTop(0.3f);
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(pcell);
            setAlignMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(mNum, min_9));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setColspan(9);
            setAlignMiddle(pcell);
            ptblR.addCell(pcell);

            //FacilityModel facility = getPhysician().getFacilityModel();
            String facilityName = pkg.getInstitutionName(); // ??
            //String facilityZipCode = facility.getZipCode(); // ?
            String facilityAddress = pkg.getInstitutionAddress(); // ?
            String facilityTelNo = pkg.getInstitutionTelephone(); // ?
            //minagawa^ ?????                 
            String drName = pkg.getPhysicianName();
            //minagawa$                    
            if (pkg.isChkUseDrugInfo()) {
                // ??
                drName = pkg.getPhysicianName();
            }
            // ********** @008 2010/06/18  **********
            // 20104?
            String prefNo = "  "; // ?? 2?
            String grade = " "; // ? 1?
            String institution = "       "; //  7?

            if ((pkg.getInstitutionNumber() != null) && (pkg.getInstitutionNumber().length() > 9)) {
                prefNo = pkg.getInstitutionNumber().substring(0, 2);
                grade = pkg.getInstitutionNumber().substring(2, 3);
                institution = pkg.getInstitutionNumber().substring(3, 10);
            }
            // ********** @008 2010/06/18  **********

            PdfPTable medOrgTbl = new PdfPTable(3);
            medOrgTbl.setWidthPercentage(100f);
            float[] widthsM = { 30, 55, 15 };
            medOrgTbl.setWidths(widthsM);
            PdfPCell medOrgCell = new PdfPCell(new Paragraph("??\n", min_7));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignJustifiedAll(medOrgCell);
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph(facilityAddress, min_8));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            medOrgCell.setColspan(2);
            setAlignMiddle(medOrgCell);
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph("????", min_7));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignJustifiedAll(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph(facilityName, min_8));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            medOrgCell.setColspan(2);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell();
            medOrgCell.setBorder(Table.NO_BORDER);
            medOrgCell.setColspan(3);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph("?", min_7));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignJustifiedAll(medOrgCell);
            setAlignMiddle(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph(facilityTelNo, min_9));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignMiddle(medOrgCell);
            medOrgCell.setColspan(2);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph("????", min_7));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignJustifiedAll(medOrgCell);
            setAlignMiddle(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph(drName, min_10));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignMiddle(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph("?", min_8));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignMiddle(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            pcell = new PdfPCell(medOrgTbl);
            pcell.setBorder(Table.NO_BORDER);
            pcell.setColspan(10);
            pcell.setPaddingBottom(CELL_PADDING_1);
            ptblR.addCell(pcell);
            // ********** @008 2010/06/18  **********
            // 20104? 
            PdfPTable medCodeTbl = new PdfPTable(13);
            medCodeTbl.setWidthPercentage(100f);
            float[] widthsCode = { 17, 8, 8, 15, 8, 17, 8, 8, 8, 8, 8, 8, 8 };
            medCodeTbl.setWidths(widthsCode);
            // ??
            PdfPCell medCodeCell = new PdfPCell(new Paragraph("?\n?", min_6));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(prefNo.charAt(0)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(prefNo.charAt(1)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph("\n?", min_6));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(grade.charAt(0)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph("", min_6));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(0)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(1)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(2)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(3)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(4)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(5)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(6)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            pcell = new PdfPCell(medCodeTbl);
            pcell.setBorder(Table.NO_BORDER);
            pcell.setColspan(10);
            pcell.setPaddingBottom(CELL_PADDING_1);
            ptblR.addCell(pcell);
            // ********** @008 2010/06/18  **********

            ptbl.addCell(ptblR);

            // ??
            PdfPTable termTbl = new PdfPTable(3);
            termTbl.setWidthPercentage(100f);
            float[] widthsT = { 14.8f, 26, 59.2f };
            termTbl.setWidths(widthsT);
            termTbl.getDefaultCell().setPadding(0f);
            PdfPCell termCell = new PdfPCell(new Paragraph("??\n", min_7));
            termCell.setBorderWidth(LINE_WIDTH_1);
            termCell.setPaddingTop(0.3f);
            setAlignJustifiedAll(termCell);
            termTbl.addCell(termCell);
            // ********* @009 2010/07/01  *********
            String periodDate = "?";
            if (pkg.getPeriod() != null) {
                periodDate = ModelUtils.convertToGengo(
                        ModelUtils.getDateAsFormatString(pkg.getPeriod(), IInfoModel.DATE_WITHOUT_TIME));
            }
            termCell = new PdfPCell(new Paragraph(periodDate, min_8));
            // ********* @009 2010/07/01  *********
            termCell.setBorderWidth(LINE_WIDTH_1);
            termCell.setBorderWidthRight(LINE_WIDTH_0);
            setAlignMiddle(termCell);
            termTbl.addCell(termCell);
            termCell = new PdfPCell(new Paragraph(
                    "???????????????????",
                    min_6));
            termCell.setBorderWidth(LINE_WIDTH_1);
            termCell.setBorderWidthLeft(LINE_WIDTH_0);
            setAlignMiddle(termCell);
            termTbl.addCell(termCell);
            pcell = new PdfPCell(termTbl);
            pcell.setBorder(Table.NO_BORDER);
            pcell.setColspan(3);
            ptbl.addCell(pcell);

            document.add(ptbl);

            // 
            ptbl = new PdfPTable(2);
            ptbl.setWidthPercentage(100f);
            ptbl.getDefaultCell().setPadding(0f);
            ptbl.getDefaultCell().setBorder(Table.NO_BORDER);
            float[] widthsPre = { 3.5f, 96.5f };
            ptbl.setWidths(widthsPre);
            pcell = new PdfPCell(
                    new Paragraph("", min_7));
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pcell);
            ptbl.addCell(pcell);
            // @005 2010/02/26  
            // ??
            // 
            PdfPTable outLineTbl = new PdfPTable(1);
            PdfPCell outLineCell; // ?
            // @005 2010/02/26  
            // 
            PdfPTable prescriptionTbl; // 
            if (ite.hasNext()) {
                prescriptionTbl = ite.next();
            } else {
                prescriptionTbl = new PdfPTable(1);
            }
            // @005 2010/02/26  
            // ??
            outLineCell = new PdfPCell(prescriptionTbl);
            outLineCell.setFixedHeight(200f);
            outLineCell.setBorderWidth(LINE_WIDTH_0);
            outLineTbl.addCell(outLineCell);
            if (totalPageNo > 1) {
                pageNo++;
                outLineCell = new PdfPCell(
                        new Paragraph((String.valueOf(pageNo) + "?" + String.valueOf(totalPageNo)), min_10));
                setAlignRight(outLineCell);
                outLineCell.setFixedHeight(12f); // @010
                outLineCell.setBorderWidth(LINE_WIDTH_1); // @010
                outLineTbl.addCell(outLineCell);
            }
            // @005 2010/02/26  
            PdfPCell prescriptionCell = new PdfPCell(outLineTbl);
            prescriptionCell.setFixedHeight(215f);
            prescriptionCell.setBorderWidth(LINE_WIDTH_1);
            ptbl.addCell(prescriptionCell);

            // 
            pcell = new PdfPCell(new Paragraph("", min_7));
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pcell);
            ptbl.addCell(pcell);
            // 
            PdfPTable noteTbl = new PdfPTable(5); // @010
            noteTbl.setWidthPercentage(100f);
            float[] widthsN = { 11, 4, 34, 4, 47 }; // @010
            noteTbl.setWidths(widthsN);
            noteTbl.getDefaultCell().setPadding(0f);
            noteTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            String address = (pkg.getPatientAddress() == null) ? "" : pkg.getPatientAddress();
            String patientName = pkg.getPatientName();
            String addressName = "?" + address + "\n???" + patientName;
            String useDrugInfo = "??" + pkg.getDrugLicenseNumber() + "("
                    + pkg.getPhysicianName() + ")";

            StringBuilder postInfo = new StringBuilder();
            // 
            if (pkg.isChkHomeMedical()) {
                postInfo.append(NOTES_HOME_MEDICAL + "\n");
            }
            if (pkg.isChkPatientInfo()) {
                // ?????
                postInfo.append(addressName);
            }
            if (postInfo.length() > 0) {
                // 
                postInfo.append("\n");
            }
            if (pkg.isChkUseDrugInfo()) {
                // ??
                postInfo.append(useDrugInfo);
            }
            // @010 20124 -->
            PdfPCell noteCell = new PdfPCell(new Paragraph("???", min_7));
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteCell.setBorderWidthBottom(LINE_WIDTH_1);
            noteCell.setMinimumHeight(CELL_HIGHT_2);
            setAlignTop(noteCell);
            noteTbl.addCell(noteCell);

            noteCell = new PdfPCell(new Paragraph("", min_15));//min_15
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteCell.setBorderWidthBottom(LINE_WIDTH_1);
            noteCell.setPadding(0f);
            setAlignRight(noteCell);
            noteTbl.addCell(noteCell);

            noteCell = new PdfPCell(new Paragraph(
                    "??????????\n?????????????",
                    min_6));
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteCell.setBorderWidthBottom(LINE_WIDTH_1);
            noteTbl.addCell(noteCell);

            noteCell = new PdfPCell(new Paragraph("", min_15));//min_15
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteCell.setBorderWidthBottom(LINE_WIDTH_1);
            noteCell.setBorderWidthRight(LINE_WIDTH_1);
            noteCell.setPadding(0f);
            setAlignLeft(noteCell);
            noteTbl.addCell(noteCell);

            //minagawa^ ????  47                   
            noteCell = new PdfPCell();
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteTbl.addCell(noteCell);
            //minagawa                    
            noteCell = new PdfPCell(new Paragraph(postInfo.toString(), min_7)); // ????????
            noteCell.setColspan(widthsN.length);
            noteCell.setMinimumHeight(40f);
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteTbl.addCell(noteCell);
            // <-- 20124 @010

            pcell = new PdfPCell(noteTbl);
            pcell.setBorderWidth(LINE_WIDTH_1);
            ptbl.addCell(pcell);

            document.add(ptbl);

            // ??
            ptbl = new PdfPTable(2);
            ptbl.setWidthPercentage(100f);
            float[] widthsOther = { 58, 42 };
            ptbl.setWidths(widthsOther);
            ptbl.getDefaultCell().setPadding(0f);
            ptbl.getDefaultCell().setBorder(Table.NO_BORDER);
            // 
            ptblL = new PdfPTable(3);
            ptblL.setWidthPercentage(100f);
            float[] widthsPh = { 28, 65, 7 };
            ptblL.setWidths(widthsPh);
            ptblL.getDefaultCell().setPadding(0f);
            ptblL.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell pcellL = new PdfPCell(new Paragraph("", min_7));
            pcellL.setMinimumHeight(CELL_HIGHT_0);
            pcellL.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(pcellL);
            setAlignMiddle(pcellL);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell(new Paragraph("?", min_8));
            pcellL.setBorderWidth(LINE_WIDTH_1);
            setAlignMiddle(pcellL);
            pcellL.setColspan(2);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell(new Paragraph("??\n??\n??", min_7));
            pcellL.setPaddingTop(0.2f);
            pcellL.setBorderWidth(LINE_WIDTH_1);
            pcellL.setBorderWidthBottom(LINE_WIDTH_0);
            setAlignJustifiedAll(pcellL);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell();
            pcellL.setBorderWidth(LINE_WIDTH_0);
            pcellL.setBorderWidthRight(LINE_WIDTH_1);
            pcellL.setColspan(2);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell(new Paragraph("?\n???", min_7));
            pcellL.setPaddingTop(0.2f);
            pcellL.setBorderWidth(LINE_WIDTH_1);
            pcellL.setBorderWidthTop(LINE_WIDTH_0);
            setAlignJustifiedAll(pcellL);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell();
            pcellL.setBorderWidth(LINE_WIDTH_0);
            pcellL.setBorderWidthBottom(LINE_WIDTH_1);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell(new Paragraph("?", min_8));
            pcellL.setBorderWidth(LINE_WIDTH_1);
            pcellL.setBorderWidthTop(LINE_WIDTH_0);
            pcellL.setBorderWidthLeft(LINE_WIDTH_0);
            setAlignJustifiedAll(pcellL);
            setAlignMiddle(pcellL);
            ptblL.addCell(pcellL);
            ptbl.addCell(ptblL);

            ptblR = new PdfPTable(9);
            ptblR.setWidthPercentage(100f);
            float[] widthsPu = { 33, 8, 8, 8, 8, 8, 8, 8, 8 };
            ptblR.setWidths(widthsPu);
            ptblR.getDefaultCell().setPadding(0f);
            PdfPCell pcellR = new PdfPCell(new Paragraph("?", min_7));
            pcellR.setMinimumHeight(CELL_HIGHT_0);
            setAlignJustifiedAll(pcellR);
            setAlignMiddle(pcellR);
            pcellR.setBorderWidth(LINE_WIDTH_1);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[0]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[1]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[2]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[3]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[4]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_2);
            pcellR.setBorderWidthRight(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[5]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthTop(LINE_WIDTH_2);
            pcellR.setBorderWidthBottom(LINE_WIDTH_2);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[6]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_2);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setBorderWidthLeft(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[7]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph("???", min_7));
            pcellR.setPaddingTop(0.3f);
            setAlignJustifiedAll(pcellR);
            pcellR.setBorderWidth(LINE_WIDTH_1);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[0]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[1]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[2]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[3]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[4]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[5]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[6]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell();
            pcellR.setBorderWidth(LINE_WIDTH_0);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell();
            pcellR.setBorderWidth(LINE_WIDTH_0);
            pcellR.setColspan(9);
            ptblR.addCell(pcellR);

            ptbl.addCell(ptblR);

            document.add(ptbl);

            ptbl = new PdfPTable(2);
            ptbl.setWidthPercentage(100f);
            float[] widthsMed = { 3.5f, 96.5f };
            ptbl.setWidths(widthsMed);
            ptbl.setSpacingBefore(3f);
            ptbl.getDefaultCell().setPadding(0f);
            ptbl.getDefaultCell().setBorder(Table.NO_BORDER);
            pcell = new PdfPCell(new Paragraph("????", min_7));
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(pcell);
            ptbl.addCell(pcell);

            ptblR = new PdfPTable(3);
            ptblR.setWidthPercentage(100f);
            float[] widthsPm = { 60, 20, 20 };
            ptblR.setWidths(widthsPm);
            ptblR.getDefaultCell().setPadding(0f);
            ptblR.getDefaultCell().setBorder(Table.NO_BORDER);
            // ????????
            PdfPTable pointTbl = new PdfPTable(7);
            pointTbl.setWidthPercentage(100f);
            float[] widthsPo = { 7, 15.5f, 15.5f, 15.5f, 15.5f, 15.5f, 15.5f };
            pointTbl.setWidths(widthsPo);
            pointTbl.getDefaultCell().setPadding(0f);
            pointTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("?", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("?", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            // ?
            PdfPCell blankCell = new PdfPCell();
            blankCell.setBorderWidth(LINE_WIDTH_1);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            ptblR.addCell(pointTbl);
            // ?
            PdfPTable feeTbl = new PdfPTable(2);
            feeTbl.setWidthPercentage(100f);
            float[] widthsF = { 50, 50 };
            feeTbl.setWidths(widthsF);
            feeTbl.getDefaultCell().setPadding(0f);
            feeTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell feeCell = new PdfPCell(new Paragraph("    ", min_7));
            feeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCell);
            feeTbl.addCell(feeCell);
            feeCell = new PdfPCell(new Paragraph("    ", min_7));
            feeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCell);
            feeTbl.addCell(feeCell);
            feeCell = new PdfPCell();
            feeCell.setBorderWidth(LINE_WIDTH_1);
            feeCell.setMinimumHeight(CELL_HIGHT_1);
            feeTbl.addCell(feeCell);
            feeTbl.addCell(feeCell);
            // ?etc..
            PdfPTable feeTblSub = new PdfPTable(4);
            feeTblSub.setWidthPercentage(100f);
            float[] widthsSub = { 28, 16, 28, 28 };
            feeTblSub.setWidths(widthsSub);
            feeTblSub.getDefaultCell().setPadding(0f);
            feeTblSub.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell feeCellSub = new PdfPCell(new Paragraph("?", min_7));
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeCellSub = new PdfPCell(new Paragraph("", min_7));
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeCellSub = new PdfPCell(new Paragraph("  ", min_7));
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeCellSub = new PdfPCell(new Paragraph("?  ", min_7));
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            // ?
            feeCellSub = new PdfPCell();
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            feeCellSub.setMinimumHeight(CELL_HIGHT_1);
            feeTblSub.addCell(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeCell = new PdfPCell(feeTblSub);
            feeCell.setBorder(Table.NO_BORDER);
            feeCell.setColspan(2);
            feeTbl.addCell(feeCell);
            // etc..?
            pcellR = new PdfPCell(feeTbl);
            pcellR.setPadding(0f);
            pcellR.setColspan(2);
            pcellR.setBorder(Table.NO_BORDER);
            ptblR.addCell(pcellR);
            // 
            noteTbl = new PdfPTable(2);
            noteTbl.setWidthPercentage(100f);
            float[] widthsNote = { 5.3f, 94.7f };
            noteTbl.setWidths(widthsNote);
            noteTbl.getDefaultCell().setPadding(0f);
            noteTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            noteCell = new PdfPCell(new Paragraph("", min_7));
            noteCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(noteCell);
            noteTbl.addCell(noteCell);
            noteCell = new PdfPCell();
            noteCell.setBorderWidth(LINE_WIDTH_1);
            noteTbl.addCell(noteCell);
            pcell = new PdfPCell(noteTbl);
            pcell.setBorderWidth(LINE_WIDTH_0);
            pcell.setPadding(0f);
            pcell.setColspan(2);
            ptblR.addCell(pcell);
            // ?
            PdfPTable sumTbl = new PdfPTable(1);
            sumTbl.setWidthPercentage(100f);
            sumTbl.getDefaultCell().setPadding(0f);
            sumTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell sumCell = new PdfPCell(new Paragraph("?", min_7));
            sumCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(sumCell);
            sumTbl.addCell(sumCell);
            sumCell = new PdfPCell();
            sumCell.setBorderWidth(LINE_WIDTH_1);
            sumCell.setMinimumHeight(CELL_HIGHT_1);
            sumTbl.addCell(sumCell);
            ptblR.addCell(sumTbl);

            pcell = new PdfPCell(ptblR);
            pcell.setBorderWidth(LINE_WIDTH_0);
            pcell.setPadding(0f);
            ptbl.addCell(pcell);

            document.add(ptbl);
            // 
            if (ite.hasNext()) {
                document.newPage();
            }

        } while (ite.hasNext());

        document.close();
        bos.close();

        // pdf content bytes
        byte[] pdfbytes = byteo.toByteArray();

        // ????? File????
        //if (!ClientContext.is5mTest()) {
        if (!Project.isTester()) {
            FileOutputStream fout = new FileOutputStream(pathToPDF);
            FileChannel channel = fout.getChannel();
            ByteBuffer bytebuff = ByteBuffer.wrap(pdfbytes);

            while (bytebuff.hasRemaining()) {
                channel.write(bytebuff);
            }
            channel.close();
            return pathToPDF;
        }

        // ??? water Mark ??
        PdfReader pdfReader = new PdfReader(pdfbytes);
        PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream(pathToPDF));

        Image image = Image.getInstance(ClientContext.getImageResource("water-mark.png"));

        for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {

            PdfContentByte content = pdfStamper.getUnderContent(i);

            image.scaleAbsolute(PageSize.A5.getWidth(), PageSize.A5.getHeight());
            image.setAbsolutePosition(0.0f, 0.0f);
            content.addImage(image);
        }

        pdfStamper.close();

        return pathToPDF;

    } catch (DocumentException e) {
        e.printStackTrace(System.err);
        throw new RuntimeException(e.getMessage());

    } catch (IOException e) {
        e.printStackTrace(System.err);
        throw new RuntimeException(e.getMessage());

    } catch (Exception e) {
        e.printStackTrace(System.err);
        throw new RuntimeException(e.getMessage());

    } finally {
        if (document != null && document.isOpen()) {
            document.close();
        }
    }
}

From source file:open.dolphin.msg.ServerPrescriptionPDFMaker.java

/**
 * ??//from   w  ww.  j  ava  2s  .co m
 */
public String output() {
    BufferedOutputStream bos;
    PdfWriter pw = null;
    Document document = null;

    try {
        Date dateNow = new Date();

        // ID
        String patientId = pkg.getPatientId();

        // ???
        String name = pkg.getPatientName();
        name = name.replaceAll(" ", "");
        name = name.replaceAll("", "");

        String iNum; // ??
        String piNum = null; // ?
        String rNum = null; // ??

        String piNum2 = null; // ?
        String rNum2 = null; // ??

        String div = ""; // ?
        String payRatio = ""; // ?

        String mNum = ""; // ???

        char[] iNumC = new char[8]; // ???
        char[] piNumC = new char[8]; // ??
        char[] rNumC = new char[7]; // ??
        char[] piNumC2 = new char[8]; // ??
        char[] rNumC2 = new char[7]; // ??
        DecimalFormat df = new DecimalFormat("#0.#"); // ??
        String paymentRatio = ""; // ?
        String paymentRatio2 = ""; // ?

        if (pkg.getApplyedInsurance().getInsuranceNumber() != null) {

            // ??
            iNum = pkg.getApplyedInsurance().getInsuranceNumber();

            // ? null ??
            if (iNum.toLowerCase().startsWith("z") || iNum.equals("9999")) {
                iNum = null;
            }

            // 
            if (pkg.getApplyedInsurance().getPVTPublicInsuranceItem() != null) {
                PVTPublicInsuranceItemModel[] pubItems = pkg.getApplyedInsurance().getPVTPublicInsuranceItem();
                for (int i = 0; i < pubItems.length; i++) {
                    PVTPublicInsuranceItemModel pm = pubItems[i];
                    if (i == 0) {
                        // ?
                        piNum = pm.getProvider();
                        piNum = ("mikinyu".equals(piNum)) ? "" : piNum;

                        // ??
                        rNum = pm.getRecipient();
                        rNum = ("mikinyu".equals(rNum)) ? "" : rNum;

                        // ???
                        paymentRatio = pm.getPaymentRatio();
                    } else if (i == 1) {
                        piNum2 = pm.getProvider();
                        piNum2 = ("mikinyu".equals(piNum2)) ? "" : piNum2;

                        rNum2 = pm.getRecipient();
                        rNum2 = ("mikinyu".equals(rNum2)) ? "" : rNum2;

                        paymentRatio2 = pm.getPaymentRatio();
                        break;
                    }
                }
            }

            // ? ?? ?
            StringBuilder sb = new StringBuilder();

            // ? ?
            if (pkg.getApplyedInsurance().getClientGroup() != null
                    && !pkg.getApplyedInsurance().getClientGroup().equals("??")) {
                sb.append(pkg.getApplyedInsurance().getClientGroup()).append("");
            }
            // ??
            if (pkg.getApplyedInsurance().getClientNumber() != null
                    && !pkg.getApplyedInsurance().getClientNumber().equals("??")) {
                sb.append(pkg.getApplyedInsurance().getClientNumber());
            }
            mNum = sb.length() > 0 ? sb.toString() : "";

            // 
            if ("?".equals(pkg.getApplyedInsurance().getInsuranceClass())) {
                div = "";
                payRatio = paymentRatio;
            } else {
                // ?
                div = "true".equals(pkg.getApplyedInsurance().getFamilyClass()) ? "?"
                        : "";
                payRatio = pkg.getApplyedInsurance().getPayOutRatio();
            }
            if (payRatio != null && !("".equals(payRatio))) {
                payRatio = df.format(Double.valueOf(payRatio) * 10);
            }

            if (DEBUG) {
                System.err.println("iNum=" + iNum);
                System.err.println("piNum=" + piNum);
                System.err.println("rNum=" + rNum);
                System.err.println("piNum2=" + piNum2);
                System.err.println("rNum2=" + rNum2);
                System.err.println("mNum=" + mNum);
                System.err.println("?=" + div);
                System.err.println("=" + payRatio);
            }

            // ???
            iNumC = partitionPadRL(iNum, 8, "R"); // ??
            piNumC = partitionPadRL(piNum, 8, "L"); // ?
            rNumC = partitionPadRL(rNum, 7, "L"); // ??
            piNumC2 = partitionPadRL(piNum2, 8, "L"); // ?2
            rNumC2 = partitionPadRL(rNum2, 7, "L"); // ??2
        }
        /*****  *****/

        document = new Document(PageSize.A5, 10, 10, 2, 2);

        // ?PDF?welcome-content
        if (getDocumentDir() == null) {
            StringBuilder sb = new StringBuilder();
            sb.append(System.getProperty("jboss.home.dir"));
            sb.append(File.separator);
            sb.append(DIR_NAME);
            setDocumentDir(sb.toString());
        }
        File dir = new File(getDocumentDir());
        dir.mkdir();

        // ??(ID_.pdf)
        StringBuilder sb = new StringBuilder();
        sb.append(patientId).append("_");
        sb.append(new SimpleDateFormat("yyyyMMddHHmmss").format(dateNow));
        sb.append(FILE_EXTENTION);
        setFileName(sb.toString());

        sb = new StringBuilder();
        sb.append(getDocumentDir());
        sb.append(File.separator);
        sb.append(getFileName());
        pathToPDF = sb.toString();

        //minagawa^ ???water mark?????????? byte[]???            
        ByteArrayOutputStream byteo = new ByteArrayOutputStream();
        bos = new BufferedOutputStream(byteo);
        //minagawa$             
        pw = PdfWriter.getInstance(document, bos);

        // font setting
        bfm = BaseFont.createFont(FONT_HEISEI_MIN3, CODE_UNIJIS_H, BaseFont.NOT_EMBEDDED);
        bfg = BaseFont.createFont(FONT_HEISEI_KAKU5, CODE_UNIJIS_H, BaseFont.NOT_EMBEDDED);
        min_6 = new Font(bfm, 6);
        min_7 = new Font(bfm, 7);
        min_8 = new Font(bfm, 8);
        min_9 = new Font(bfm, 9);
        min_10 = new Font(bfm, 10);
        min_12 = new Font(bfm, 12);
        min_14 = new Font(bfm, 14);
        min_15 = new Font(bfm, 15);
        min_4 = new Font(bfm, 4); // @009

        // 
        document.open();
        document.addAuthor(pkg.getPhysicianName());
        document.addTitle(PROPERTY_TITLE);
        document.addSubject(PROPERTY_SUB_TITLE);

        // ???
        List<PdfPTable> list = createPrescriptionTbl2();
        Iterator<PdfPTable> ite = list.iterator();

        // ?
        int pageNo = 0;
        int totalPageNo = list.size();

        // ?????????
        do {
            PdfPTable ptbl = new PdfPTable(1);
            ptbl.setWidthPercentage(100f);
            ptbl.getDefaultCell().setPadding(0f);
            PdfPCell pcell = new PdfPCell(new Paragraph(REPORT_TITLE, min_15));
            pcell.setBorder(Table.NO_BORDER);
            setAlignCenter(pcell);
            ptbl.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(REPORT_SUB_TITLE, min_7));
            pcell.setBorder(Table.NO_BORDER);
            setAlignCenter(pcell);
            ptbl.addCell(pcell);
            document.add(ptbl);

            ptbl = new PdfPTable(3);
            ptbl.setWidthPercentage(100f);
            ptbl.getDefaultCell().setPadding(0f);
            ptbl.getDefaultCell().setBorder(Table.NO_BORDER);
            float[] widths = { 43.5f, 2f, 54.5f };
            ptbl.setWidths(widths);
            // ?
            pcell = new PdfPCell(new Paragraph(patientId, min_9));
            pcell.setBorder(Table.NO_BORDER);
            pcell.setColspan(10);
            ptbl.addCell(pcell);

            PdfPTable ptblL = new PdfPTable(9);
            ptblL.setSpacingBefore(10f);
            ptblL.setWidthPercentage(100f);
            float[] widthsL = { 33, 8, 8, 8, 8, 8, 8, 8, 8 };
            ptblL.setWidths(widthsL);
            ptblL.getDefaultCell().setPadding(0f);
            pcell = new PdfPCell(new Paragraph("?", min_7));
            pcell.setMinimumHeight(CELL_HIGHT_0);
            setAlignJustifiedAll(pcell);
            setAlignMiddle(pcell);
            pcell.setBorderWidth(LINE_WIDTH_1);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[0]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[1]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[2]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[3]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[4]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_2);
            pcell.setBorderWidthRight(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[5]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthTop(LINE_WIDTH_2);
            pcell.setBorderWidthBottom(LINE_WIDTH_2);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[6]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_2);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setBorderWidthLeft(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(piNumC[7]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph("???", min_7));
            pcell.setPaddingTop(0.3f);
            setAlignJustifiedAll(pcell);
            pcell.setBorderWidth(LINE_WIDTH_1);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[0]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[1]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[2]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[3]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[4]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[5]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(rNumC[6]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthLeft(LINE_WIDTH_3);
            pcell.setPadding(0f);
            setAlignCenterMiddle(pcell);
            ptblL.addCell(pcell);
            pcell = new PdfPCell();
            pcell.setBorderWidth(LINE_WIDTH_0);
            ptblL.addCell(pcell);

            PdfPTable patientTbl = new PdfPTable(2);
            patientTbl.setWidthPercentage(100f);
            float[] widthsPa = { 7.8f, 92.2f };
            patientTbl.setWidths(widthsPa);
            patientTbl.getDefaultCell().setPadding(0f);
            patientTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell pcellP = new PdfPCell(new Paragraph("", min_7));
            pcellP.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pcellP);
            patientTbl.addCell(pcellP);
            // 
            PdfPTable desc = new PdfPTable(5);
            desc.setWidthPercentage(100f);
            float[] widthsD = { 28.5f, 41.5f, 7, 16, 7 };
            desc.setWidths(widthsD);
            // ???(??)
            PdfPCell patientInfo = new PdfPCell(new Paragraph("???", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(patientInfo);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            PdfPTable nameTbl = new PdfPTable(1);
            nameTbl.setWidthPercentage(100f);
            nameTbl.setSpacingAfter(3f);
            PdfPCell nameCell = new PdfPCell(new Paragraph(pkg.getPatientKana(), min_7));
            nameCell.setBorderWidth(LINE_WIDTH_0);
            nameTbl.addCell(nameCell);
            nameCell = new PdfPCell(new Paragraph(pkg.getPatientName(), min_9));
            nameCell.setBorderWidth(LINE_WIDTH_0);
            nameTbl.addCell(nameCell);
            patientInfo = new PdfPCell(nameTbl);
            patientInfo.setColspan(4);
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            desc.addCell(patientInfo);
            // 
            patientInfo = new PdfPCell(new Paragraph("", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(patientInfo);
            desc.addCell(patientInfo);
            String birthDay = ModelUtils.convertToGengo(pkg.getPatientBirthday());
            patientInfo = new PdfPCell(new Paragraph(birthDay, min_9));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            patientInfo.setColspan(3);
            patientInfo.setPaddingTop(0.5f);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph(pkg.getPatientSex(), min_8));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(patientInfo);
            desc.addCell(patientInfo);
            // 
            patientInfo = new PdfPCell(new Paragraph("", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(patientInfo);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph(div, min_8));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph("?", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_1);
            setAlignMiddle(patientInfo);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph(payRatio, min_9));
            setAlignRightMiddle(patientInfo);
            patientInfo.setBorderWidth(LINE_WIDTH_0);
            desc.addCell(patientInfo);
            patientInfo = new PdfPCell(new Paragraph("", min_7));
            patientInfo.setBorderWidth(LINE_WIDTH_0);
            patientInfo.setVerticalAlignment(Element.ALIGN_BOTTOM);
            setAlignRight(patientInfo);
            desc.addCell(patientInfo);
            patientTbl.addCell(desc);
            pcell = new PdfPCell(patientTbl);
            pcell.setColspan(9);
            pcell.setBorderWidth(LINE_WIDTH_1);
            ptblL.addCell(pcell);
            // 
            pcell = new PdfPCell(new Paragraph("", min_7));
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(pcell);
            setAlignMiddle(pcell);
            ptblL.addCell(pcell);
            // @003 2010/02/15 ???????????????
            String issueDate = ModelUtils.convertToGengo(
                    ModelUtils.getDateAsFormatString(pkg.getIssuanceDate(), IInfoModel.DATE_WITHOUT_TIME));
            pcell = new PdfPCell(new Paragraph(issueDate, min_9));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPaddingTop(0.5f);
            setAlignMiddle(pcell);
            pcell.setColspan(8);
            ptblL.addCell(pcell);

            ptbl.addCell(ptblL);
            ptbl.addCell("");

            PdfPTable ptblR = new PdfPTable(10);
            ptblR.setSpacingBefore(10f);
            ptblR.setWidthPercentage(100f);
            float[] widthsR = { 30, 7, 7, 7, 7, 7, 7, 7, 7, 14 };
            ptblR.setWidths(widthsR);
            pcell = new PdfPCell(new Paragraph("??", min_7));
            pcell.setMinimumHeight(CELL_HIGHT_0);
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(pcell);
            setAlignMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[0]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[1]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_2);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[2]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[3]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthRight(LINE_WIDTH_2);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[4]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthTop(LINE_WIDTH_2);
            pcell.setBorderWidthBottom(LINE_WIDTH_2);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[5]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setBorderWidthTop(LINE_WIDTH_2);
            pcell.setBorderWidthBottom(LINE_WIDTH_2);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[6]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_2);
            pcell.setBorderWidthLeft(LINE_WIDTH_1);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(String.valueOf(iNumC[7]), min_14));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setPadding(CELL_PADDING_0);
            setAlignCenterMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell();
            pcell.setBorderWidth(LINE_WIDTH_0);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(
                    new Paragraph("?????", min_7));
            pcell.setPaddingTop(0.3f);
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(pcell);
            setAlignMiddle(pcell);
            ptblR.addCell(pcell);
            pcell = new PdfPCell(new Paragraph(mNum, min_9));
            pcell.setBorderWidth(LINE_WIDTH_1);
            pcell.setColspan(9);
            setAlignMiddle(pcell);
            ptblR.addCell(pcell);

            //FacilityModel facility = getPhysician().getFacilityModel();
            String facilityName = pkg.getInstitutionName(); // ??
            //String facilityZipCode = facility.getZipCode(); // ?
            String facilityAddress = pkg.getInstitutionAddress(); // ?
            String facilityTelNo = pkg.getInstitutionTelephone(); // ?
            //minagawa^ ?????                 
            String drName = pkg.getPhysicianName();
            //minagawa$                    
            if (pkg.isChkUseDrugInfo()) {
                // ??
                drName = pkg.getPhysicianName();
            }
            // ********** @008 2010/06/18  **********
            // 20104?
            String prefNo = "  "; // ?? 2?
            String grade = " "; // ? 1?
            String institution = "       "; //  7?

            if ((pkg.getInstitutionNumber() != null) && (pkg.getInstitutionNumber().length() > 9)) {
                prefNo = pkg.getInstitutionNumber().substring(0, 2);
                grade = pkg.getInstitutionNumber().substring(2, 3);
                institution = pkg.getInstitutionNumber().substring(3, 10);
            }
            // ********** @008 2010/06/18  **********

            PdfPTable medOrgTbl = new PdfPTable(3);
            medOrgTbl.setWidthPercentage(100f);
            float[] widthsM = { 30, 55, 15 };
            medOrgTbl.setWidths(widthsM);
            PdfPCell medOrgCell = new PdfPCell(new Paragraph("??\n", min_7));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignJustifiedAll(medOrgCell);
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph(facilityAddress, min_8));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            medOrgCell.setColspan(2);
            setAlignMiddle(medOrgCell);
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph("????", min_7));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignJustifiedAll(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph(facilityName, min_8));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            medOrgCell.setColspan(2);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell();
            medOrgCell.setBorder(Table.NO_BORDER);
            medOrgCell.setColspan(3);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgCell.setPaddingBottom(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph("?", min_7));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignJustifiedAll(medOrgCell);
            setAlignMiddle(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph(facilityTelNo, min_9));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignMiddle(medOrgCell);
            medOrgCell.setColspan(2);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph("????", min_7));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignJustifiedAll(medOrgCell);
            setAlignMiddle(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph(drName, min_10));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignMiddle(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            medOrgCell = new PdfPCell(new Paragraph("?", min_8));
            medOrgCell.setBorderWidth(LINE_WIDTH_0);
            setAlignMiddle(medOrgCell);
            medOrgCell.setPaddingTop(CELL_PADDING_0); // @008
            medOrgTbl.addCell(medOrgCell);
            pcell = new PdfPCell(medOrgTbl);
            pcell.setBorder(Table.NO_BORDER);
            pcell.setColspan(10);
            pcell.setPaddingBottom(CELL_PADDING_1);
            ptblR.addCell(pcell);
            // ********** @008 2010/06/18  **********
            // 20104? 
            PdfPTable medCodeTbl = new PdfPTable(13);
            medCodeTbl.setWidthPercentage(100f);
            float[] widthsCode = { 17, 8, 8, 15, 8, 17, 8, 8, 8, 8, 8, 8, 8 };
            medCodeTbl.setWidths(widthsCode);
            // ??
            PdfPCell medCodeCell = new PdfPCell(new Paragraph("?\n?", min_6));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(prefNo.charAt(0)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(prefNo.charAt(1)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph("\n?", min_6));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(grade.charAt(0)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph("", min_6));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(0)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(1)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(2)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(3)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(4)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(5)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            medCodeCell = new PdfPCell(new Paragraph(String.valueOf(institution.charAt(6)), min_14));
            medCodeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(medCodeCell);
            medCodeCell.setPaddingTop(CELL_PADDING_0);
            medCodeTbl.addCell(medCodeCell);
            pcell = new PdfPCell(medCodeTbl);
            pcell.setBorder(Table.NO_BORDER);
            pcell.setColspan(10);
            pcell.setPaddingBottom(CELL_PADDING_1);
            ptblR.addCell(pcell);
            // ********** @008 2010/06/18  **********

            ptbl.addCell(ptblR);

            // ??
            PdfPTable termTbl = new PdfPTable(3);
            termTbl.setWidthPercentage(100f);
            float[] widthsT = { 14.8f, 26, 59.2f };
            termTbl.setWidths(widthsT);
            termTbl.getDefaultCell().setPadding(0f);
            PdfPCell termCell = new PdfPCell(new Paragraph("??\n", min_7));
            termCell.setBorderWidth(LINE_WIDTH_1);
            termCell.setPaddingTop(0.3f);
            setAlignJustifiedAll(termCell);
            termTbl.addCell(termCell);
            // ********* @009 2010/07/01  *********
            String periodDate = "?";
            if (pkg.getPeriod() != null) {
                periodDate = ModelUtils.convertToGengo(
                        ModelUtils.getDateAsFormatString(pkg.getPeriod(), IInfoModel.DATE_WITHOUT_TIME));
            }
            termCell = new PdfPCell(new Paragraph(periodDate, min_8));
            // ********* @009 2010/07/01  *********
            termCell.setBorderWidth(LINE_WIDTH_1);
            termCell.setBorderWidthRight(LINE_WIDTH_0);
            setAlignMiddle(termCell);
            termTbl.addCell(termCell);
            termCell = new PdfPCell(new Paragraph(
                    "???????????????????",
                    min_6));
            termCell.setBorderWidth(LINE_WIDTH_1);
            termCell.setBorderWidthLeft(LINE_WIDTH_0);
            setAlignMiddle(termCell);
            termTbl.addCell(termCell);
            pcell = new PdfPCell(termTbl);
            pcell.setBorder(Table.NO_BORDER);
            pcell.setColspan(3);
            ptbl.addCell(pcell);

            document.add(ptbl);

            // 
            ptbl = new PdfPTable(2);
            ptbl.setWidthPercentage(100f);
            ptbl.getDefaultCell().setPadding(0f);
            ptbl.getDefaultCell().setBorder(Table.NO_BORDER);
            float[] widthsPre = { 3.5f, 96.5f };
            ptbl.setWidths(widthsPre);
            pcell = new PdfPCell(
                    new Paragraph("", min_7));
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pcell);
            ptbl.addCell(pcell);
            // @005 2010/02/26  
            // ??
            // 
            PdfPTable outLineTbl = new PdfPTable(1);
            PdfPCell outLineCell; // ?
            // @005 2010/02/26  
            // 
            PdfPTable prescriptionTbl; // 
            if (ite.hasNext()) {
                prescriptionTbl = ite.next();
            } else {
                prescriptionTbl = new PdfPTable(1);
            }
            // @005 2010/02/26  
            // ??
            outLineCell = new PdfPCell(prescriptionTbl);
            outLineCell.setFixedHeight(200f);
            outLineCell.setBorderWidth(LINE_WIDTH_0);
            outLineTbl.addCell(outLineCell);
            if (totalPageNo > 1) {
                pageNo++;
                outLineCell = new PdfPCell(
                        new Paragraph((String.valueOf(pageNo) + "?" + String.valueOf(totalPageNo)), min_10));
                setAlignRight(outLineCell);
                outLineCell.setFixedHeight(12f); // @010
                outLineCell.setBorderWidth(LINE_WIDTH_1); // @010
                outLineTbl.addCell(outLineCell);
            }
            // @005 2010/02/26  
            PdfPCell prescriptionCell = new PdfPCell(outLineTbl);
            prescriptionCell.setFixedHeight(215f);
            prescriptionCell.setBorderWidth(LINE_WIDTH_1);
            ptbl.addCell(prescriptionCell);

            // 
            pcell = new PdfPCell(new Paragraph("", min_7));
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pcell);
            ptbl.addCell(pcell);
            // 
            PdfPTable noteTbl = new PdfPTable(5); // @010
            noteTbl.setWidthPercentage(100f);
            float[] widthsN = { 11, 4, 34, 4, 47 }; // @010
            noteTbl.setWidths(widthsN);
            noteTbl.getDefaultCell().setPadding(0f);
            noteTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            String address = (pkg.getPatientAddress() == null) ? "" : pkg.getPatientAddress();
            String patientName = pkg.getPatientName();
            String addressName = "?" + address + "\n???" + patientName;
            String useDrugInfo = "??" + pkg.getDrugLicenseNumber() + "("
                    + pkg.getPhysicianName() + ")";

            StringBuilder postInfo = new StringBuilder();
            // 
            if (pkg.isChkHomeMedical()) {
                postInfo.append(NOTES_HOME_MEDICAL + "\n");
            }
            if (pkg.isChkPatientInfo()) {
                // ?????
                postInfo.append(addressName);
            }
            if (postInfo.length() > 0) {
                // 
                postInfo.append("\n");
            }
            if (pkg.isChkUseDrugInfo()) {
                // ??
                postInfo.append(useDrugInfo);
            }
            // @010 20124 -->
            PdfPCell noteCell = new PdfPCell(new Paragraph("???", min_7));
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteCell.setBorderWidthBottom(LINE_WIDTH_1);
            noteCell.setMinimumHeight(CELL_HIGHT_2);
            setAlignTop(noteCell);
            noteTbl.addCell(noteCell);

            noteCell = new PdfPCell(new Paragraph("", min_15));//min_15
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteCell.setBorderWidthBottom(LINE_WIDTH_1);
            noteCell.setPadding(0f);
            setAlignRight(noteCell);
            noteTbl.addCell(noteCell);

            noteCell = new PdfPCell(new Paragraph(
                    "??????????\n?????????????",
                    min_6));
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteCell.setBorderWidthBottom(LINE_WIDTH_1);
            noteTbl.addCell(noteCell);

            noteCell = new PdfPCell(new Paragraph("", min_15));//min_15
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteCell.setBorderWidthBottom(LINE_WIDTH_1);
            noteCell.setBorderWidthRight(LINE_WIDTH_1);
            noteCell.setPadding(0f);
            setAlignLeft(noteCell);
            noteTbl.addCell(noteCell);

            //minagawa^ ????  47                   
            noteCell = new PdfPCell();
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteTbl.addCell(noteCell);
            //minagawa                    
            noteCell = new PdfPCell(new Paragraph(postInfo.toString(), min_7)); // ????????
            noteCell.setColspan(widthsN.length);
            noteCell.setMinimumHeight(40f);
            noteCell.setBorderWidth(LINE_WIDTH_0);
            noteTbl.addCell(noteCell);
            // <-- 20124 @010

            pcell = new PdfPCell(noteTbl);
            pcell.setBorderWidth(LINE_WIDTH_1);
            ptbl.addCell(pcell);

            document.add(ptbl);

            // ??
            ptbl = new PdfPTable(2);
            ptbl.setWidthPercentage(100f);
            float[] widthsOther = { 58, 42 };
            ptbl.setWidths(widthsOther);
            ptbl.getDefaultCell().setPadding(0f);
            ptbl.getDefaultCell().setBorder(Table.NO_BORDER);
            // 
            ptblL = new PdfPTable(3);
            ptblL.setWidthPercentage(100f);
            float[] widthsPh = { 28, 65, 7 };
            ptblL.setWidths(widthsPh);
            ptblL.getDefaultCell().setPadding(0f);
            ptblL.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell pcellL = new PdfPCell(new Paragraph("", min_7));
            pcellL.setMinimumHeight(CELL_HIGHT_0);
            pcellL.setBorderWidth(LINE_WIDTH_1);
            setAlignJustifiedAll(pcellL);
            setAlignMiddle(pcellL);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell(new Paragraph("?", min_8));
            pcellL.setBorderWidth(LINE_WIDTH_1);
            setAlignMiddle(pcellL);
            pcellL.setColspan(2);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell(new Paragraph("??\n??\n??", min_7));
            pcellL.setPaddingTop(0.2f);
            pcellL.setBorderWidth(LINE_WIDTH_1);
            pcellL.setBorderWidthBottom(LINE_WIDTH_0);
            setAlignJustifiedAll(pcellL);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell();
            pcellL.setBorderWidth(LINE_WIDTH_0);
            pcellL.setBorderWidthRight(LINE_WIDTH_1);
            pcellL.setColspan(2);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell(new Paragraph("?\n???", min_7));
            pcellL.setPaddingTop(0.2f);
            pcellL.setBorderWidth(LINE_WIDTH_1);
            pcellL.setBorderWidthTop(LINE_WIDTH_0);
            setAlignJustifiedAll(pcellL);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell();
            pcellL.setBorderWidth(LINE_WIDTH_0);
            pcellL.setBorderWidthBottom(LINE_WIDTH_1);
            ptblL.addCell(pcellL);
            pcellL = new PdfPCell(new Paragraph("?", min_8));
            pcellL.setBorderWidth(LINE_WIDTH_1);
            pcellL.setBorderWidthTop(LINE_WIDTH_0);
            pcellL.setBorderWidthLeft(LINE_WIDTH_0);
            setAlignJustifiedAll(pcellL);
            setAlignMiddle(pcellL);
            ptblL.addCell(pcellL);
            ptbl.addCell(ptblL);

            ptblR = new PdfPTable(9);
            ptblR.setWidthPercentage(100f);
            float[] widthsPu = { 33, 8, 8, 8, 8, 8, 8, 8, 8 };
            ptblR.setWidths(widthsPu);
            ptblR.getDefaultCell().setPadding(0f);
            PdfPCell pcellR = new PdfPCell(new Paragraph("?", min_7));
            pcellR.setMinimumHeight(CELL_HIGHT_0);
            setAlignJustifiedAll(pcellR);
            setAlignMiddle(pcellR);
            pcellR.setBorderWidth(LINE_WIDTH_1);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[0]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[1]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[2]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[3]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[4]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_2);
            pcellR.setBorderWidthRight(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[5]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthTop(LINE_WIDTH_2);
            pcellR.setBorderWidthBottom(LINE_WIDTH_2);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[6]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_2);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setBorderWidthLeft(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(piNumC2[7]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph("???", min_7));
            pcellR.setPaddingTop(0.3f);
            setAlignJustifiedAll(pcellR);
            pcellR.setBorderWidth(LINE_WIDTH_1);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[0]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[1]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[2]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[3]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[4]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[5]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthRight(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell(new Paragraph(String.valueOf(rNumC2[6]), min_14)); // @006
            pcellR.setBorderWidth(LINE_WIDTH_1);
            pcellR.setBorderWidthLeft(LINE_WIDTH_3);
            pcellR.setPadding(0f);
            setAlignCenterMiddle(pcellR);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell();
            pcellR.setBorderWidth(LINE_WIDTH_0);
            ptblR.addCell(pcellR);
            pcellR = new PdfPCell();
            pcellR.setBorderWidth(LINE_WIDTH_0);
            pcellR.setColspan(9);
            ptblR.addCell(pcellR);

            ptbl.addCell(ptblR);

            document.add(ptbl);

            ptbl = new PdfPTable(2);
            ptbl.setWidthPercentage(100f);
            float[] widthsMed = { 3.5f, 96.5f };
            ptbl.setWidths(widthsMed);
            ptbl.setSpacingBefore(3f);
            ptbl.getDefaultCell().setPadding(0f);
            ptbl.getDefaultCell().setBorder(Table.NO_BORDER);
            pcell = new PdfPCell(new Paragraph("????", min_7));
            pcell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(pcell);
            ptbl.addCell(pcell);

            ptblR = new PdfPTable(3);
            ptblR.setWidthPercentage(100f);
            float[] widthsPm = { 60, 20, 20 };
            ptblR.setWidths(widthsPm);
            ptblR.getDefaultCell().setPadding(0f);
            ptblR.getDefaultCell().setBorder(Table.NO_BORDER);
            // ????????
            PdfPTable pointTbl = new PdfPTable(7);
            pointTbl.setWidthPercentage(100f);
            float[] widthsPo = { 7, 15.5f, 15.5f, 15.5f, 15.5f, 15.5f, 15.5f };
            pointTbl.setWidths(widthsPo);
            pointTbl.getDefaultCell().setPadding(0f);
            pointTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("?", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("?", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            pointCell = new PdfPCell(new Paragraph("", min_7));
            pointCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(pointCell);
            pointTbl.addCell(pointCell);
            // ?
            PdfPCell blankCell = new PdfPCell();
            blankCell.setBorderWidth(LINE_WIDTH_1);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            pointTbl.addCell(blankCell);
            ptblR.addCell(pointTbl);
            // ?
            PdfPTable feeTbl = new PdfPTable(2);
            feeTbl.setWidthPercentage(100f);
            float[] widthsF = { 50, 50 };
            feeTbl.setWidths(widthsF);
            feeTbl.getDefaultCell().setPadding(0f);
            feeTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell feeCell = new PdfPCell(new Paragraph("    ", min_7));
            feeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCell);
            feeTbl.addCell(feeCell);
            feeCell = new PdfPCell(new Paragraph("    ", min_7));
            feeCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCell);
            feeTbl.addCell(feeCell);
            feeCell = new PdfPCell();
            feeCell.setBorderWidth(LINE_WIDTH_1);
            feeCell.setMinimumHeight(CELL_HIGHT_1);
            feeTbl.addCell(feeCell);
            feeTbl.addCell(feeCell);
            // ?etc..
            PdfPTable feeTblSub = new PdfPTable(4);
            feeTblSub.setWidthPercentage(100f);
            float[] widthsSub = { 28, 16, 28, 28 };
            feeTblSub.setWidths(widthsSub);
            feeTblSub.getDefaultCell().setPadding(0f);
            feeTblSub.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell feeCellSub = new PdfPCell(new Paragraph("?", min_7));
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeCellSub = new PdfPCell(new Paragraph("", min_7));
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeCellSub = new PdfPCell(new Paragraph("  ", min_7));
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeCellSub = new PdfPCell(new Paragraph("?  ", min_7));
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            // ?
            feeCellSub = new PdfPCell();
            feeCellSub.setBorderWidth(LINE_WIDTH_1);
            feeCellSub.setMinimumHeight(CELL_HIGHT_1);
            feeTblSub.addCell(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeTblSub.addCell(feeCellSub);
            feeCell = new PdfPCell(feeTblSub);
            feeCell.setBorder(Table.NO_BORDER);
            feeCell.setColspan(2);
            feeTbl.addCell(feeCell);
            // etc..?
            pcellR = new PdfPCell(feeTbl);
            pcellR.setPadding(0f);
            pcellR.setColspan(2);
            pcellR.setBorder(Table.NO_BORDER);
            ptblR.addCell(pcellR);
            // 
            noteTbl = new PdfPTable(2);
            noteTbl.setWidthPercentage(100f);
            float[] widthsNote = { 5.3f, 94.7f };
            noteTbl.setWidths(widthsNote);
            noteTbl.getDefaultCell().setPadding(0f);
            noteTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            noteCell = new PdfPCell(new Paragraph("", min_7));
            noteCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenterMiddle(noteCell);
            noteTbl.addCell(noteCell);
            noteCell = new PdfPCell();
            noteCell.setBorderWidth(LINE_WIDTH_1);
            noteTbl.addCell(noteCell);
            pcell = new PdfPCell(noteTbl);
            pcell.setBorderWidth(LINE_WIDTH_0);
            pcell.setPadding(0f);
            pcell.setColspan(2);
            ptblR.addCell(pcell);
            // ?
            PdfPTable sumTbl = new PdfPTable(1);
            sumTbl.setWidthPercentage(100f);
            sumTbl.getDefaultCell().setPadding(0f);
            sumTbl.getDefaultCell().setBorder(Table.NO_BORDER);
            PdfPCell sumCell = new PdfPCell(new Paragraph("?", min_7));
            sumCell.setBorderWidth(LINE_WIDTH_1);
            setAlignCenter(sumCell);
            sumTbl.addCell(sumCell);
            sumCell = new PdfPCell();
            sumCell.setBorderWidth(LINE_WIDTH_1);
            sumCell.setMinimumHeight(CELL_HIGHT_1);
            sumTbl.addCell(sumCell);
            ptblR.addCell(sumTbl);

            pcell = new PdfPCell(ptblR);
            pcell.setBorderWidth(LINE_WIDTH_0);
            pcell.setPadding(0f);
            ptbl.addCell(pcell);

            document.add(ptbl);
            // 
            if (ite.hasNext()) {
                document.newPage();
            }

        } while (ite.hasNext());

        document.close();
        bos.close();

        // pdf content bytes
        byte[] pdfbytes = byteo.toByteArray();

        // ????? File????
        //if (!ClientContext.is5mTest()) {
        FileOutputStream fout = new FileOutputStream(pathToPDF);
        FileChannel channel = fout.getChannel();
        ByteBuffer bytebuff = ByteBuffer.wrap(pdfbytes);

        while (bytebuff.hasRemaining()) {
            channel.write(bytebuff);
        }
        channel.close();
        //return pathToPDF;
        //}

        //            // ??? water Mark ??
        //            PdfReader pdfReader = new PdfReader(pdfbytes);
        //            PdfStamper pdfStamper = new PdfStamper(pdfReader,new FileOutputStream(pathToPDF));
        //
        //            Image image = Image.getInstance(ClientContext.getImageResource("water-mark.png"));
        //
        //            for(int i=1; i<= pdfReader.getNumberOfPages(); i++){
        //
        //                PdfContentByte content = pdfStamper.getUnderContent(i);
        //
        //                image.scaleAbsolute(PageSize.A5.getWidth(), PageSize.A5.getHeight());
        //                image.setAbsolutePosition(0.0f, 0.0f);
        //                content.addImage(image);
        //            }
        //
        //            pdfStamper.close();

        return getFileName(); //http://ip:8080/filename.pdf

    } catch (DocumentException e) {
        e.printStackTrace(System.err);
        throw new RuntimeException(e.getMessage());

    } catch (IOException e) {
        e.printStackTrace(System.err);
        throw new RuntimeException(e.getMessage());

    } catch (Exception e) {
        e.printStackTrace(System.err);
        throw new RuntimeException(e.getMessage());

    } finally {
        if (document != null && document.isOpen()) {
            document.close();
        }
    }
}

From source file:org.mapfish.print.PDFUtils.java

License:Open Source License

/**
 * When we have to do some custom drawing in a block that is layed out by
 * iText, we first give an empty table with the good dimensions to iText,
 * then iText will call a callback with the actual position. When that
 * happens, we use the given drawer to do the actual drawing.
 *//*from  w  w  w. j  av  a 2 s .co m*/
public static PdfPTable createPlaceholderTable(double width, double height, double spacingAfter,
        ChunkDrawer drawer, HorizontalAlign align, PDFCustomBlocks customBlocks) {
    PdfPTable placeHolderTable = new PdfPTable(1);
    placeHolderTable.setLockedWidth(true);
    placeHolderTable.setTotalWidth((float) width);
    final PdfPCell placeHolderCell = new PdfPCell();
    placeHolderCell.setMinimumHeight((float) height);
    placeHolderCell.setPadding(0f);
    placeHolderCell.setBorder(PdfPCell.NO_BORDER);
    placeHolderTable.addCell(placeHolderCell);
    customBlocks.addChunkDrawer(drawer);
    placeHolderTable.setTableEvent(drawer);
    placeHolderTable.setComplete(true);

    final PdfPCell surroundingCell = new PdfPCell(placeHolderTable);
    surroundingCell.setPadding(0f);
    surroundingCell.setBorder(PdfPCell.NO_BORDER);
    if (align != null) {
        placeHolderTable.setHorizontalAlignment(align.getCode());
        surroundingCell.setHorizontalAlignment(align.getCode());
    }

    PdfPTable surroundingTable = new PdfPTable(1);
    surroundingTable.setSpacingAfter((float) spacingAfter);
    surroundingTable.addCell(surroundingCell);
    surroundingTable.setComplete(true);

    return surroundingTable;
}

From source file:org.posterita.businesslogic.administration.CustomerManager.java

License:Open Source License

public static String fidelityCard(Properties ctx, ArrayList<CustomerBean> customerList)
        throws OperationException {
    String reportName = RandomStringGenerator.randomstring() + ".pdf";
    String reportPath = ReportManager.getReportPath(reportName);

    boolean shouldPrintCard = false;

    for (CustomerBean b : customerList) {
        if (b.getIsActive()) {
            shouldPrintCard = true;/*from   w w w  . jav  a 2 s.c om*/
            break;
        }
    }

    if (!shouldPrintCard) {
        throw new NoCustomerFoundException("Cannot print fidelity card. Cause no active customers were found.");
    }

    Document document = new Document(PageSize.A4, 3, 3, 2, 4);//l,r,t,b

    try {
        //          step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file
        PdfWriter.getInstance(document, new FileOutputStream(reportPath));

        // step 3: we open the document
        document.open();

        PdfPTable main = new PdfPTable(2);
        main.setWidthPercentage(71.0f);
        main.getDefaultCell().setBorderColor(Color.gray);

        PdfPCell cell = new PdfPCell();
        cell.setMinimumHeight(150.0f);

        Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD);
        //Font spaceFont = FontFactory.getFont(FontFactory.HELVETICA,6,Font.BOLD);
        //Font spaceFont2 = FontFactory.getFont(FontFactory.HELVETICA,15,Font.BOLD);

        //ResourceBundle rb = ResourceBundle.getBundle("MessageResources");

        for (CustomerBean bean : customerList) {
            if (bean.getIsActive()) {
                String name = bean.getPartnerName();
                String name1 = "";
                String add2 = "";
                String add1 = "";
                String city = "";

                if (bean.getAddress1() != null)
                    add1 = bean.getAddress1();

                if (bean.getAddress2() != null)
                    add2 = bean.getAddress2();

                if (bean.getCity() != null)
                    city = bean.getCity();

                String Address = "   " + add1;
                String Add2 = " " + add2;
                String Add3 = "   " + city;

                String BackPriv1Path = PathInfo.PROJECT_HOME + "/images/BackPriv1.jpg";
                String backPriv2Path = PathInfo.PROJECT_HOME + "/images/backPriv2.jpg";
                String frontImgPath = PathInfo.PROJECT_HOME + "/images/pc.png";

                float WIDTH = 205;
                float HEIGHT = 135;

                Image Back1 = Image.getInstance(BackPriv1Path);
                Back1.scaleAbsolute(WIDTH - 40, HEIGHT / 3);
                Image Back2 = Image.getInstance(backPriv2Path);
                Back2.scaleAbsolute(WIDTH, HEIGHT / 3);
                Image frontImg = Image.getInstance(frontImgPath);
                frontImg.scaleAbsolute(WIDTH, HEIGHT);

                if (bean.getSurname() != null && bean.getSurname().trim().length() > 0)
                    name1 = "   " + name + " " + name1 + bean.getSurname();

                byte[] barcode = BarcodeManager.getBarcodeAsByte(bean.getBpartnerId().toString());
                Image barcodeImg = Image.getInstance(barcode);
                barcodeImg.setRotation(1.57f);
                barcodeImg.scaleAbsolute(HEIGHT - 55f, WIDTH / 5);

                //document.add(barcodeImg);
                PdfPTable card = new PdfPTable(2);
                card.getDefaultCell().setBorderWidth(0.0f);

                PdfPCell c = null;
                card.setWidthPercentage(50.0f);

                PdfPTable t = new PdfPTable(1);
                PdfPTable nametable = new PdfPTable(1);

                c = new PdfPCell(Back1);
                c.setBorderWidth(0.0f);
                nametable.addCell(c);

                c = new PdfPCell(new Phrase(name1, smallFont));
                c.setHorizontalAlignment(Element.ALIGN_CENTER);
                c.setVerticalAlignment(Element.ALIGN_CENTER);
                c.setBorderWidth(0.0f);
                nametable.addCell(c);

                c = new PdfPCell(new Phrase(Address, smallFont));
                c.setHorizontalAlignment(Element.ALIGN_CENTER);
                c.setVerticalAlignment(Element.ALIGN_CENTER);
                c.setBorderWidth(0.0f);
                //c.setColspan(2);
                nametable.addCell(c);

                c = new PdfPCell(new Phrase(Add2, smallFont));
                c.setHorizontalAlignment(Element.ALIGN_CENTER);
                c.setVerticalAlignment(Element.ALIGN_CENTER);
                c.setBorderWidth(0.0f);
                //c.setColspan(2);
                nametable.addCell(c);

                c = new PdfPCell(new Phrase(Add3, smallFont));
                c.setHorizontalAlignment(Element.ALIGN_CENTER);
                c.setVerticalAlignment(Element.ALIGN_CENTER);
                c.setBorderWidth(0.0f);
                //c.setColspan(2);
                nametable.addCell(c);

                //nametable.getDefaultCell();
                nametable.getDefaultCell().setBorderWidth(0.0f);
                nametable.setHorizontalAlignment(Element.ALIGN_CENTER);
                card.addCell(nametable);

                c = new PdfPCell(barcodeImg);
                c.setBorderWidth(0.0f);
                //c.setColspan(2);
                c.setHorizontalAlignment(Element.ALIGN_RIGHT);
                c.setVerticalAlignment(Element.ALIGN_MIDDLE);
                c.setPadding(5.0f);
                card.addCell(c);

                c = new PdfPCell(Back2);
                c.setBorderWidth(0.0f);
                c.setColspan(2);
                card.addCell(c);

                c = new PdfPCell(new Phrase(name1, smallFont));
                c.setBorderWidth(0.0f);
                t.addCell(c);

                c = new PdfPCell(new Phrase(Address, smallFont));
                c.setBorderWidth(0.0f);
                t.addCell(c);

                c = new PdfPCell(new Phrase(Add3, smallFont));
                c.setBorderWidth(0.0f);
                t.addCell(c);

                PdfPTable card1 = new PdfPTable(1);
                card.getDefaultCell().setBorderWidth(0.0f);

                PdfPCell c1 = null;
                card.setWidthPercentage(50.0f);

                c1 = new PdfPCell(frontImg);
                c1.setBorderWidth(0.0f);
                card1.addCell(c1);

                main.addCell(card);
                main.addCell(card1);
            }

        }
        document.add(main);

    }
    // TODO handle the following exception neatly
    catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();
    return reportName;
}

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

License:Open Source License

/**
 * Creates an empty PdfPTable cell with a defined height and colspan.
 * /*www . j  a va  2 s  .  com*/
 * @param height
 *            the height of the created cell
 * @param colspan
 *            the colspan
 * 
 * @return Empty cell with defined minimum height
 */
protected PdfPCell createVerticalStrut(float height, int colspan) {
    PdfPCell fill = new PdfPCell();

    fill.setColspan(colspan);
    fill.setMinimumHeight(height);
    fill.disableBorderSide(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP | Rectangle.BOTTOM);

    return fill;
}