List of usage examples for com.itextpdf.text Element ALIGN_RIGHT
int ALIGN_RIGHT
To view the source code for com.itextpdf.text Element ALIGN_RIGHT.
Click Source Link
From source file:fxml.test.PDFService.java
private PdfPTable createDocumentHeader() throws IOException, BadElementException { //start creating header for the document...... PdfPTable headerTable = new PdfPTable(3); headerTable.setHorizontalAlignment(Element.ALIGN_LEFT); try {/*from ww w . j ava 2 s . c o m*/ headerTable.setTotalWidth(new float[] { 57.5f, 531.5f, 183f }); headerTable.setLockedWidth(true); } catch (DocumentException ex) { Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex); } Image image = Image.getInstance(getClass().getClassLoader().getResource("img/sust.jpg")); image.scalePercent(42f); image.setAlignment(Element.ALIGN_LEFT); PdfPCell imageCell = new PdfPCell(image, false); imageCell.setPaddingTop(6); imageCell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(imageCell); //start info table..... PdfPTable infoTable = new PdfPTable(1); infoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); String universityText = "SHAHJALAL UNIVERSITY OF SCIENCE & TECHNOLOGY SYLHET, BANGLADESH"; String tabulationText = "TABULATION SHEET"; String deptText = inputs.get(0).trim(); String s1 = inputs.get(1).trim(); String s2 = inputs.get(2).trim(); String semesterText = ("B.Sc (Engg.) " + s1 + " SEMESTER EXAMINATION " + s2); String session = inputs.get(3).trim(); String date = inputs.get(4).trim(); String sessionDateText = ("SESSION:" + session + " EXAMINATION HELD IN: " + date); infoTable.addCell(getCellForHeaderString(universityText, 0, false, 0, Element.ALIGN_CENTER, font10, true)); infoTable.addCell(getCellForHeaderString(tabulationText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable.addCell(getCellForHeaderString(deptText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable.addCell(getCellForHeaderString(semesterText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable .addCell(getCellForHeaderString(sessionDateText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); //end info table..... PdfPCell infoCell = new PdfPCell(infoTable); infoCell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(infoCell); PdfPCell resultPublishDateCell = new PdfPCell( new Paragraph("Result Published On............................", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD))); resultPublishDateCell.setBorder(Rectangle.NO_BORDER); resultPublishDateCell.setVerticalAlignment(Element.ALIGN_MIDDLE); resultPublishDateCell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(resultPublishDateCell); headerTable.setSpacingAfter(17.5f); // System.err.println("completed header table"); return headerTable; //end creating header for the document...... }
From source file:fxml.test.PDFService.java
private PdfPCell nameCellHelper(String args) { PdfPCell cell = new PdfPCell(new Paragraph(args, font9)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingBottom(2.5f);/*from w w w. j av a 2 s . c om*/ return cell; }
From source file:generators.InvoiceEventListener.java
@Override public void onEndPage(PdfWriter writer, Document document) { Font defaultFont = new Font(Font.FontFamily.TIMES_ROMAN, 12); try {/* w w w . j a v a 2s. c o m*/ PdfPTable footerTable = new PdfPTable(3); footerTable.setTotalWidth(document.right(document.leftMargin())); footerTable.getDefaultCell().setBorder(Rectangle.TOP); footerTable.addCell(new Paragraph("Lionsclub Oegstgeest/Warmond", defaultFont)); footerTable.completeRow(); footerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); footerTable.addCell(new Paragraph("Betaalrekening", defaultFont)); footerTable.addCell(new Paragraph(": ************", defaultFont)); footerTable.completeRow(); footerTable.addCell(new Paragraph("Inschrijvnummer KvK Rijnland", defaultFont)); footerTable.addCell(new Paragraph(": ************ ", defaultFont)); footerTable.completeRow(); footerTable.writeSelectedRows(0, -1, document.leftMargin(), document.bottom(footerTable.getTotalHeight()) - document.bottomMargin() + 15, writer.getDirectContent()); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT, new Phrase(String.format("%d", writer.getPageNumber()), defaultFont), document.right(), document.bottom() - document.bottomMargin() + 18, 0); } catch (Exception e) { e.printStackTrace(); } }
From source file:gov.utah.dts.det.ccl.actions.facility.information.license.reports.LicenseCertificate.java
private static void writePdf(License license, ByteArrayOutputStream ba, HttpServletRequest request) throws DocumentException, BadElementException { SimpleDateFormat df = new SimpleDateFormat("MMMM d, yyyy"); StringBuilder sb;//from w w w . ja v a 2s. c o m // Retrieve the certificate template to use as watermark ServletContext context = request.getSession().getServletContext(); String templatefile = context.getRealPath("/resources") + "/LicenseCertificateTemplate.pdf"; PdfReader reader = getTemplateReader(templatefile); if (reader != null && reader.getNumberOfPages() > 0) { Phrase phrase; // Create new document using the page size of the certificate template document Document document = new Document(reader.getPageSizeWithRotation(1), 0, 0, 0, 0); PdfWriter writer = PdfWriter.getInstance(document, ba); document.open(); // Get the writer under content byte for placing of watermark PdfContentByte under = writer.getDirectContentUnder(); PdfContentByte over = writer.getDirectContent(); // Retrieve the first page of the template document and wrap as an Image to use as new document watermark PdfImportedPage page = writer.getImportedPage(reader, 1); Image img = Image.getInstance(page); // Make sure the image has an absolute page position if (!img.hasAbsoluteX() || !img.hasAbsoluteY()) { img.setAbsolutePosition(0, 0); } under.addImage(img); /* * THE FOLLOWING TWO FUNCTION CALLS DISPLAY THE PAGE MARGINS AND TEXT COLUMN BORDERS FOR DEBUGGING TEXT PLACEMENT. * UNCOMMENT EACH FUNCTION CALL TO HAVE BORDERS DISPLAYED ON THE OUTPUT DOCUMENT. THIS WILL HELP WHEN YOU NEED * TO SEE WHERE TEXT WILL BE PLACED ON THE CERTIFICATE FORM. */ // Show the page margins //showPageMarginBorders(over); // Show the text column borders //showColumnBorders(over); ColumnText ct = new ColumnText(over); ct.setLeading(fixedLeading); // Add Facility Name to column String text = license.getFacility().getName(); if (text != null) { phrase = new Phrase(text.toUpperCase(), mediumfontB); phrase.setLeading(noLeading); ct.addText(phrase); ct.addText(Chunk.NEWLINE); } // Add Facility Site to column text = license.getFacility().getSiteName(); if (text != null) { phrase = new Phrase(text.toUpperCase(), mediumfontB); phrase.setLeading(noLeading); ct.addText(phrase); ct.addText(Chunk.NEWLINE); } // Add Facility Address to column text = license.getFacility().getLocationAddress().getAddressOne(); if (text != null) { phrase = new Phrase(text.toUpperCase(), mediumfontB); phrase.setLeading(noLeading); ct.addText(phrase); ct.addText(Chunk.NEWLINE); } text = license.getFacility().getLocationAddress().getCityStateZip(); if (text != null) { phrase = new Phrase(text.toUpperCase(), mediumfontB); phrase.setLeading(noLeading); ct.addText(phrase); ct.addText(Chunk.NEWLINE); } // Write column to document ct.setAlignment(Element.ALIGN_CENTER); ct.setSimpleColumn(COLUMNS[0][0], COLUMNS[0][1], COLUMNS[0][2], COLUMNS[0][3]); ct.go(); // Add Certification Service Code to column ct = new ColumnText(over); ct.setLeading(fixedLeading); String service = ""; if (license.getSpecificServiceCode() != null && StringUtils.isNotBlank(license.getSpecificServiceCode().getValue()) && DV_TREATMENT.equalsIgnoreCase(license.getSpecificServiceCode().getValue())) { service += DOMESTIC_VIOLENCE; } if (!license.getProgramCodeIds().isEmpty()) { // redmine 25410 mentalHealthLoop: for (PickListValue pkv : license.getProgramCodeIds()) { String program = pkv.getValue(); int idx = program.indexOf(" -"); if (idx >= 0) { String code = program.substring(0, idx); if (MENTAL_HEALTH_CODES.indexOf(code + ":") >= 0) { if (service.length() > 0) { service += " / "; } service += MENTAL_HEALTH; break mentalHealthLoop; } } } substanceAbuseLoop: for (PickListValue pkv : license.getProgramCodeIds()) { String program = pkv.getValue(); int idx = program.indexOf(" -"); if (idx >= 0) { String code = program.substring(0, idx); if (SUBSTANCE_ABUSE_CODES.indexOf(code + ":") >= 0) { if (service.length() > 0) { service += " / "; } service += SUBSTANCE_ABUSE; break substanceAbuseLoop; } } } } if (StringUtils.isNotBlank(license.getServiceCodeDesc())) { if (service.length() > 0) { service += " / "; } service += license.getServiceCodeDesc(); } if (StringUtils.isNotEmpty(service)) { phrase = new Phrase(service.toUpperCase(), mediumfont); phrase.setLeading(noLeading); ct.addText(phrase); ct.addText(Chunk.NEWLINE); } // Add CLIENTS Info to column sb = new StringBuilder("FOR "); if (license.getAgeGroup() == null || license.getAgeGroup().getValue().equalsIgnoreCase("Adult & Youth")) { // Adult & Youth if (license.getAdultTotalSlots() != null) { sb.append(license.getAdultTotalSlots().toString()); } sb.append(" ADULT AND YOUTH CLIENTS"); } else if (license.getAgeGroup().getValue().equalsIgnoreCase("Adult")) { // Adult if (license.getAdultTotalSlots() != null) { // Are male or female counts specified? sb.append(license.getAdultTotalSlots().toString()); sb.append(" ADULT"); if (license.getAdultFemaleCount() != null || license.getAdultMaleCount() != null) { // Does either the male or female count equal the total slot count? if ((license.getAdultFemaleCount() != null && license.getAdultFemaleCount().equals(license.getAdultTotalSlots()))) { sb.append(" FEMALE CLIENTS"); } else if (license.getAdultMaleCount() != null && license.getAdultMaleCount().equals(license.getAdultTotalSlots())) { sb.append(" MALE CLIENTS"); } else { sb.append(" CLIENTS, "); if (license.getAdultMaleCount() != null) { sb.append(license.getAdultMaleCount().toString() + " MALE"); } if (license.getAdultFemaleCount() != null) { if (license.getAdultMaleCount() != null) { sb.append(" AND "); } sb.append(license.getAdultFemaleCount().toString() + " FEMALE"); } if (license.getFromAge() != null || license.getToAge() != null) { sb.append(","); } } } else { sb.append(" CLIENTS"); } } else { sb.append(" ADULT CLIENTS"); } } else { // Youth if (license.getYouthTotalSlots() != null) { // Are male or female counts specified? sb.append(license.getYouthTotalSlots().toString()); sb.append(" YOUTH"); if (license.getYouthFemaleCount() != null || license.getYouthMaleCount() != null) { // Does either the male or female count equal the total slot count? if ((license.getYouthFemaleCount() != null && license.getYouthFemaleCount().equals(license.getYouthTotalSlots()))) { sb.append(" FEMALE CLIENTS"); } else if (license.getYouthMaleCount() != null && license.getYouthMaleCount().equals(license.getYouthTotalSlots())) { sb.append(" MALE CLIENTS"); } else { sb.append(" CLIENTS, "); if (license.getYouthMaleCount() != null) { sb.append(license.getYouthMaleCount().toString() + " MALE"); } if (license.getYouthFemaleCount() != null) { if (license.getYouthMaleCount() != null) { sb.append(" AND "); } sb.append(license.getYouthFemaleCount().toString() + " FEMALE"); } if (license.getFromAge() != null || license.getToAge() != null) { sb.append(","); } } } else { sb.append(" CLIENTS"); } } else { sb.append(" YOUTH CLIENTS"); } } if (license.getFromAge() != null || license.getToAge() != null) { sb.append(" AGES "); if (license.getFromAge() != null) { sb.append(license.getFromAge().toString()); if (license.getToAge() != null) { sb.append(" TO " + license.getToAge().toString()); } else { sb.append(" AND OLDER"); } } else { sb.append("TO " + license.getToAge().toString()); } } phrase = new Phrase(sb.toString(), mediumfont); phrase.setLeading(noLeading); ct.addText(phrase); ct.addText(Chunk.NEWLINE); // Add Certificate Comments if (StringUtils.isNotBlank(license.getCertificateComment())) { phrase = new Phrase(license.getCertificateComment().toUpperCase(), mediumfont); phrase.setLeading(noLeading); ct.addText(phrase); } // Write column to document ct.setAlignment(Element.ALIGN_CENTER); ct.setSimpleColumn(COLUMNS[1][0], COLUMNS[1][1], COLUMNS[1][2], COLUMNS[1][3]); ct.go(); // Add Certificate Start Date if (license.getStartDate() != null) { phrase = new Phrase(df.format(license.getStartDate()), mediumfont); phrase.setLeading(noLeading); ct = new ColumnText(over); ct.setSimpleColumn(phrase, COLUMNS[2][0], COLUMNS[2][1], COLUMNS[2][2], COLUMNS[2][3], fixedLeading, Element.ALIGN_RIGHT); ct.go(); } // Add Certificate End Date if (license.getEndDate() != null) { phrase = new Phrase(df.format(license.getEndDate()), mediumfont); phrase.setLeading(noLeading); ct = new ColumnText(over); ct.setSimpleColumn(phrase, COLUMNS[3][0], COLUMNS[3][1], COLUMNS[3][2], COLUMNS[3][3], fixedLeading, Element.ALIGN_LEFT); ct.go(); } // Add License Number if (license.getLicenseNumber() != null) { phrase = new Phrase(license.getLicenseNumber().toString(), largefontB); phrase.setLeading(noLeading); ct = new ColumnText(over); ct.setSimpleColumn(phrase, COLUMNS[4][0], COLUMNS[4][1], COLUMNS[4][2], COLUMNS[4][3], numberLeading, Element.ALIGN_CENTER); ct.go(); } document.close(); } }
From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.LivescanAuthorization.java
private static void generateDocumentPage1(TrackingRecordScreeningLetter screeningLetter, Document document, PdfWriter writer) throws BadElementException, DocumentException, Exception { PdfPTable table = null;/*from w ww . j av a 2s . com*/ int headerwidths[] = {}; Paragraph paragraph = null; List blist = null; ListItem item = null; ListItem subItem = null; SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy"); // LS Authorization Letter Page 1 addLetterIdentifier(screeningLetter, document); paragraph = new Paragraph(fixedLeadingLarge); paragraph.add(new Phrase("Office of Licensing Authorization", largefontB)); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); paragraph = new Paragraph(fixedLeadingLarge); paragraph.add(new Phrase("for Electronic Background Check", largefontB)); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); paragraph = new Paragraph(fixedLeadingLarge); paragraph.add(new Phrase(df.format(screeningLetter.getLetterDate()), mediumfontB)); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); paragraph = new Paragraph(fixedLeadingMedium); paragraph.add(new Phrase("Office of Licensing Information", mediumfontU)); paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("Type of Background Check Required and Agency Billing Code:", smallfont)); paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); /* * Start of Billing information line generation */ table = new PdfPTable(3); // format the table headerwidths = new int[] { 20, 45, 35 }; // percentage table.setWidths(headerwidths); // percentage table.setWidthPercentage(100); table.setSpacingBefore(page1SeparatorSpace); table.getDefaultCell().setPadding(0); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // Add Billing Code if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling() != null && StringUtils.isNotBlank( screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling().getValue())) { table.addCell( new Phrase(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling().getValue(), xlargefontB)); } else { table.addCell(new Phrase(" ", xlargefontB)); } // Add Fee information paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("Search Fee = ", smallfont)); if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getSearchFee() != null) { paragraph.add(new Phrase( CommonUtils.fromDoubleToCurrency( screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getSearchFee()), smallfontB)); } else { paragraph.add(SMALL_BLANK); } paragraph.add(new Phrase(" / Scan Fee = ", smallfont)); if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getScanFee() != null) { paragraph .add(new Phrase( CommonUtils.fromDoubleToCurrency( screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getScanFee()), smallfontB)); } table.addCell(paragraph); // Add Facility Type information table.addCell(new Phrase("Licensed Treatment Programs", smallfont)); // Add Billing Information Line Table to document document.add(table); /* * End of Billing information line table generation */ // Add Check Number document line paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("Check Number ", smallfont)); if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && StringUtils .isNotBlank(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getMoNumber())) { paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getMoNumber(), smallfontB)); } paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); /* * Start of Check Issuer information line */ table = new PdfPTable(2); // format the table headerwidths = new int[] { 40, 60 }; // percentage table.setWidths(headerwidths); // percentage table.setWidthPercentage(100); table.setSpacingBefore(page1SeparatorSpace); table.getDefaultCell().setPadding(0); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // Add Issuer information paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("Issuer ", smallfont)); if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && StringUtils .isNotBlank(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getIssuedBy())) { paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getIssuedBy(), smallfontB)); } table.addCell(paragraph); // Add Program Name information paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("Program Name ", smallfont)); if (screeningLetter.getTrackingRecordScreening().getFacility() != null && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFacility().getName())) { paragraph.add( new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getName(), smallfontB)); } table.addCell(paragraph); // Add the Check Issuer table to the document document.add(table); /* * End of Check Issuer information line */ /* * Start of Applicant information line generation */ table = new PdfPTable(3); // format the table headerwidths = new int[] { 43, 20, 37 }; // percentage table.setWidths(headerwidths); // percentage table.setWidthPercentage(100); table.setSpacingBefore(page1SeparatorSpace); table.getDefaultCell().setPadding(0); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_MIDDLE); // Add Applicant name paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("Applicant ", smallfont)); if (screeningLetter.getTrackingRecordScreening().getPerson() != null && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFirstAndLastName())) { paragraph.add( new Phrase(screeningLetter.getTrackingRecordScreening().getFirstAndLastName(), smallfontB)); } table.addCell(paragraph); // Add Applicant ID paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("ID ", smallfont)); if (StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getPersonIdentifier())) { paragraph.add( new Phrase(screeningLetter.getTrackingRecordScreening().getPersonIdentifier(), smallfontB)); } table.addCell(paragraph); // Add DOB information paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("DOB ", smallfont)); try { paragraph.add( new Phrase(df.format(screeningLetter.getTrackingRecordScreening().getBirthday()), smallfontB)); } catch (NullPointerException e) { } table.addCell(paragraph); // Add Applicant Information Line Table to document document.add(table); /* * End of Applicant information line generation */ // Add Facility Licensing Specialist Information paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("OL Representative ", smallfont)); if (screeningLetter.getTrackingRecordScreening().getFacility() != null && screeningLetter.getTrackingRecordScreening().getFacility().getLicensingSpecialist() != null && StringUtils.isNotBlank(screeningLetter.getTrackingRecordScreening().getFacility() .getLicensingSpecialist().getFirstAndLastName())) { paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility() .getLicensingSpecialist().getFirstAndLastName(), smallfontB)); } paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); // Add Distribution Line paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase( "Distribution: Original for the Applicant to turn in to the Live Scan Operator. Copy retained by Office of Licensing.", smallfont)); paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); // Add Program & Applicatant header line paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("Program & Applicant Information and Instructions", smallfontBU)); paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); // Add READ THIS CAREFULLY paragraph = new Paragraph(fixedLeadingMedium); paragraph.add(new Phrase("READ THIS CAREFULLY", mediumfontB)); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); /* * Start of instructions list section */ blist = new List(false, 20); item = new ListItem(fixedLeadingSmall); item.setListSymbol(new Chunk("1.", mediumfont)); item.add(new Phrase( "The Office of Licensing authorizes the applicant to submit her/his fingerprints for an electronic applicant background check ", smallfont)); item.add(new Phrase( "at various sites throughout Utah using the Live Scan system. Please see the enclosed list for site information. Each site ", smallfont)); item.add(new Phrase( "charges a fee for the electronic fingerprint scan. Scanning fees vary from site to site. This is a separate fee from the ", smallfont)); item.add(new Phrase( "one submitted to the Department of Human Services for the actual criminal background search.", smallfont)); item.setSpacingBefore(page1ListSpace); blist.add(item); item = new ListItem(fixedLeadingSmall); item.setListSymbol(new Chunk("2.", mediumfont)); item.add(new Phrase( "Complete electronic fingerprint submission within 15 days of the date of this authorization letter. If unused, ", smallfontB)); item.add(new Phrase("requests for refunds will not be considered after 30 days. ", smallfontB)); item.setSpacingBefore(page1ListSpace); blist.add(item); item = new ListItem(fixedLeadingSmall); item.setListSymbol(new Chunk("", smallfont)); item.add(new Phrase( "Refund requests require a letter of explanation from the licensed program accompanied by this original authorization letter.", smallfontBU)); item.setSpacingBefore(4.0f); blist.add(item); item = new ListItem(fixedLeadingSmall); item.setListSymbol(new Chunk("", smallfont)); item.add(new Phrase( "Failure to complete electronic fingerprint submission within this time will result in the denial of the background screening ", smallfontB)); item.add(new Phrase( "clearance and the applicant will not be permitted to have direct access to children or vulnerable adults, will not be eligible ", smallfontB)); item.add(new Phrase( "to provide services to programs licensed by the Utah Department of Human Services, Office of Licensing, and will not be ", smallfontB)); item.add(new Phrase("eligible to proceed with foster care or adoption.", smallfontB)); item.setSpacingBefore(4.0f); blist.add(item); item = new ListItem(fixedLeadingSmall); item.setListSymbol(new Chunk("3.", mediumfont)); paragraph = new Paragraph(fixedLeadingSmall); paragraph.add(new Phrase("You will need to take with you:", smallfont)); item.add(paragraph); List subList = new List(false, 10); subList.setIndentationLeft(10); subItem = new ListItem(fixedLeadingSmall); subItem.add(new Phrase("This original letter. Photocopies and facsimile (FAX) copies will not be accepted.", smallfont)); subList.add(subItem); subItem = new ListItem(fixedLeadingSmall); subItem.add(new Phrase( "Photo identification in the form of your driver license or state identification card issued by the Division of Motor Vehicles.", smallfont)); subList.add(subItem); subItem = new ListItem(fixedLeadingSmall); subItem.add(new Phrase("Social Security Card", smallfont)); subList.add(subItem); subItem = new ListItem(fixedLeadingSmall); subItem.add( new Phrase("Cash or check as required (see site list for acceptable form of payment).", smallfont)); subList.add(subItem); item.add(subList); item.setSpacingBefore(page1ListSpace); blist.add(item); item = new ListItem(fixedLeadingSmall); item.setListSymbol(new Chunk("4.", mediumfont)); item.add(new Phrase( "If the electronically submitted fingerprints are rejected, the Office of Licensing will notify the applicant/licensed program ", smallfont)); item.add(new Phrase("of additional instructions for completing the nationwide background search.", smallfont)); item.setSpacingBefore(page1ListSpace); blist.add(item); item = new ListItem(fixedLeadingSmall); item.setListSymbol(new Chunk("5.", mediumfont)); item.add(new Phrase("Legibly print the following information for the scanning operator:", smallfont)); item.setSpacingBefore(page1ListSpace); blist.add(item); document.add(blist); document.add(getPage1WriteInLine1()); document.add(getPage1WriteInLine2()); document.add(getPage1WriteInLine3()); blist = new List(false, 20); item = new ListItem(fixedLeadingSmall); item.setListSymbol(new Chunk("6.", mediumfont)); item.add(new Phrase( "Applicant Signature ___________________________________________________ Date ________________", smallfont)); item.setSpacingBefore(page1ListSpace); blist.add(item); document.add(blist); paragraph = new Paragraph(); paragraph.add(new Phrase( "A current list of Livescan sites is available at www.hslic.utah.gov/docs/livescan sites.pdf", smallfontB)); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); if (screeningLetter.getTrackingRecordScreening().getTrsDpsFbi() != null && screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling() != null && StringUtils.isNotBlank( screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling().getValue())) { paragraph = new Paragraph(); paragraph.add( new Phrase(screeningLetter.getTrackingRecordScreening().getTrsDpsFbi().getBilling().getValue(), xlargefontB)); paragraph.setAlignment(Element.ALIGN_RIGHT); paragraph.setSpacingBefore(page1SeparatorSpace); document.add(paragraph); } /* * End of instructions list section */ }
From source file:gov.va.cem.eoas.business.FaxArchivesPDF.java
public InputStream generatePDF(FaxRecord data) { SimpleDateFormat newFormat = new SimpleDateFormat("MM/dd/yyyy"); Date curDate = new Date(); String caseIdData = (data.getCaseId() != null) ? data.getCaseId() : ""; String currentDate = new String(newFormat.format(curDate)); String sepDocs = (data.getSepDocs()) ? "X" : ""; String marLicense = (data.getMarLicense()) ? "X" : ""; String adminDecision = (data.getAdminDecision()) ? "X" : ""; String deathCert = (data.getDeathCert()) ? "X" : ""; String divorceDecree = (data.getDivorceDecree()) ? "X" : ""; String otherCheck = (data.getOtherCheck()) ? "X" : ""; String transDate = (data.getTransDate() != null) ? new String(newFormat.format(data.getTransDate())) : ""; String priorLoc = (data.getPriorLoc() != null) ? data.getPriorLoc() : ""; String otherComments = (data.getOtherComments() != null) ? data.getOtherComments() : ""; String remarks = (data.getRemarks() != null) ? data.getRemarks() : ""; String to = data.getTo().getDisplayName(); String fileNo = (data.getFileNo() != null) ? data.getFileNo() : ""; String vetName = (data.getVetName() != null) ? data.getVetName() : ""; String ssnData = (data.getSSN() != null) ? data.getSSN() : ""; String snData = (data.getSN() != null) ? data.getSN() : ""; String farcNo = (data.getFarcNo() != null) ? data.getFarcNo() : ""; String boxNoData = (data.getBoxNo() != null) ? data.getBoxNo() : ""; String faxPages = (data.getFaxPages() != null) ? data.getFaxPages() : ""; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/* ww w . j a v a2s . c om*/ PdfWriter.getInstance(document, outputStream); //Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 9); Font font2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD); Font font3 = new Font(Font.FontFamily.TIMES_ROMAN, 11); Font fontBold = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD); //Font fontUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.UNDERLINE); Font fontHeader = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); document.open(); String dirPath = FacesContext.getCurrentInstance().getExternalContext() .getInitParameter("image_file_path"); // Check servlet context for invalid character if (dirPath.contains("..")) throw new IllegalArgumentException( "Servlet context contains invalid character(s). Security may have been compromised."); File dir = new File(dirPath); Image image = Image.getInstance(dir + "/ArchiveFaxHeader.jpg"); image.scalePercent(69, 66); document.add(image); // Create first table float[] colsWidthTo = { .3f, 2f, .4f, 2f }; PdfPTable addressTable = new PdfPTable(colsWidthTo); addressTable.setWidthPercentage(100); PdfPCell toLabel = new PdfPCell(new Phrase("TO:", fontBold)); toLabel.setRowspan(3); toLabel.setBorderWidthRight(0); addressTable.addCell(toLabel); PdfPCell toName = new PdfPCell(new Phrase(to, fontBold)); toName.setBorderWidthLeft(0); toName.setBorderWidthBottom(0); addressTable.addCell(toName); PdfPCell fromLabel = new PdfPCell(new Phrase("FROM:", fontBold)); fromLabel.setBorderWidthRight(0); fromLabel.setBorderWidthBottom(0); addressTable.addCell(fromLabel); PdfPCell fromName = new PdfPCell(new Phrase("Eligibility Case Manager", fontBold)); fromName.setBorderWidthBottom(0); fromName.setBorderWidthLeft(0); addressTable.addCell(fromName); PdfPCell toAddress = new PdfPCell(new Phrase("", fontBold)); toAddress.setBorderWidthLeft(0); toAddress.setBorderWidthTop(0); addressTable.addCell(toAddress); PdfPCell fromDateLabel = new PdfPCell(new Phrase("DATE:", fontBold)); fromDateLabel.setBorderWidthRight(0); fromDateLabel.setBorderWidthTop(0); //toLabel.setRowspan(2); addressTable.addCell(fromDateLabel); PdfPCell dateFrom = new PdfPCell(new Phrase(currentDate, fontBold)); dateFrom.setBorderWidthTop(0); dateFrom.setBorderWidthLeft(0); addressTable.addCell(dateFrom); addressTable.setSpacingBefore(15); addressTable.setSpacingAfter(15); document.add(addressTable); float[] colsWidthCaseId = { .7f, 3f }; PdfPTable caseTable = new PdfPTable(colsWidthCaseId); caseTable.setWidthPercentage(100); PdfPCell caseIdLabel = new PdfPCell(new Phrase("Eligibility Case Id:", font3)); caseIdLabel.setBorderWidth(0); caseTable.addCell(caseIdLabel); PdfPCell caseIdInput = new PdfPCell(new Phrase(caseIdData, font3)); caseIdInput.setBorderWidth(0); caseTable.addCell(caseIdInput); caseTable.setSpacingAfter(8); document.add(caseTable); float[] colsWidthFolder = { .5f, 3f }; PdfPTable folderTable = new PdfPTable(colsWidthFolder); folderTable.setWidthPercentage(100); PdfPCell folderLabel = new PdfPCell(new Phrase("VA file No:", font3)); folderLabel.setBorderWidth(0); folderTable.addCell(folderLabel); PdfPCell folder = new PdfPCell(new Phrase(fileNo, font3)); folder.setBorderWidth(0); folderTable.addCell(folder); folderTable.setSpacingAfter(8); document.add(folderTable); float[] colsWidthRef = { .7f, 3f }; PdfPTable refTable = new PdfPTable(colsWidthRef); refTable.setWidthPercentage(100); PdfPCell ref = new PdfPCell(new Phrase("Veteran's Name:", font3)); ref.setBorderWidth(0); refTable.addCell(ref); PdfPCell refName = new PdfPCell(new Phrase(vetName, font3)); refName.setBorderWidth(0); refTable.addCell(refName); refTable.setSpacingAfter(8); document.add(refTable); float[] colsWidthSSN = { .3f, 2f, .25f, 2f }; PdfPTable ssnTable = new PdfPTable(colsWidthSSN); ssnTable.setWidthPercentage(100); PdfPCell ssnLabel = new PdfPCell(new Phrase("SSN:", font3)); ssnLabel.setBorderWidth(0); ssnTable.addCell(ssnLabel); PdfPCell ssn = new PdfPCell(new Phrase(ssnData, font3)); ssn.setBorderWidth(0); ssnTable.addCell(ssn); PdfPCell snLabel = new PdfPCell(new Phrase("SN:", font3)); snLabel.setBorderWidth(0); ssnTable.addCell(snLabel); PdfPCell sn = new PdfPCell(new Phrase(snData, font3)); sn.setBorderWidth(0); ssnTable.addCell(sn); ssnTable.setSpacingAfter(8); document.add(ssnTable); float[] colsWidthFARC = { .6f, 2f, .8f, 2f }; PdfPTable farcTable = new PdfPTable(colsWidthFARC); farcTable.setWidthPercentage(100); PdfPCell farcLabel = new PdfPCell(new Phrase("FARC No:", font3)); farcLabel.setBorderWidth(0); farcTable.addCell(farcLabel); PdfPCell farc = new PdfPCell(new Phrase(farcNo, font3)); farc.setBorderWidth(0); farcTable.addCell(farc); PdfPCell farcDateLabel = new PdfPCell(new Phrase("Transfer Date:", font3)); farcDateLabel.setBorderWidth(0); farcTable.addCell(farcDateLabel); PdfPCell farcDate = new PdfPCell(new Phrase(transDate, font3)); farcDate.setBorderWidth(0); farcTable.addCell(farcDate); farcTable.setSpacingAfter(8); document.add(farcTable); float[] colsWidthLoc = { .8f, 2f, .6f, 2f }; PdfPTable locTable = new PdfPTable(colsWidthLoc); locTable.setWidthPercentage(100); PdfPCell locLabel = new PdfPCell(new Phrase("Prior Location:", font3)); locLabel.setBorderWidth(0); locTable.addCell(locLabel); PdfPCell location = new PdfPCell(new Phrase(priorLoc, font3)); location.setBorderWidth(0); locTable.addCell(location); PdfPCell boxNoLabel = new PdfPCell(new Phrase("Box No:", font3)); boxNoLabel.setBorderWidth(0); locTable.addCell(boxNoLabel); PdfPCell boxNo = new PdfPCell(new Phrase(boxNoData, font3)); boxNo.setBorderWidth(0); locTable.addCell(boxNo); locTable.setSpacingAfter(8); document.add(locTable); float[] colsWidthRemarks = { .6f, 5f }; PdfPTable remarks1Table = new PdfPTable(colsWidthRemarks); remarks1Table.setWidthPercentage(100); PdfPCell remark1Label = new PdfPCell(new Phrase("Remarks:", font3)); remark1Label.setBorderWidth(0); remarks1Table.addCell(remark1Label); PdfPCell remarks1Input = new PdfPCell(new Phrase( "Please provide copy(ies) of the following document(s) to establish eligibility for burial in a national cemetery.", font3)); remarks1Input.setBorderWidth(0); remarks1Table.addCell(remarks1Input); remarks1Table.setSpacingAfter(8); document.add(remarks1Table); float[] colsWidthDocs = { .4f, 2f, .4f, 2f }; PdfPTable docsTable = new PdfPTable(colsWidthDocs); docsTable.setWidthPercentage(100); PdfPCell docsLabel = new PdfPCell(new Phrase(sepDocs, font3)); docsLabel.setHorizontalAlignment(Element.ALIGN_CENTER); docsLabel.setBorderWidth(0); docsLabel.setBorderWidthBottom(1); docsTable.addCell(docsLabel); PdfPCell docs1 = new PdfPCell(new Phrase("Separation Document(s)", font3)); docs1.setBorderWidth(0); docsTable.addCell(docs1); PdfPCell docs2 = new PdfPCell(new Phrase(deathCert, font3)); docs2.setHorizontalAlignment(Element.ALIGN_CENTER); docs2.setBorderWidth(0); docs2.setBorderWidthBottom(1); docsTable.addCell(docs2); PdfPCell docs3 = new PdfPCell(new Phrase("Death Certificate", font3)); docs3.setBorderWidth(0); docsTable.addCell(docs3); PdfPCell docs4 = new PdfPCell(new Phrase(marLicense, font3)); docs4.setHorizontalAlignment(Element.ALIGN_CENTER); docs4.setBorderWidth(0); docs4.setBorderWidthBottom(1); docsTable.addCell(docs4); PdfPCell docs5 = new PdfPCell(new Phrase("Marriage License", font3)); docs5.setBorderWidth(0); docsTable.addCell(docs5); PdfPCell docs6 = new PdfPCell(new Phrase(divorceDecree, font3)); docs6.setHorizontalAlignment(Element.ALIGN_CENTER); docs6.setBorderWidth(0); docs6.setBorderWidthBottom(1); docsTable.addCell(docs6); PdfPCell docs7 = new PdfPCell(new Phrase("Divorce Decree", font3)); docs7.setBorderWidth(0); docsTable.addCell(docs7); PdfPCell docs8 = new PdfPCell(new Phrase(adminDecision, font3)); docs8.setHorizontalAlignment(Element.ALIGN_CENTER); docs8.setBorderWidth(0); docs8.setBorderWidthBottom(1); docsTable.addCell(docs8); PdfPCell docs9 = new PdfPCell(new Phrase("VA Admin Decision", font3)); docs9.setBorderWidth(0); docsTable.addCell(docs9); PdfPCell docs10 = new PdfPCell(new Phrase("", font3)); docs10.setBorderWidth(0); docsTable.addCell(docs10); PdfPCell docs11 = new PdfPCell(new Phrase("", font3)); docs11.setBorderWidth(0); docsTable.addCell(docs11); document.add(docsTable); float[] colsWidthOther = { .4f, .4f, 4f }; PdfPTable otherDocTable = new PdfPTable(colsWidthOther); otherDocTable.setWidthPercentage(100); PdfPCell otherDoc1 = new PdfPCell(new Phrase(otherCheck, font3)); otherDoc1.setHorizontalAlignment(Element.ALIGN_CENTER); otherDoc1.setBorderWidth(0); otherDoc1.setBorderWidthBottom(1); otherDocTable.addCell(otherDoc1); PdfPCell otherDoc2 = new PdfPCell(new Phrase("Other", font3)); otherDoc2.setBorderWidth(0); otherDocTable.addCell(otherDoc2); PdfPCell otherDoc3 = new PdfPCell(new Phrase("", font3)); otherDoc3.setBorderWidth(0); otherDocTable.addCell(otherDoc3); otherDocTable.setSpacingAfter(8); document.add(otherDocTable); if (!otherComments.equals("")) { float[] colsWidthOtherComments = { 1.1f, 5f }; PdfPTable otherCommentsTable = new PdfPTable(colsWidthOtherComments); otherCommentsTable.setWidthPercentage(100); PdfPCell otherCommentLabel = new PdfPCell(new Phrase("Other Comments:", font3)); otherCommentLabel.setBorderWidth(0); otherCommentsTable.addCell(otherCommentLabel); PdfPCell otherCommentsInput = new PdfPCell(new Phrase(otherComments, font3)); otherCommentsInput.setBorderWidth(0); otherCommentsTable.addCell(otherCommentsInput); otherCommentsTable.setSpacingAfter(8); document.add(otherCommentsTable); } PdfPTable remarksTable = new PdfPTable(colsWidthRemarks); remarksTable.setWidthPercentage(100); PdfPCell remarkLabel = new PdfPCell(new Phrase("Remarks:", font3)); remarkLabel.setBorderWidth(0); remarksTable.addCell(remarkLabel); PdfPCell remarksInput = new PdfPCell(new Phrase(remarks, font3)); remarksInput.setBorderWidth(0); remarksTable.addCell(remarksInput); remarksTable.setSpacingAfter(8); document.add(remarksTable); Paragraph expediteOne = new Paragraph("-- PLEASE EXPEDITE --", font3); expediteOne.setSpacingBefore(5); expediteOne.setSpacingAfter(10); document.add(expediteOne); Paragraph disclosure = new Paragraph( "This fax is intended only for the use of the person or office to which it is addressed and may contain information that is privileged, confidential, or protected by law. All others are hereby notified that the receipt of this fax does not waive any applicable privilege or exemption for disclosure and that any dissemination, distribution, or copying of this communication is prohibited. If you have received this fax in error, please notify this office immediately at the telephone number listed above.", font2); disclosure.setAlignment(Element.ALIGN_JUSTIFIED); disclosure.setSpacingBefore(5); disclosure.setSpacingAfter(10); document.add(disclosure); float[] colsWidthPages = { 5f, .5f, 2f }; PdfPTable pagesTable = new PdfPTable(colsWidthPages); pagesTable.setWidthPercentage(71); PdfPCell pageOneLabel = new PdfPCell( new Phrase("This fax sheet consists of the cover page and ", fontHeader)); pageOneLabel.setBorderWidth(0); pageOneLabel.setHorizontalAlignment(Element.ALIGN_RIGHT); pagesTable.addCell(pageOneLabel); PdfPCell pages = new PdfPCell(new Phrase(faxPages, fontHeader)); pages.setBorderWidth(0); pages.setHorizontalAlignment(Element.ALIGN_CENTER); pages.setBorderWidthBottom(1); pagesTable.addCell(pages); PdfPCell pageTwoLabel = new PdfPCell(new Phrase(" additional pages", fontHeader)); pageTwoLabel.setBorderWidth(0); pagesTable.addCell(pageTwoLabel); pagesTable.setSpacingAfter(8); document.add(pagesTable); Paragraph expediteTwo = new Paragraph("FAX: 816-268-8163 ***** BURIAL PLEASE EXPEDITE *****", fontBold); expediteTwo.setSpacingBefore(5); expediteTwo.setSpacingAfter(10); document.add(expediteTwo); document.close(); } catch (Exception ex) { System.err.println(ex.getMessage()); } return new ByteArrayInputStream(outputStream.toByteArray()); }
From source file:GUI_StafKlinik.Panel_Penggajian.java
private Paragraph getPreface(String status) { lk = new Laporan_Keuangan(); Paragraph preface = new Paragraph(); Calendar cal = new GregorianCalendar(); String tanggal = "0"; if (cal.get(Calendar.DATE) < 0) { tanggal = "0" + cal.get(Calendar.DATE); } else {/*from w w w . j av a2s . c o m*/ tanggal = "" + cal.get(Calendar.DATE); } int bulan = (cal.get(Calendar.MONTH)) + 1; ; int tahun = cal.get(Calendar.YEAR); String id1 = lk.getId(); String id2 = p.getIdPegawai(); String id = id = id1 + id2; preface.setAlignment(Element.ALIGN_CENTER); Chunk chunk = new Chunk("Slip Gaji", font2); preface.add(Chunk.NEWLINE); preface.add(chunk); chunk = new Chunk("SI Klinik", font2); preface.add(Chunk.NEWLINE); preface.add(chunk); chunk = new Chunk("Jalan Pahlawan 45 Surabaya", font1); preface.add(Chunk.NEWLINE); preface.add(chunk); chunk = new Chunk("Telepon : 031 7564231", font1); preface.add(Chunk.NEWLINE); preface.add(chunk); preface.add(Chunk.NEWLINE); preface.add(Chunk.NEWLINE); preface.setAlignment(Element.ALIGN_RIGHT); chunk = new Chunk("Tanggal " + tanggal + "/" + bulan + "/" + tahun, font1); preface.add(Chunk.NEWLINE); preface.add(chunk); chunk = new Chunk("No. Referensi :" + id, font1); preface.add(Chunk.NEWLINE); preface.add(chunk); return preface; }
From source file:hsa.awp.admingui.report.util.HeaderFooter.java
License:Open Source License
/** * this method is called by Pageevent./*from w w w . ja v a 2 s. c o m*/ * * @param writer write of the document * @param document document it self */ public void onEndPage(PdfWriter writer, Document document) { Rectangle rect = writer.getBoxSize("art"); /* title */ ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(title, FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16)), rect.getLeft(), rect.getTop() + 20, 0); /* subtitle */ ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(subtitle, FontFactory.getFont(FontFactory.HELVETICA, 9)), rect.getLeft(), rect.getTop() + 9, 0); /* date */ DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); java.util.Date date = new java.util.Date(); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_RIGHT, new Phrase(dateFormat.format(date)), rect.getRight(), rect.getTop() + 15, 0); /* pagenumber */ ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(String.format("Seite %d", writer.getPageNumber())), (rect.getLeft() + rect.getRight()) / 2, rect.getBottom() - 25, 0); }
From source file:ics4u.ics4u_final_project.Recipe.java
License:Open Source License
private void addData(Document doc) { //create the format for the % Daily Value DecimalFormat onePer = new DecimalFormat("#,##0%"); try {//from www. jav a 2 s . com //add the title of the recipe doc.add(new Paragraph(title, TITLE_FONT)); //add each of the ingredients for (int i = 0; i < ingredients.size(); i++) { doc.add(new Paragraph(ingredients.get(i).getFormattedName(), LABEL_NORMAL)); } //add the instructions Paragraph p = new Paragraph(); if (!instructions.equals("")) { p = new Paragraph(new Phrase("Instructions:\n", LABEL_FONT)); doc.add(p); p = new Paragraph(); p.add(new Phrase(instructions + "\n", LABEL_NORMAL)); } else { p.add(new Phrase("\n")); } //create the nutrient value table PdfPTable label = new PdfPTable(10); label.setWidthPercentage(30); //Top PdfPCell c = new PdfPCell(new Phrase("Nutrition Facts", LABEL_FONT)); c.setColspan(10); c.setBorderWidthBottom(0); label.addCell(c); c = new PdfPCell(new Phrase("Per " + servingName, LABEL_BOLD)); c.setColspan(10); c.setBorderWidthTop(0); label.addCell(c); //Amount PdfPCell c2a = new PdfPCell(new Phrase("Amount", LABEL_SMALL)); c2a.setColspan(3); c2a.setBorderWidthRight(0); PdfPCell c2b = new PdfPCell(new Phrase("% Daily Value", LABEL_SMALL)); c2b.setColspan(10); c2b.setHorizontalAlignment(Element.ALIGN_RIGHT); c2b.setBorderWidthLeft(0); label.addCell(c2a); label.addCell(c2b); //Calories c = new PdfPCell(new Phrase("Calories " + (int) (nutrients[208] / servings), LABEL_BOLD)); c.setColspan(10); c.setBorderWidthTop(2); label.addCell(c); //Fat PdfPCell ca = new PdfPCell(new Phrase("Fat " + (int) (nutrients[204] / servings) + "g", LABEL_BOLD)); ca.setColspan(6); ca.setBorderWidthRight(0); PdfPCell cb = new PdfPCell(new Phrase(onePer.format((nutrients[204] / servings) / 60.0), LABEL_BOLD)); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); label.addCell(ca); label.addCell(cb); //fat 2 ca = new PdfPCell(new Phrase("Saturated " + ((int) (nutrients[606] / servings)) + "g\n\t+ Trans " + ((int) (nutrients[605] / servings)) + "g", LABEL_NORMAL)); ca.setColspan(6); ca.setIndent(16); ca.setBorderWidthRight(0); cb = new PdfPCell(new Phrase(onePer.format((nutrients[606] / servings) / 20.0), LABEL_BOLD)); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); label.addCell(ca); label.addCell(cb); //Cholesterol c = new PdfPCell(new Phrase("Cholesterol " + ((int) (nutrients[601] / servings)) + "mg", LABEL_BOLD)); c.setColspan(10); label.addCell(c); //Sodium ca = new PdfPCell(new Phrase("Sodium " + (int) (nutrients[307] / servings) + "mg", LABEL_BOLD)); ca.setColspan(6); ca.setBorderWidthRight(0); cb = new PdfPCell(new Phrase(onePer.format((nutrients[307] / servings) / 2400.0), LABEL_BOLD)); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); label.addCell(ca); label.addCell(cb); //Carbs ca = new PdfPCell(new Phrase("Carbohydrate " + (int) (nutrients[205] / servings) + "g", LABEL_BOLD)); ca.setColspan(7); ca.setBorderWidthRight(0); cb = new PdfPCell(new Phrase(onePer.format((nutrients[205] / servings) / 300.0), LABEL_BOLD)); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); label.addCell(ca); label.addCell(cb); //Fibre ca = new PdfPCell(new Phrase("Fibre " + (int) (nutrients[291] / servings) + "g", LABEL_NORMAL)); ca.setColspan(6); ca.setIndent(16); ca.setBorderWidthRight(0); cb = new PdfPCell(new Phrase(onePer.format((nutrients[291] / servings) / 25.0), LABEL_BOLD)); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); label.addCell(ca); label.addCell(cb); //Sugar ca = new PdfPCell(new Phrase("Sugars " + (int) (nutrients[269] / servings) + "g", LABEL_NORMAL)); ca.setColspan(10); ca.setIndent(16); label.addCell(ca); //Protein ca = new PdfPCell(new Phrase("Protein " + (int) (nutrients[203] / servings) + "g", LABEL_BOLD)); ca.setColspan(10); label.addCell(ca); //Vit A ca = new PdfPCell(new Phrase("Vitamin A", LABEL_NORMAL)); ca.setColspan(6); ca.setBorderWidthRight(0); ca.setBorderWidthTop(2); cb = new PdfPCell(cb = new PdfPCell(new Phrase( onePer.format( ((nutrients[319] + (nutrients[321] / 12) + (nutrients[834] / 24)) / servings) / 1000), LABEL_NORMAL))); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); cb.setBorderWidthTop(2); label.addCell(ca); label.addCell(cb); //Vit C ca = new PdfPCell(new Phrase("Vitamin C", LABEL_NORMAL)); ca.setColspan(6); ca.setBorderWidthRight(0); cb = new PdfPCell(new Phrase(onePer.format((nutrients[401] / servings) / 60.0), LABEL_NORMAL)); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); label.addCell(ca); label.addCell(cb); //Calcium ca = new PdfPCell(new Phrase("Calcium", LABEL_NORMAL)); ca.setColspan(6); ca.setBorderWidthRight(0); cb = new PdfPCell(new Phrase(onePer.format((nutrients[301] / servings) / 1100.0), LABEL_NORMAL)); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); label.addCell(ca); label.addCell(cb); //Iron ca = new PdfPCell(new Phrase("Iron", LABEL_NORMAL)); ca.setColspan(6); ca.setBorderWidthRight(0); cb = new PdfPCell(new Phrase(onePer.format((nutrients[303] / servings) / 14.0), LABEL_NORMAL)); cb.setColspan(10); cb.setHorizontalAlignment(Element.ALIGN_RIGHT); cb.setBorderWidthLeft(0); label.addCell(ca); label.addCell(cb); //Add to the table label.setHorizontalAlignment(Element.ALIGN_LEFT); p.add(label); //add to the document doc.add(p); } catch (DocumentException ex) { System.out.println("Error: " + ex.toString()); } }
From source file:ihm.panneaux.GenererPdf.java
private void initComponement() throws FileNotFoundException, DocumentException, IOException { String DEST = "devis/devis-" + devis.getNumero() + ".pdf"; OutputStream file = new FileOutputStream(new File(DEST)); com.itextpdf.text.Document document = new com.itextpdf.text.Document(); PdfWriter.getInstance((com.itextpdf.text.Document) document, file); // PAS TOUCHE PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(DEST)); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent(); writer.setPageEvent(event);// www . j av a2 s .c om document.open(); PdfContentByte canvas = writer.getDirectContent(); Image logo = Image.getInstance("images/logo.png"); logo.scaleAbsolute(200, 57); // INFO DEVIS Image devisImg = Image.getInstance("images/imgDevis.png"); devisImg.scaleAbsolute(110, 34); devisImg.setAbsolutePosition((PageSize.POSTCARD.getWidth() + 150), (PageSize.POSTCARD.getHeight() - devisImg.getScaledHeight()) * 2); Font fontImgDevis = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); Phrase numeroInfo = new Phrase("Numro " + devis.getNumero(), fontImgDevis); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, numeroInfo, devisImg.getScaledWidth() + 413, devisImg.getScaledHeight() + 710, 0); Phrase dateInfo = new Phrase("Le " + devis.getDate(), fontImgDevis); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, dateInfo, devisImg.getScaledWidth() + 420, devisImg.getScaledHeight() + 695, 0); Image devisImgBordure = Image.getInstance("images/bordureDevis.png"); devisImgBordure.setAbsolutePosition((devisImg.getScaledWidth() + 318), devisImg.getScaledHeight() + 660); devisImgBordure.scaleAbsolute(120, 122); // INFO ENTREPRISE Font fontEntreprise = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD); Phrase coGerants = new Phrase("Co-grants : " + devis.getEntreprise().getCoGerant(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, coGerants, devisImg.getScaledWidth() + 210, devisImg.getScaledHeight() + 660, 0); Phrase siege = new Phrase("Sige : " + devis.getEntreprise().getSiege(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, siege, devisImg.getScaledWidth() + 149, devisImg.getScaledHeight() + 640, 0); Phrase tel = new Phrase("TEL : " + devis.getEntreprise().getTel(), fontEntreprise); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, tel, devisImg.getScaledWidth() + 113, devisImg.getScaledHeight() + 625, 0); Image bordureEntreprise = Image.getInstance("images/bordureEntreprise.png"); bordureEntreprise.setAbsolutePosition(devisImg.getScaledWidth() - 80, devisImg.getScaledHeight() + 610); // INFO CLIENT Font fontClient = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL); Phrase nomPrenom = new Phrase(devis.getClient().getNom() + " " + devis.getClient().getPrenom(), fontClient); Phrase commune = new Phrase(devis.getClient().getAdresse(), fontClient); Phrase adresse = new Phrase(devis.getClient().getCodePostale() + " " + devis.getClient().getCommune(), fontClient); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, nomPrenom, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 595, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, commune, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 580, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, adresse, PageSize.A4.getWidth() - 280, devisImg.getScaledHeight() + 565, 0); document.add(logo); document.add(devisImg); document.add(devisImgBordure); document.add(bordureEntreprise); // AJOUT DES DONNEES DU TABLEAUX float[] columnWidths = { 14, 3, 4, 3, 4 }; Font fontCategorie = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); fontCategorie.setColor(BaseColor.GREEN); PdfPTable table = new PdfPTable(columnWidths); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.setTotalWidth(PageSize.A4.getWidth() - 15); table.setSpacingBefore(150); table.setLockedWidth(true); Font Categorie = new Font(FontFamily.HELVETICA, 13, Font.BOLD); Font Chantier = new Font(FontFamily.HELVETICA, 11, Font.UNDERLINE); PdfPCell cellChantier = new PdfPCell(new Phrase("CHANTIER : " + chantier, Chantier)); cellChantier.setColspan(3); cellChantier.setBorder(Rectangle.NO_BORDER); table.addCell(cellChantier); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(new Phrase("Dsignation", Categorie)); PdfPCell unite = new PdfPCell(new Phrase("Unite", Categorie)); PdfPCell quantite = new PdfPCell(new Phrase("Quantite", Categorie)); PdfPCell prixht = new PdfPCell(new Phrase("Prix HT", Categorie)); PdfPCell pvtht = new PdfPCell(new Phrase("Pvt HT", Categorie)); unite.setHorizontalAlignment(Element.ALIGN_CENTER); quantite.setHorizontalAlignment(Element.ALIGN_CENTER); prixht.setHorizontalAlignment(Element.ALIGN_CENTER); pvtht.setHorizontalAlignment(Element.ALIGN_CENTER); unite.setBorder(Rectangle.NO_BORDER); quantite.setBorder(Rectangle.NO_BORDER); prixht.setBorder(Rectangle.NO_BORDER); pvtht.setBorder(Rectangle.NO_BORDER); table.addCell(unite); table.addCell(quantite); table.addCell(prixht); table.addCell(pvtht); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); double htTotalParcour = 0; double ttcTotalParcour = 0; if (this.EquipementDeChantier.isEmpty() == false) { table.addCell(new Phrase("Equipement De Chantier", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : EquipementDeChantier) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); /* BACKUP table.addCell(listeMaterielDevi.getMateriel().getNom()); table.addCell(listeMaterielDevi.getMateriel().getUnite()); table.addCell(Double.toString(listeMaterielDevi.getQuantite())); table.addCell(Double.toString(listeMaterielDevi.getMateriel().getPrix())+""); table.addCell(Double.toString(listeMaterielDevi.getPvtHT())+""); */ ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (Couverture.isEmpty() == false) { table.addCell(new Phrase("Couverture", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Couverture) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (CouvertureArdoise.isEmpty() == false) { table.addCell(new Phrase("Couverture Ardoise", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : CouvertureArdoise) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (CouvertureTuile.isEmpty() == false) { table.addCell(new Phrase("Couverture Tuile", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : CouvertureTuile) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Demoussage.isEmpty() == false) { table.addCell(new Phrase("Demoussage", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Demoussage) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Velux.isEmpty() == false) { table.addCell(new Phrase("Velux", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Velux) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (this.Zinguerie.isEmpty() == false) { table.addCell(new Phrase("Zinguerie", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Zinguerie) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } if (Plancher.isEmpty() == false) { table.addCell(new Phrase("Plancher", fontCategorie)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); for (DevisContenu listeMaterielDevi : Plancher) { table.addCell(listeMaterielDevi.getMateriel().getNom()); PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite())); PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite()))); PdfPCell cellprix = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + "")); PdfPCell cellpvtHT = new PdfPCell( new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + "")); cellunite.setHorizontalAlignment(Element.ALIGN_CENTER); cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER); cellprix.setHorizontalAlignment(Element.ALIGN_CENTER); cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER); cellunite.setBorder(Rectangle.NO_BORDER); cellQuantite.setBorder(Rectangle.NO_BORDER); cellprix.setBorder(Rectangle.NO_BORDER); cellpvtHT.setBorder(Rectangle.NO_BORDER); table.addCell(cellunite); table.addCell(cellQuantite); table.addCell(cellprix); table.addCell(cellpvtHT); ttcTotalParcour += listeMaterielDevi.getPvtHT(); htTotalParcour += listeMaterielDevi.getPvtHT(); } table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); } ttcTotalParcour = (ttcTotalParcour * devis.getTva() / 100) + ttcTotalParcour; LineDash solid = new SolidLine(); PdfPCell cell, cell2, cellSOUSTOTAL, cellhttotal, tva, getTva, totalttc, gettotalttc; table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); table.addCell(new Phrase(" ")); cell = new PdfPCell(new Phrase("")); cell.setBorder(PdfPCell.NO_BORDER); cell.setCellEvent(new CustomBorder(null, null, null, solid)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); table.addCell(new Phrase("")); table.addCell(new Phrase("")); cellSOUSTOTAL = new PdfPCell(new Phrase("SOUS-TOTAL")); cellSOUSTOTAL.setHorizontalAlignment(Element.ALIGN_MIDDLE); cellSOUSTOTAL.setBorder(Rectangle.NO_BORDER); table.addCell(cellSOUSTOTAL); table.addCell(new Phrase("")); double prixHT_2Chiffre = Math.round((htTotalParcour) * Math.pow(10, 2)) / Math.pow(10, 2); String httotal = String.valueOf(prixHT_2Chiffre); cellhttotal = new PdfPCell(new Phrase(httotal + "")); cellhttotal.setBorder(Rectangle.NO_BORDER); cellhttotal.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(cellhttotal); table.addCell(new Phrase("")); table.addCell(new Phrase("")); tva = new PdfPCell(new Phrase("TVA")); tva.setBorder(Rectangle.NO_BORDER); tva.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(tva); getTva = new PdfPCell(new Phrase(devis.getTva() + "%")); getTva.setBorder(Rectangle.NO_BORDER); getTva.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(getTva); String tvaprix = String.valueOf(htTotalParcour * devis.getTva() / 100); double prixTVA_2Chiffre = Math.round(Double.parseDouble(tvaprix) * Math.pow(10, 2)) / Math.pow(10, 2); cell2 = new PdfPCell(new Phrase(Double.toString(prixTVA_2Chiffre) + "")); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setCellEvent(new CustomBorder(null, null, null, solid)); cell2.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell2); table.addCell(""); table.addCell(""); totalttc = new PdfPCell(new Phrase("Total TTC")); totalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE); totalttc.setBorder(PdfPCell.NO_BORDER); table.addCell(totalttc); table.addCell(""); double prixTTC_2Chiffre = Math.round(ttcTotalParcour * Math.pow(10, 2)) / Math.pow(10, 2); String ttctotal = String.valueOf(Double.toString(prixTTC_2Chiffre)); gettotalttc = new PdfPCell(new Phrase(ttctotal + "")); gettotalttc.setBorder(PdfPCell.NO_BORDER); gettotalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE); table.addCell(gettotalttc); table.setSpacingAfter(10); document.add(table); Pattern p = Pattern.compile("[.^\\.]+"); String texte = devis.getInformationComplementaire(); Font infoComptBlue = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptBlue.setColor(BaseColor.BLUE); Font infoComptRed = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptRed.setColor(BaseColor.RED); Font infoComptBlack = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL); infoComptBlack.setColor(BaseColor.BLACK); Paragraph infoComp = new Paragraph(); Image BonPourAccord = null; BonPourAccord = Image.getInstance("images/BonPourAccord.png"); infoComp.setAlignment(Element.ALIGN_LEFT); BonPourAccord.setAlignment(Image.TEXTWRAP | Image.ALIGN_RIGHT); String[] phrase = p.split(texte); for (int i = 0; i < phrase.length; i++) { if (i == 0 || i == 1) { infoComp.add(new Paragraph(phrase[i], infoComptBlue)); } if (i == 2 || i == 3 || i == 4 || i == 5) { infoComp.add(new Paragraph(phrase[i], infoComptRed)); } if (i > 5 && i <= 11) infoComp.add(new Paragraph(phrase[i], infoComptBlack)); if (i > 11) infoComp.add(new Paragraph(phrase[i], infoComptRed)); } /* A OPTIMISER */ float taille_tableau = table.calculateHeights() + table.getRowHeight(table.getLastCompletedRowIndex()); if (taille_tableau > 386) { document.newPage(); } document.add(BonPourAccord); document.add(infoComp); document.close(); EnvoieDevis envoie = new EnvoieDevis(null, true, session, devis); this.CouvertureArdoise.clear(); this.CouvertureTuile.clear(); this.Demoussage.clear(); this.EquipementDeChantier.clear(); this.Velux.clear(); this.Zinguerie.clear(); this.Couverture.clear(); this.Plancher.clear(); }