protected void apply(PdfPCell cell, RenderingContext context, PJsonObject params) { if (paddingLeft != null) cell.setPaddingLeft(paddingLeft.floatValue()); if (paddingRight != null) cell.setPaddingRight(paddingRight.floatValue()); if (paddingTop != null) cell.setPaddingTop(paddingTop.floatValue()); if (paddingBottom != null) cell.setPaddingBottom(paddingBottom.floatValue()); if (borderWidthLeft != null) cell.setBorderWidthLeft(borderWidthLeft.floatValue()); if (borderWidthRight != null) cell.setBorderWidthRight(borderWidthRight.floatValue()); if (borderWidthTop != null) cell.setBorderWidthTop(borderWidthTop.floatValue()); if (borderWidthBottom != null) cell.setBorderWidthBottom(borderWidthBottom.floatValue()); if (getBorderColorLeftVal(context, params) != null) cell.setBorderColorLeft(getBorderColorLeftVal(context, params)); if (getBorderColorRightVal(context, params) != null) cell.setBorderColorRight(getBorderColorRightVal(context, params)); if (getBorderColorTopVal(context, params) != null) cell.setBorderColorTop(getBorderColorTopVal(context, params)); if (getBorderColorBottomVal(context, params) != null) cell.setBorderColorBottom(getBorderColorBottomVal(context, params)); if (getBackgroundColorVal(context, params) != null) cell.setBackgroundColor(getBackgroundColorVal(context, params)); if (align != null) cell.setHorizontalAlignment(align.getCode()); if (vertAlign != null) cell.setVerticalAlignment(vertAlign.getCode()); }
public static PdfPCell resetPaddings( PdfPCell cell, float top, float bottom, float left, float right) { cell.setPaddingTop(top); cell.setPaddingBottom(bottom); cell.setPaddingLeft(left); cell.setPaddingRight(right); return cell; }
@Override public Element getITextElement() { PdfPCell cell = new PdfPCell(); cell.setBorderColorTop(getBorderTopColor()); cell.setBorderColorBottom(getBorderBottomColor()); cell.setBorderColorLeft(getBorderLeftColor()); cell.setBorderColorRight(getBorderRightColor()); cell.setBorderWidthTop(APdfBuilder.mmToPoints(getBorderTopWidth())); cell.setBorderWidthBottom(APdfBuilder.mmToPoints(getBorderBottomWidth())); cell.setBorderWidthLeft(APdfBuilder.mmToPoints(getBorderLeftWidth())); cell.setBorderWidthRight(APdfBuilder.mmToPoints(getBorderRightWidth())); cell.setPadding(0); cell.setPaddingTop(APdfBuilder.mmToPoints(getPaddingTop())); cell.setPaddingBottom(APdfBuilder.mmToPoints(getPaddingBottom())); cell.setPaddingLeft(APdfBuilder.mmToPoints(getPaddingLeft())); cell.setPaddingRight(APdfBuilder.mmToPoints(getPaddingRight())); cell.setExtraParagraphSpace(0); cell.setIndent(0); cell.setUseBorderPadding(false); cell.setBackgroundColor(getBackgroundColor()); cell.setColspan(getColspan()); for (ItextElement element : elements) cell.addElement(element.getITextElement()); return cell; }
private void drawOGHeader( Document document, UserShopForm sForm, String pImageName, boolean personal) throws DocumentException { // add the logo try { Image i = Image.getInstance(pImageName); float x = document.leftMargin(); float y = document.getPageSize().getHeight() - i.getHeight() - 5; i.setAbsolutePosition(x, y); document.add(i); } catch (Exception e) { e.printStackTrace(); } if (catalogOnly) { return; } // unfortuanately this means we are limited to PDF rendering only. // get the user's personal info PdfPTable personalInfo; if (personal) { personalInfo = getPersonalized(sForm); } else { personalInfo = getNonPersonalized(sForm); } if (null != sForm.getAppUser().getUserAccount() && null != sForm.getAppUser().getUserAccount().getSkuTag()) { String t = sForm.getAppUser().getUserAccount().getSkuTag().getValue(); if (t != null && t.length() > 0) { mSkuTag = t; } } // Display the contact info PdfPTable contactInfo = new PdfPTable(2); contactInfo.setWidthPercentage(50); contactInfo.setWidths(sizes); contactInfo.getDefaultCell().setBorder(borderType); contactInfo.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT); String orderOnlineStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.orderOnLine:", null); contactInfo.addCell(makePhrase(orderOnlineStr + " ", smallHeading, false)); contactInfo.addCell( makePhrase( sForm.getAppUser().getUserStore().getStorePrimaryWebAddress().getValue(), smallHeading, true)); ContactUsInfo contact = null; if (sForm.getAppUser().getContactUsList().size() == 1) { contact = (ContactUsInfo) sForm.getAppUser().getContactUsList().get(0); } String orderFaxNumber = null, bscdesc = null; if (sForm.getAppUser().getSite().getBSC() != null && sForm.getAppUser().getSite().getBSC().getFaxNumber() != null && sForm.getAppUser().getSite().getBSC().getFaxNumber().getPhoneNum() != null) { orderFaxNumber = sForm.getAppUser().getSite().getBSC().getFaxNumber().getPhoneNum(); bscdesc = sForm.getAppUser().getSite().getBSC().getBusEntityData().getLongDesc(); } if (orderFaxNumber == null && contact != null) { orderFaxNumber = contact.getFax(); } if (orderFaxNumber != null) { String faxOrderStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.faxOrder:", null); contactInfo.addCell(makePhrase(faxOrderStr + " ", smallHeading, false)); contactInfo.addCell(makePhrase(orderFaxNumber, smallHeading, true)); } if (null != bscdesc && bscdesc.length() > 0) { // if there is a BSC descripton set, then show // that information. PdfPCell cell = new PdfPCell(new Paragraph(bscdesc, smallHeading)); cell.disableBorderSide(PdfPCell.LEFT); cell.disableBorderSide(PdfPCell.RIGHT); cell.disableBorderSide(PdfPCell.TOP); cell.disableBorderSide(PdfPCell.BOTTOM); cell.setColspan(2); cell.setPaddingTop(6); contactInfo.addCell(cell); } else { // otherwise show the standard contact us information // request for dmsi - dhl for eric. durval 11/1/2005. if (contact != null) { contactInfo.addCell(makePhrase(" ", smallHeading, false)); contactInfo.addCell(makePhrase(" ", smallHeading, true)); String contactUsStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.contactUs", null); contactInfo.addCell(makePhrase(contactUsStr + " ", smallHeading, false)); contactInfo.addCell(makePhrase("", smallHeading, true)); String phoneStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.phone:", null); contactInfo.addCell(makePhrase(phoneStr + " ", smallHeading, false)); contactInfo.addCell( makePhrase( "" + contact.getPhone() + " " + contact.getCallHours(), smallHeading, true)); String emailStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.email:", null); contactInfo.addCell(makePhrase(emailStr + " ", smallHeading, false)); contactInfo.addCell(makePhrase(contact.getEmail(), smallHeading, true)); } } // make the two tables into one PdfPTable wholeTable = new PdfPTable(2); wholeTable.setWidthPercentage(100); wholeTable.setWidths(halves); wholeTable.getDefaultCell().setBorder(borderType); wholeTable.addCell(personalInfo); wholeTable.addCell(contactInfo); document.add(wholeTable); String ogcomments = ""; if (null != sForm.getAppUser().getSite() && null != sForm.getAppUser().getSite().getComments()) { ogcomments = sForm.getAppUser().getSite().getComments().getValue(); } if (null == ogcomments || ogcomments.length() == 0) { if (null != sForm.getAppUser().getUserAccount()) { ogcomments = sForm.getAppUser().getUserAccount().getComments().getValue(); } } // add the comments if there are any if (ogcomments != null && ogcomments.length() > 0) { document.add(makeBlankLine()); String commentsStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.comments:", null); document.add(makePhrase(commentsStr + " " + ogcomments, smallHeading, true)); } document.add(makeBlankLine()); String commentsStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.comments:", null); document.add( makePhrase( commentsStr + " " + "__________________________________________" + "__________________________________________" + "__________", smallHeading, true)); document.add( makePhrase( "__________" + "__________________________________________" + "__________________________________________" + "__________", smallHeading, true)); document.add( makePhrase( "__________" + "__________________________________________" + "__________________________________________" + "__________", smallHeading, true)); // Add an order guide note in the next page if a note is present. if (null != sForm.getAppUser().getUserAccount() && null != sForm.getAppUser().getUserAccount().getOrderGuideNote()) { String t = sForm.getAppUser().getUserAccount().getOrderGuideNote().getValue(); if (t != null && t.length() > 0) { document.newPage(); pageNumber = pageNumber + 1; // document.add(makeBlankLine()); document.add(makePhrase(t, smallHeading, true)); } } PdfPTable sort = new PdfPTable(1); sort.setWidthPercentage(100); sort.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); sort.getDefaultCell().setBorder(borderType); if (sForm.getOrderBy() == Constants.ORDER_BY_CATEGORY) { String sortedByCategoryStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.sortedBy:Category", null); sort.addCell(makePhrase(sortedByCategoryStr + " ", smallHeading, false)); } else if (sForm.getOrderBy() == Constants.ORDER_BY_CUST_SKU) { String sortedByOurSkuNumStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.sortedBy:OurSkuNum", null); sort.addCell(makePhrase(sortedByOurSkuNumStr, smallHeading, false)); } else { String sortedByProductNameStr = ClwI18nUtil.getMessage(mRequest, "shop.og.text.sortedBy:ProductName", null); sort.addCell(makePhrase(sortedByProductNameStr, smallHeading, false)); } document.add(sort); }