List of usage examples for com.itextpdf.text Paragraph setSpacingBefore
public void setSpacingBefore(float spacing)
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable bodySection() throws Exception { String exportRefRemarks = ""; String routingInsRemarks = ""; String InsStatement = ""; StringBuilder pierValues = new StringBuilder(); String[] remarkTypes = { REMARKS_TYPE_ROUTING_INSTRU, REMARKS_TYPE_EXPORT_REF }; List remarks = new LclRemarksDAO().getRemarksByTypes(lclbl.getFileNumberId(), remarkTypes); for (Object row : remarks) { Object[] col = (Object[]) row; if (col[1].toString().equalsIgnoreCase("Export Reference")) { exportRefRemarks = col[0].toString(); }/*from www . ja v a 2s . c om*/ if (col[1].toString().equalsIgnoreCase("Routing Instruction")) { routingInsRemarks = col[0].toString(); } } String bill_type = lclbl.getBillingType(); billingType = bill_type.equalsIgnoreCase("P") ? "** FREIGHT PREPAID **" : bill_type.equalsIgnoreCase("C") ? "** FREIGHT COLLECT **" : bill_type.equalsIgnoreCase("B") && "Y".equalsIgnoreCase(printPpdBlBothKey) ? "** FREIGHT PREPAID **" : "** FREIGHT COLLECT **"; billType = bill_type.equalsIgnoreCase("P") ? "PPD" : bill_type.equalsIgnoreCase("C") ? "COL" : "BOTH"; LclSsDetail bookedOrPickedVoy = null; ExportVoyageSearchModel pickedDetails = new LclUnitSsDAO() .getPickedVoyageByVessel(lclBooking.getFileNumberId(), "E"); if (pickedDetails != null && CommonUtils.isNotEmpty(pickedDetails.getUnitSsId())) { LclUnitSs lclUnitSs = new LclUnitSsDAO().findById(Long.parseLong(pickedDetails.getUnitSsId())); bookedOrPickedVoy = lclUnitSs.getLclSsHeader().getVesselSsDetail(); unitNumber = lclUnitSs.getLclUnit().getUnitNo(); voyageNumber = lclUnitSs.getLclSsHeader().getScheduleNo(); sealOut = CommonUtils.isNotEmpty(lclUnitSs.getSUHeadingNote()) ? lclUnitSs.getSUHeadingNote().toUpperCase() : ""; } else { bookedOrPickedVoy = null != lclbl.getBookedSsHeaderId() ? lclbl.getBookedSsHeaderId().getVesselSsDetail() : null; } StringBuilder carrierName = new StringBuilder(); if (bookedOrPickedVoy != null) { sailDate = DateUtils.formatStringDateToAppFormatMMM(bookedOrPickedVoy.getStd()); sailDateFormat = DateUtils.formatDateToMMMMDDYYYY(bookedOrPickedVoy.getStd()); ladenSailDateRemarks = "\nLaden On Board:" + sailDate; if (CommonFunctions.isNotNull(bookedOrPickedVoy.getSpReferenceName())) { carrierName.append(bookedOrPickedVoy.getSpReferenceName()).append(" "); } if (CommonUtils.isNotEmpty(bookedOrPickedVoy.getTransMode())) { carrierName.append(bookedOrPickedVoy.getTransMode()).append(". "); } if (CommonUtils.isNotEmpty(bookedOrPickedVoy.getSpReferenceNo())) { carrierName.append(bookedOrPickedVoy.getSpReferenceNo()); } pierValues.append(bookedOrPickedVoy.getDeparture().getUnLocationName()); if (null != bookedOrPickedVoy.getDeparture().getStateId()) { pierValues.append("/").append(bookedOrPickedVoy.getDeparture().getStateId().getCode()); } } Paragraph p = null; table = new PdfPTable(2); table.setWidthPercentage(100f); table.setWidths(new float[] { 5.3f, 4.7f }); PdfPCell bCell = null; bCell = new PdfPCell(); bCell.setBorder(0); bCell.setPadding(0f); bCell.setBorderWidthBottom(0.06f); bCell.setBorderWidthTop(0.06f); bCell.setBorderWidthRight(0.06f); PdfPTable bTable = new PdfPTable(2); bTable.setWidths(new float[] { 5f, 4f }); bTable.setWidthPercentage(100f); bTable.addCell(makeCellLeftTopNoBorderFont("SHIPPER/EXPORTER", -0.5f, 0.8f, blackBoldFont65)); PdfPCell shCell = new PdfPCell(); shCell.setBorder(0); shCell.setColspan(2); shCell.setPadding(0f); shCell.setPaddingLeft(4f); shCell.setBorderWidthBottom(0.06f); shCell.setFixedHeight(65f); String shipperDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getShipContact()); if (CommonUtils.isNotEmpty(shipperDetails)) { p = new Paragraph(11f, "" + shipperDetails.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(15f); } else { p = new Paragraph(8f, "", totalFontQuote); shCell.setPadding(35f); } shCell.addElement(p); bTable.addCell(shCell); //consignee bTable.addCell(makeCellLeftTopNoBorderFont("CONSIGNEE", -0.5f, 0.8f, blackBoldFont65)); //consignee Values PdfPCell cvCell = new PdfPCell(); cvCell.setBorder(0); cvCell.setColspan(2); cvCell.setPadding(0f); cvCell.setPaddingLeft(4f); cvCell.setBorderWidthBottom(0.06f); cvCell.setFixedHeight(65f); String consDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getConsContact()); if (CommonUtils.isNotEmpty(consDetails)) { p = new Paragraph(11f, "" + consDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(15f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); cvCell.setPadding(30f); } cvCell.addElement(p); bTable.addCell(cvCell); //Notify bTable.addCell(makeCellLeftTopNoBorderFont("NOTIFY PARTY", -0.5f, 0.8f, blackBoldFont65)); //consignee Values PdfPCell nvCell = new PdfPCell(); nvCell.setBorder(0); nvCell.setColspan(2); nvCell.setPadding(0f); nvCell.setPaddingLeft(4f); nvCell.setBorderWidthBottom(0.06f); nvCell.setFixedHeight(70f); String notyDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getNotyContact()); if (CommonUtils.isNotEmpty(notyDetails)) { p = new Paragraph(11f, "" + notyDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(25f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); nvCell.setPadding(40f); } nvCell.addElement(p); bTable.addCell(nvCell); //place of receipt PdfPCell prCell = new PdfPCell(); prCell.setBorder(0); prCell.setPaddingLeft(-0.9f); prCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "PLACE OF RECEIPT", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); prCell.addElement(p); bTable.addCell(prCell); /* Pier Logic */ String pier = "N".equalsIgnoreCase(printPierPol) ? ("N".equalsIgnoreCase(printPierPol) && !"N".equalsIgnoreCase(hblPierOverRideKey)) ? hblPierOverRideKey : pierValues.toString() : ""; /* POL Logic */ String pol = ""; if ("Y".equalsIgnoreCase(printPierPol)) { if ("N".equalsIgnoreCase(hblPierOverRideKey)) { pol = pierValues.toString(); } else { pol = hblPierOverRideKey; } } else { pol = !"N".equalsIgnoreCase(hblPolOverRideKey) ? hblPolOverRideKey : polValues; } Boolean checkBlInsurance = new LclBlAcDAO().checkBlInsurance(lclbl.getFileNumberId(), INSURANCE_CHARGE_CODE); if (checkBlInsurance && "Y".equalsIgnoreCase(printBlInsuranceKey)) { InsStatement = LoadLogisoftProperties.getProperty("InsuranceChargeComment"); } PdfPCell pierCell = new PdfPCell(); pierCell.setBorder(0); pierCell.setBorderWidthLeft(0.06f); pierCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "PIER", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); pierCell.addElement(p); bTable.addCell(pierCell); //place of receipt values PdfPCell prvCell = new PdfPCell(); prvCell.setBorder(0); prvCell.setBorderWidthBottom(0.06f); if (lclBooking.getPooPickup()) { LclBookingPad lclBookingPad = lclBooking.getLclFileNumber().getLclBookingPadList().get(0); String pickUp_city = lclBookingPad.getPickUpCity().replaceAll("/", ","); pickUp_city = pickUp_city.substring(pickUp_city.indexOf("-") + 1, pickUp_city.length()); p = new Paragraph(7f, "" + pickUp_city.toUpperCase(), totalFontQuote); } else { StringBuilder placeofReceipt = new StringBuilder(); if (null != lclbl.getPortOfOrigin()) { placeofReceipt.append(lclbl.getPortOfOrigin().getUnLocationName()); if (CommonFunctions.isNotNull(lclbl.getPortOfOrigin().getStateId()) && CommonFunctions.isNotNull(lclbl.getPortOfOrigin().getStateId().getCode())) { placeofReceipt.append(",").append(lclbl.getPortOfOrigin().getStateId().getCode()); } } p = new Paragraph(7f, "" + placeofReceipt.toString().toUpperCase(), totalFontQuote); } p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); prvCell.addElement(p); bTable.addCell(prvCell); //pier values PdfPCell piervCell = new PdfPCell(); piervCell.setBorder(0); piervCell.setBorderWidthLeft(0.06f); piervCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + pier, totalFontQuote); p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); piervCell.addElement(p); bTable.addCell(piervCell); //exporting carrier PdfPCell ecCell = new PdfPCell(); ecCell.setBorder(0); ecCell.setPaddingLeft(-0.5f); ecCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "EXPORTING CARRIER (Vessel) (Flag)", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); ecCell.addElement(p); bTable.addCell(ecCell); //portof loading PdfPCell portCell = new PdfPCell(); portCell.setBorder(0); portCell.setPaddingTop(-0.2f); portCell.setBorderWidthLeft(0.06f); p = new Paragraph(7f, "PORT OF LOADING", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); portCell.addElement(p); bTable.addCell(portCell); //exporting values PdfPCell exvCell = new PdfPCell(); exvCell.setBorder(0); exvCell.setFixedHeight(15f); exvCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + carrierName.toString().toUpperCase(), totalFontQuote); p.setSpacingAfter(5f); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_LEFT); exvCell.addElement(p); bTable.addCell(exvCell); //port of loading values PdfPCell portvCell = new PdfPCell(); portvCell.setBorder(0); portvCell.setBorderWidthLeft(0.06f); portvCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + pol.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); portvCell.addElement(p); bTable.addCell(portvCell); //sea port of discharge PdfPCell seaCell = new PdfPCell(); seaCell.setBorder(0); seaCell.setPaddingLeft(-0.5f); seaCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "SEA PORT OF DISCHARGE", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); seaCell.addElement(p); bTable.addCell(seaCell); //finalde PdfPCell finalCell = new PdfPCell(); finalCell.setBorder(0); finalCell.setBorderWidthLeft(0.06f); finalCell.setPaddingTop(-0.2f); p = new Paragraph(7f, "FINAL DELIVERY TO", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); finalCell.addElement(p); bTable.addCell(finalCell); //sea values PdfPCell seavCell = new PdfPCell(); seavCell.setBorder(0); seavCell.setFixedHeight(25f); // seavCell.setBorderWidthBottom(0.06f); p = new Paragraph(7f, "" + podValues.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); seavCell.addElement(p); bTable.addCell(seavCell); //fina deliver values String finalDest = !fdOverride.equalsIgnoreCase("N") ? fdOverride : (agencyInfo != null && CommonUtils.isNotEmpty(agencyInfo[2])) ? agencyInfo[2] : blUtils.getBLConcatenatedFinalDestination(lclbl); PdfPCell finalvCell = new PdfPCell(); finalvCell.setBorder(0); finalvCell.setBorderWidthLeft(0.06f); p = new Paragraph(7f, !finalDest.equalsIgnoreCase(podValues) ? "" + finalDest.toUpperCase() : "", totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); finalvCell.addElement(p); bTable.addCell(finalvCell); bCell.addElement(bTable); table.addCell(bCell); //2column cell = new PdfPCell(); cell.setBorder(0); cell.setPadding(0f); cell.setBorderWidthBottom(0.06f); cell.setBorderWidthTop(0.06f); PdfPTable pTable = new PdfPTable(2); pTable.setWidths(new float[] { 4f, 2f }); pTable.setWidthPercentage(100f); PdfPCell nCell = null; nCell = new PdfPCell(); nCell.setBorder(0); nCell.setPaddingTop(0.2f); p = new Paragraph(7f, "DOCUMENT NO", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); nCell.addElement(p); pTable.addCell(nCell); nCell = new PdfPCell(); nCell.setBorder(0); nCell.setPaddingTop(0.2f); p = new Paragraph(7f, "PAGE : " + ++page_count, blackBoldFont65); p.setAlignment(Element.ALIGN_RIGHT); nCell.addElement(p); pTable.addCell(nCell); String consolidateNumber = new LclConsolidateDAO() .getConsolidatesFileNumbers(lclbl.getLclFileNumber().getId().toString()); consolidateNumber = null == consolidateNumber ? lclbl.getLclFileNumber().getFileNumber() : lclbl.getLclFileNumber().getFileNumber() + "," + consolidateNumber; PdfPCell dvCell = new PdfPCell(); dvCell.setBorder(0); dvCell.setColspan(2); dvCell.setBorderWidthBottom(0.06f); dvCell.setPaddingLeft(8f); dvCell.setPaddingBottom(5f); dvCell.setPaddingTop(2f); p = new Paragraph(8f, "" + consolidateNumber.toUpperCase(), totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); dvCell.addElement(p); pTable.addCell(dvCell); PdfPCell eCell = new PdfPCell(); eCell.setBorder(0); eCell.setPaddingTop(0.2f); eCell.setColspan(2); p = new Paragraph(7f, "EXPORT REFERENCE", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); eCell.addElement(p); pTable.addCell(eCell); PdfPCell evCell = new PdfPCell(); evCell.setBorder(0); evCell.setColspan(2); evCell.setBorderWidthBottom(0.06f); evCell.setPaddingLeft(8f); evCell.setFixedHeight(35f); exportRefRemarks = exportRefRemarks + ("EXPORT".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "") + ("EXPORT".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : ""); if (exportRefRemarks != null && !exportRefRemarks.equals("")) { p = new Paragraph(10f, "" + exportRefRemarks, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", contentBLNormalFont); } evCell.addElement(p); pTable.addCell(evCell); PdfPCell fCell = new PdfPCell(); fCell.setBorder(0); fCell.setColspan(2); fCell.setPaddingTop(0.2f); p = new Paragraph(7f, "FORWARDING AGENT-REFERENCES", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); fCell.addElement(p); pTable.addCell(fCell); //forwarding avlues PdfPCell fvCell = new PdfPCell(); fvCell.setBorder(0); fvCell.setColspan(2); fvCell.setPaddingLeft(3f); fvCell.setPaddingTop(2f); fvCell.setBorderWidthBottom(0.06f); fvCell.setFixedHeight(65f); if (null != lclbl.getFwdAcct() && !lclbl.getFwdAcct().getAccountName().equalsIgnoreCase("NO FRT. FORWARDER ASSIGNED")) { boolean forwarderAcctFlag = new LCLBlDAO() .getFreightForwardAcctStatus(lclbl.getFwdAcct().getAccountno()); String fwdDetails = lclUtils.getConcatenatedAccountDetails(lclbl.getFwdContact()); if (CommonUtils.isNotEmpty(fwdDetails) && !forwarderAcctFlag) { p = new Paragraph(11f, "" + fwdDetails.toUpperCase(), totalFontQuote); p.setSpacingAfter(15f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", totalFontQuote); fvCell.setPadding(25f); } fvCell.addElement(p); pTable.addCell(fvCell); } else { p = new Paragraph(8f, "", totalFontQuote); fvCell.setBorderWidthBottom(0.06f); pTable.addCell(fvCell); } //pointoforigin PdfPCell pCell = new PdfPCell(); pCell.setBorder(0); pCell.setColspan(2); pCell.setPaddingTop(0.2f); p = new Paragraph(7f, "POINT AND COUNTRY OF ORIGIN", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); pCell.addElement(p); pTable.addCell(pCell); //point avlues PdfPCell pvCell = new PdfPCell(); pvCell.setBorder(0); pvCell.setColspan(2); pvCell.setPaddingLeft(8f); pvCell.setPaddingBottom(5f); pvCell.setPaddingTop(2f); pvCell.setFixedHeight(20f); pvCell.setBorderWidthBottom(0.06f); if (lclbl.getPointOfOrigin() != null) { p = new Paragraph(9f, "" + lclbl.getPointOfOrigin(), totalFontQuote); pvCell.addElement(p); } p.setAlignment(Element.ALIGN_LEFT); pTable.addCell(pvCell); //domes PdfPCell doCell = new PdfPCell(); doCell.setBorder(0); doCell.setColspan(2); doCell.setPaddingTop(0.2f); p = new Paragraph(7f, "DOMESTIC ROUTING/EXPORT INSTRUCTIONS", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); doCell.addElement(p); pTable.addCell(doCell); //point avlues PdfPCell dovCell = new PdfPCell(); dovCell.setBorder(0); dovCell.setColspan(2); dovCell.setPaddingLeft(8f); dovCell.setBorderWidthBottom(0.06f); dovCell.setFixedHeight(45f); routingInsRemarks = routingInsRemarks + ("ROUTING".equalsIgnoreCase(ladenSailDateOptKey) ? ladenSailDateRemarks : "") + ("ROUTING".equalsIgnoreCase(printTermsTypeKey) ? termsType1 : ""); if (routingInsRemarks != null && !"".equalsIgnoreCase(routingInsRemarks)) { p = new Paragraph(10f, "" + routingInsRemarks, totalFontQuote); p.setSpacingAfter(10f); p.setAlignment(Element.ALIGN_LEFT); } else { p = new Paragraph(8f, "", contentBLNormalFont); dovCell.setPadding(15f); } dovCell.addElement(p); pTable.addCell(dovCell); //addito PdfPCell adCell = new PdfPCell(); adCell.setBorder(0); adCell.setColspan(2); adCell.setPaddingTop(0.2f); p = new Paragraph(7f, "ADDITIONAL DOCUMENT NUMBERS", blackBoldFont65); p.setAlignment(Element.ALIGN_LEFT); adCell.addElement(p); pTable.addCell(adCell); //add values PdfPCell advCell = new PdfPCell(); advCell.setBorder(0); advCell.setColspan(2); advCell.setPadding(10f); p = new Paragraph(7f, InsStatement, totalFontQuote); p.setAlignment(Element.ALIGN_LEFT); advCell.addElement(p); pTable.addCell(advCell); cell.addElement(pTable); table.addCell(cell); return table; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public PdfPTable addingCommodityValues() throws DocumentException, ParseException, Exception { Font font6 = new Font(FontFamily.COURIER, 6f, Font.BOLD); Font blackContentNormalFont8 = FontFactory.getFont("Arial", 8f, Font.NORMAL); Paragraph p = null; table = new PdfPTable(5); table.setWidthPercentage(100f);/*w w w . ja va 2 s . co m*/ table.setWidths(new float[] { 2.74f, 1f, 6.33f, 1.40f, 1.40f }); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(0); cell.setBorderWidthLeft(0.6f); p = new Paragraph(7f, " " + ipeHotCodeComments, blackContentNormalFont8); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(2f); cell.addElement(p); p = new Paragraph(7f, "" + billingType, totalFontQuote); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(2f); cell.addElement(p); if ("Y".equalsIgnoreCase(receiveKeyValue)) { p = new Paragraph(7f, "*** PLEASE NOTE THAT PAYMENT MUST BE RECEIVED PRIOR TO ISSUING EXPRESS RELEASE / ORIGINAL HBL ***", blackContentNormalFont8); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); } p = new Paragraph(7f, "I HEREBY DECLARE THAT THE ABOVE NAMED MATERIALS ARE PROPERLY CLASSIFIED," + "\n" + "DESCRIBED,PACKAGED, MARKED, AND LABELED, AND ARE IN PROPER CONDITION FOR" + "\n" + "TRANSPORTATION ACCORDING TO THE APPLICABLE REGULATIONS OF THE DEPARTMENT" + "\n" + " OF TRANSPORTATION AND IMO.", font6); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(0); cell.setBorderWidthLeft(0.6f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthLeft(0.6f); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(5); p = new Paragraph(7f, " Declared value per Package if value is More Than $500 Per Package USD___________________________", blackContentNormalFont8); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingBefore(5f); cell.addElement(p); p = new Paragraph(7f, "These Commodities, Technology Or Software Were Exported From the United States in Accordance with the Export " + "Administration Regulations.", blackContentNormalFont8); p.setSpacingBefore(5f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); p = new Paragraph(7f, "Diversion Contrary To U.S. Law Prohibited.", blackContentNormalFont8); p.setSpacingBefore(3f); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.kohmiho.mpsr.export.PDFGenerator.java
@SuppressWarnings("unchecked") protected void fillColumnText(List<HashMap<String, Object>> bookmarkList, ColumnText ct, float leftIndent, int depth, Font font) { if (null != bookmarkList) { for (int i = 0; i < bookmarkList.size(); i++) { HashMap<String, Object> bookmark = bookmarkList.get(i); String title = (String) bookmark.get("Title"); String pageNum = ((String) bookmark.get("Page")).split(" ")[0]; Paragraph paragraph = null != font ? new Paragraph(title, font) : new Paragraph(title); // paragraph.add(new Chunk(new VerticalPositionMark())); paragraph.add(new Chunk(new DottedLineSeparator())); paragraph.add(Integer.toString((Integer.parseInt(pageNum) - 1))); paragraph.setIndentationLeft(leftIndent * depth); paragraph.setSpacingBefore(0 == depth ? 9 : 0); ct.addElement(paragraph);//from ww w. ja v a 2s . c o m fillColumnText(((List<HashMap<String, Object>>) bookmark.get("Kids")), ct, leftIndent, depth + 1, null); } } }
From source file:com.kohmiho.mpsr.export.PDFGenerator.java
private void addSectionTitle(Document document, String sectionTitle, Font fontChapterHeader, int indentation, int spacingBefore, int spacingAfter) throws DocumentException { Paragraph paragraph = new Paragraph(); paragraph.setSpacingBefore(spacingBefore); paragraph.setSpacingAfter(spacingAfter); paragraph.setIndentationLeft(indentation); paragraph.setFont(fontChapterHeader); paragraph.add(new Phrase(sectionTitle)); document.add(paragraph);//from www . j av a2 s .c o m }
From source file:com.kohmiho.mpsr.export.PDFGenerator.java
private void addParagraph(Document document, PdfWriter writer, XMLWorkerHelper xmlWorker, String data, Font font, int indentationLeft, int spacingBefore, int spacingAfter) throws DocumentException, IOException { if (!data.startsWith("<")) { Paragraph paragraph = new Paragraph(); paragraph.setIndentationLeft(indentationLeft); paragraph.setSpacingBefore(spacingBefore); paragraph.setSpacingAfter(spacingAfter); if (null != font) paragraph.setFont(font);// www . ja v a 2 s . c om paragraph.add(data); document.add(paragraph); } else { xmlWorker.parseXHtml(writer, document, new StringReader(data)); } }
From source file:com.kohmiho.mpsr.export.PDFGenerator.java
private void addImage(Document document, String filename, String caption, Font font, int indentationLeft, int spacingBefore, int spacingAfter) throws BadElementException, MalformedURLException, IOException, DocumentException { if (null == filename) { addParagraph(document, null, null, String.format("[*** No Picture for %s ***]", caption), font, indentationLeft, 0, 0);//w ww . j av a 2 s . co m return; } try { Paragraph paragraph = new Paragraph(); paragraph.setIndentationLeft(indentationLeft); paragraph.setSpacingBefore(spacingBefore); paragraph.setSpacingAfter(spacingAfter); if (null != font) paragraph.setFont(font); paragraph.setKeepTogether(true); paragraph.setAlignment(Element.ALIGN_CENTER); Image image = Image.getInstance(filename); image.scaleToFit(400, 400); paragraph.add(new Chunk(image, 0, 0, true)); paragraph.add(new Chunk("\n")); paragraph.add(caption); document.add(paragraph); } catch (Exception e) { addParagraph(document, null, null, String.format("[*** Unable to render picture for %s ***]", caption), font, indentationLeft, 0, 0); } }
From source file:com.masscustsoft.service.ToPdf.java
License:Open Source License
private com.itextpdf.text.List getList(Map row) throws Exception { String type = (String) row.get("type"); com.itextpdf.text.List list = null; if ("greek".equals(type)) list = new GreekList(); else if ("roman".equals(type)) list = new RomanList(); else if ("zd".equals(type)) list = new ZapfDingbatsList(1); else if ("zd#".equals(type)) list = new ZapfDingbatsNumberList(1); else/*from w w w. jav a 2 s . c o m*/ list = new com.itextpdf.text.List(); Integer charNumber = (Integer) row.get("charNumber"); if (charNumber != null) { if (list instanceof ZapfDingbatsList) { ((ZapfDingbatsList) list).setCharNumber(charNumber); } if (list instanceof ZapfDingbatsNumberList) { ((ZapfDingbatsNumberList) list).setType(charNumber); } } Boolean lowercase = (Boolean) row.get("lowercase"); if (lowercase != null) list.setLowercase(lowercase); Boolean numbered = (Boolean) row.get("numbered"); if (numbered != null) list.setNumbered(numbered); Boolean lettered = (Boolean) row.get("lettered"); if (lettered != null) list.setLettered(lettered); Integer first = (Integer) row.get("first"); if (first != null) list.setFirst(first); String symbol = (String) row.get("symbol"); if (symbol != null) { Paragraph p = new Paragraph(); getChunks(p, row, symbol); if (p.size() > 0) { Object sym = p.get(0); if (sym instanceof Chunk) { list.setListSymbol((Chunk) sym); } } } Float ident = (Float) row.get("ident"); if (ident == null) ident = 10f; list.setSymbolIndent(ident); List<Map> lst = (List) row.get("items"); if (lst != null) { for (Map item : lst) { Element el = getElement(item); if (el != null) { ListItem li = new ListItem(); li.add(el); list.add(li); } } } if (list.size() > 0) { Object o = list.getItems().get(0); if (o instanceof Paragraph) { Paragraph p = (Paragraph) o; Float spaceBefore = (Float) row.get("spaceBefore"); if (spaceBefore != null) p.setSpacingBefore(spaceBefore); } o = list.getItems().get(list.getItems().size() - 1); if (o instanceof Paragraph) { Paragraph p = (Paragraph) o; Float spaceAfter = (Float) row.get("spaceAfter"); if (spaceAfter != null) p.setSpacingAfter(spaceAfter); } } return list; }
From source file:com.mycompany.peram_inclassexam.WritePDFFile.java
public void createPDF(AccountDetails account) throws DocumentException, FileNotFoundException, BadElementException, IOException { Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter write = PdfWriter.getInstance(document, new FileOutputStream(account.getLastName() + "_output.pdf")); document.open();// w w w .java 2 s .co m Image image = Image.getInstance("image.png"); image.scaleToFit(450f, 1800f); document.add(image); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); Paragraph welcomeParagraph = new Paragraph( "Welcome! " + account.getFirstName() + " " + account.getLastName() + "!"); welcomeParagraph.setSpacingBefore(50); document.add(welcomeParagraph); String firstName = "First Name: " + account.getFirstName(); String lastName = "Last Name: " + account.getLastName(); String acctNumber = "Account Number: " + account.getAccountNo(); String acctBalance = String.format("Account Balance: $%.1f", account.getAccountBalance()); Paragraph detailsPara = new Paragraph("Below are your Account Details:\n" + firstName + "\n" + lastName + "\n" + acctNumber + "\n" + acctBalance); detailsPara.setIndentationLeft(30); detailsPara.setSpacingBefore(20); document.add(detailsPara); document.close(); write.close(); }
From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java
License:Open Source License
public int generate(String saveUrl, SerializableBitmap sign, Form form, ArrayList<String> photos, ArrayList<String> workers) { try {/*from w w w. j av a 2s . c om*/ Document document = new Document(); url = saveUrl; PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(url)); document.setMargins(20, 20, 20, 20); document.open(); Bitmap inputLogo = BitmapFactory.decodeStream(context.getAssets().open("logo.jpg")); ByteArrayOutputStream outstream = new ByteArrayOutputStream(); inputLogo.compress(Bitmap.CompressFormat.JPEG, 100, outstream); Image logo = Image.getInstance(outstream.toByteArray()); Bitmap inputQR = BitmapFactory.decodeStream(context.getAssets().open("qr.jpg")); outstream = new ByteArrayOutputStream(); inputQR.compress(Bitmap.CompressFormat.JPEG, 100, outstream); Image qr = Image.getInstance(outstream.toByteArray()); outstream = new ByteArrayOutputStream(); sign.getImage().compress(Bitmap.CompressFormat.JPEG, 100, outstream); Image sgn = Image.getInstance(outstream.toByteArray()); qr.scaleAbsolute(90f, 90f); qr.setAbsolutePosition(340f, 705f); logo.scaleAbsolute(150f, 50f); logo.setAbsolutePosition(50f, 750f); sgn.scaleAbsolute(130f, 30f); sgn.setAbsolutePosition(25f, 75f); Paragraph p = new Paragraph("\r\n\r\n\r\nMPWiK S.A.\r\n50-421 Wrocaw\r\nul.Na Grobli 14-16", normal); p.setIndentationLeft(420f); document.add(p); p = new Paragraph("RAPORT WYMIANY WODOMIERZA", bold); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingBefore(60f); document.add(p); document.add(table(form)); p = new Paragraph(form.getInformations(), normal); p.setAlignment(Element.ALIGN_LEFT); p.setIndentationLeft(50f); p.setSpacingBefore(20f); document.add(p); document.add(signTable(form, sgn, workers)); document.add(logo); document.add(qr); if (photos != null && photos.size() > 0) { document.newPage(); for (int i = 0; i < photos.size(); i++) { try { if (photos.get(i) != null && !photos.get(i).equals("")) { Log.d(TAG, photos.get(i)); Bitmap temp = PictureHelper.bitmapFromUrl(photos.get(i)); outstream = new ByteArrayOutputStream(); temp.compress(Bitmap.CompressFormat.JPEG, 100, outstream); Image photo = Image.getInstance(outstream.toByteArray()); photo.scaleToFit(document.getPageSize().getWidth() - 50, document.getPageSize().getHeight()); document.add(photo); } } catch (Exception e) { } } } document.close(); writer.close(); return 1; } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); return 0; } catch (DocumentException e) { Log.e(TAG, e.getMessage()); return 0; } catch (IOException e) { Log.e(TAG, e.getMessage()); return 0; } catch (Exception e) { Log.e(TAG, e.getMessage()); return 0; } }
From source file:control.listaEquipos.java
private boolean generapdf(String path) throws DocumentException, FileNotFoundException { boolean estado = false; Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();/*from w w w. ja va 2 s. c o m*/ Paragraph paragraph1 = new Paragraph("Equipos"); document.add(paragraph1); Paragraph paragraph2 = new Paragraph(""); paragraph2.setSpacingBefore(38f); document.add(paragraph2); PdfPTable table = new PdfPTable(7); table.addCell("Id "); table.addCell("Nombre"); table.addCell("categoria"); table.addCell("Accesorios"); table.addCell("Descripcion"); table.addCell("Marca"); table.addCell("Estado"); Object[][] tabla = this.getTableData(tabEquipo); for (Object[] o : tabla) { int i = 0; for (Object e : o) { if (i <= 6) { if (e != null) table.addCell(((String) e.toString())); else table.addCell(""); } i++; } } document.add(table); document.close(); return true; }