List of usage examples for com.itextpdf.text Paragraph setSpacingAfter
public void setSpacingAfter(float spacing)
From source file:gov.utah.dts.det.ccl.actions.trackingrecordscreening.letters.reports.MultiStateOffenderLetterTX.java
private static void writePdf(TrackingRecordScreeningLetter screeningLetter, OutputStream ba, HttpServletRequest request) throws DocumentException, BadElementException, IOException { Document document = null;/* ww w . j a v a 2 s . com*/ Paragraph paragraph = null; ListItem item = null; document = new Document(PageSize.LETTER, 50, 50, 125, 0); PdfWriter writer = PdfWriter.getInstance(document, ba); StringBuilder sb = null; SimpleDateFormat df = new SimpleDateFormat("MMMM d, yyyy"); document.open(); LetterheadStamper.stampLetter(writer, request); paragraph = getParagraph(10.0f); paragraph.add(new Phrase("MSO TX", smallfont)); paragraph.setIndentationLeft(415); document.add(paragraph); paragraph.clear(); paragraph.add(new Phrase("Rev 3/12", smallfont)); paragraph.setSpacingAfter(50); document.add(paragraph); // Add report date paragraph = getParagraph(); paragraph.add(new Phrase(df.format(screeningLetter.getLetterDate()), mediumfont)); paragraph.setIndentationLeft(350); document.add(paragraph); // Add facility name and address information paragraph = getParagraph(); paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getName().toUpperCase(), mediumfont)); paragraph.setSpacingBefore(5); document.add(paragraph); if (screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress() != null) { if (StringUtils.isNotBlank( screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getAddressOne())) { paragraph = getParagraph(); paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress() .getAddressOne().toUpperCase(), mediumfont)); document.add(paragraph); } if (StringUtils.isNotBlank( screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getAddressTwo())) { // Add facility location address two paragraph = getParagraph(); paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress() .getAddressTwo().toUpperCase(), mediumfont)); document.add(paragraph); } if (StringUtils.isNotBlank( screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress().getCityStateZip())) { paragraph = getParagraph(); paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFacility().getCbsAddress() .getCityStateZip().toUpperCase(), mediumfont)); document.add(paragraph); } } // Add subject information paragraph = getParagraph(); paragraph.add(new Phrase("RE: Notice of additional Criminal Background Screening information needed:", mediumfont)); paragraph.setSpacingBefore(10); document.add(paragraph); // Add Screening Person's Name/ID sb = new StringBuilder(); paragraph = getParagraph(16.0f); paragraph.add(new Phrase(screeningLetter.getTrackingRecordScreening().getFirstAndLastName() + " (" + screeningLetter.getTrackingRecordScreening().getPersonIdentifier() + ")", mediumfont)); // Indent this line to line up with 'Notice' in subject line paragraph.setIndentationLeft(22); document.add(paragraph); // Add salutation paragraph = getParagraph(); paragraph.add(new Phrase("Dear Director:", mediumfont)); paragraph.setSpacingBefore(18); document.add(paragraph); // Start letter detail sb = new StringBuilder(); sb.append( "As a follow-up to the request for background screening by the Department of Human Services, Office of Licensing, "); sb.append("this is to notify you that additional criminal background screening information is needed."); paragraph = getParagraph(); paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(10); document.add(paragraph); paragraph = getParagraph(); paragraph.add(new Phrase( "Enclosed are two fingerprint cards for the applicant to provide complete, accurate and legible identifying information. ", mediumfont)); paragraph.add(new Phrase("Return the completed fingerprint cards with a $36.50 fee in the form of a ", mediumfont)); paragraph.add(new Phrase("cashier's check or money order ", mediumfontI)); paragraph.add(new Phrase("(no personal checks) payable to the ", mediumfont)); paragraph.add(new Phrase("Department of Human Resources, ", mediumfontI)); paragraph.add(new Phrase( "to the Office of Licensing within 15 calendar days of your receipt of this notice. Do not put multiple fingerprints ", mediumfont)); paragraph.add(new Phrase("with one payment, unless for a couple with the same last name.", mediumfont)); paragraph.setSpacingBefore(10); paragraph.setSpacingAfter(10); document.add(paragraph); // Add the fingerprint card procedures as an indented bullet list List procedure = new List(false, 10); procedure.setIndentationLeft(22); item = getListItem(); item.add(new Phrase( "Prints should be taken by a local law enforcement office, or an agency approved by law enforcement.", mediumfont)); procedure.add(item); item = getListItem(); item.add(new Phrase("The FBI will reject a card with any highlighting.", mediumfont)); procedure.add(item); item = getListItem(); item.add(new Phrase( "Use only these cards showing identification from the Office of Licensing. We will be glad to give you replacement cards if requested.", mediumfont)); procedure.add(item); item = getListItem(); item.add(new Phrase( "If mailing the cards back to us, return by regular mail (please do not fold the cards).", mediumfont)); procedure.add(item); item = getListItem(); item.add(new Phrase( "Fingerprint cards must be completely filled out or they will be returned for completion.", mediumfont)); procedure.add(item); document.add(procedure); sb = new StringBuilder(); sb.append( "Failure to return the completed fingerprint cards and fee within 15 calendar days will result in the background screening "); sb.append( "application being denied, and the applicant will not be eligible to be associated with the licensed program in any capacity "); sb.append( "or will not be eligible to proceed with foster care or adoption until all clearance procedures are completed."); paragraph = getParagraph(); paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(10); document.add(paragraph); sb = new StringBuilder(); sb.append( "Please allow up to 12 weeks for the completion of the clearance process. For assistance or inquiries, please contact the Office of Licensing "); sb.append("at (801) 538-4242."); paragraph = getParagraph(); paragraph.add(new Phrase(sb.toString(), mediumfont)); paragraph.setSpacingBefore(10); document.add(paragraph); paragraph = new Paragraph(); paragraph.add(new Phrase("Sincerely,", mediumfont)); paragraph.setSpacingBefore(10); document.add(paragraph); paragraph = new Paragraph(); paragraph.add(new Phrase(screeningLetter.getCreatedBy().getFirstAndLastName(), mediumfont)); paragraph.setSpacingBefore(25); document.add(paragraph); paragraph = new Paragraph(); paragraph.add(new Phrase("Background Screening Unit", mediumfont)); document.add(paragraph); document.close(); }
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 {//from w w w . ja va 2s. 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.GestionProjects.java
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed String IMAGE1 = lblPathImage.getText(); Font red = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.RED); Chunk redText = new Chunk("Les information relatif au Projet : ", red); Font blue = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, BaseColor.BLUE); Document document = new Document(); java.util.Date utilStartDate = jdateDeadLine.getDate(); java.sql.Date sqlStartDate = new java.sql.Date(utilStartDate.getTime()); try {//from w w w . jav a 2s . co m PdfWriter.getInstance(document, new FileOutputStream("Report.pdf")); document.open(); Paragraph p1 = new Paragraph(); p1.add(redText); p1.add(txtTitreProjet.getText()); Chunk txtdesc = new Chunk("Decription du Projet: ", red); Paragraph p2 = new Paragraph(); p2.add(txtdesc); p2.add(txtDescriptionProjet.getText()); Chunk txtcat = new Chunk("Catgorie du Projet: ", red); Paragraph p3 = new Paragraph(); p3.add(txtcat); p3.add(combo_Cat.getSelectedItem().toString()); Chunk txtfin = new Chunk("Mode de finnancement du Projet: ", red); Paragraph p4 = new Paragraph(); p4.add(txtfin); p4.add(ComboFinnancementProjet.getSelectedItem().toString()); Chunk txtdate = new Chunk("Date DeadLine Projet: ", red); Paragraph p5 = new Paragraph(); p5.add(txtdate); p5.add(sqlStartDate.toString()); p1.setSpacingAfter(25); p1.setSpacingBefore(25); p1.setAlignment(Element.ALIGN_CENTER); p1.setIndentationLeft(50); p1.setIndentationRight(50); document.add(p1); document.add(p2); document.add(p3); document.add(p4); document.add(p5); if (Desktop.isDesktopSupported()) { try { File myFile = new File("Report.pdf"); Desktop.getDesktop().open(myFile); } catch (IOException ex) { // no application registered for PDFs } } } catch (Exception e) { System.out.println(e); } document.close(); // TODO add your handling code here: }
From source file:ictproject.ReportGenerator.java
private Paragraph getParagraph(String name, String type) { Paragraph paragraph = new Paragraph(); paragraph.setSpacingAfter(10); switch (type) { case "pani ko sroth": { Paragraph para1 = new Paragraph("@= ljBfdfg kfgLsf >f]tx?sf] cj:yfM", fontNormal); para1.setAlignment(Element.ALIGN_CENTER); paragraph.add(para1);//w ww .j a v a 2 s.c om break; } case "pani janya rog ko bibaran": { Paragraph para1 = new Paragraph("%= kfgLhGo /f]ux?sf] ljj/0f M", fontNormal); para1.setAlignment(Element.ALIGN_CENTER); Paragraph para3 = new Paragraph( "uflj;:t/Lo kfgLhGo /f]ux?sf] ljj/0f :jf:Yo rf}sLaf6 jf dlxnf ;jo+;]ljsf af6 lng]", fontNormal); paragraph.add(para1); break; } case "actual budget": { Paragraph para1 = new Paragraph( "# -s_ ut tLg jif{sf nflu uflj;n] vfg]kfgL tyf ;/;kmfO If]qdf 5'6fPsf] jh]6 ljj/0fM", fontNormal); // Paragraph para3=new Paragraph("uflj;sf] hDdf ;Defljt nufgL ? ",fontNormal); // Paragraph para4=new Paragraph(getDistinctResult(name, "gabisaKoLagani", "actualBudget")); para1.setAlignment(Element.ALIGN_CENTER); Paragraph para5 = new Paragraph(); para5.add(new Chunk("uflj;sf] hDdf ;Defljt nufgL ? ", fontNormal)); para5.add(getDistinctResult(name, "gabisaKoLagani", "actualBudget")); paragraph.add(para1); paragraph.add(para5); break; } case "expected budget": { Paragraph para1 = new Paragraph( "# -v_ cfufdL # jif{sf nflu uflj;sf] vfg]kfgL tyf ;/;kmfO If]qdf x'g ;Sg] ;Defljt ah]6M", fontNormal); para1.setAlignment(Element.ALIGN_CENTER); Paragraph para5 = new Paragraph(); para5.add(new Chunk("uflj;sf] hDdf ;Defljt nufgL ? ", fontNormal)); para5.add(getDistinctResult(name, "gabisaKoLagani", "expectedBudget")); paragraph.add(para1); paragraph.add(para5); break; } case "janajatiAnusar": { Paragraph para2 = new Paragraph("uflj;sf] gfdMM" + converter(name), fontNormal); para2.setIndentationLeft(50); Paragraph para1 = new Paragraph("!= hfthftL cg';f/sf] 3/w'/L ljj/0fM", fontNormal); para1.setAlignment(Element.ALIGN_CENTER); paragraph.add(para2); paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE); paragraph.add(para1); break; } case "sauchalayKoAwasta": { Paragraph para1 = new Paragraph("$= zf}rfnosf] cj:yf M", fontNormal);//. ? ",fontNormal); para1.setAlignment(Element.ALIGN_CENTER); paragraph.add(para1); break; } case "gulmi": { Paragraph para = new Paragraph(); Paragraph para1 = new Paragraph("lhNnf ljsf; ;ldltsf] sfof{no", fontNormal); para1.setAlignment(Element.ALIGN_CENTER); Paragraph para3 = new Paragraph("u'NdL", fontNormal); para3.setAlignment(Element.ALIGN_CENTER); Paragraph para4 = new Paragraph("vfg]kfgL tyf ;/;kmfO OsfO{", fontNormal); para4.setAlignment(Element.ALIGN_CENTER); para.add(para1); para.add(para3); para.add(para4); return para; } case "name": { Paragraph para = new Paragraph(converter(name), fontNormal); para.setAlignment(Element.ALIGN_CENTER); return para; } } return paragraph; }
From source file:KTCNPM.ExportFile.java
public void exportFile(ArrayList<String> list, ArrayList<String> listTAW, ArrayList<String> listTBF, ArrayList<String> listTCF, ArrayList<String> listEF, ArrayList<String> listG) throws IOException { Document document = new Document(); try {//from www . j av a2s. com String fileSRC = "E:\\KTCNPM.pdf"; File file = new File(fileSRC); if (file.exists()) { file.delete(); } else { file.createNewFile(); } PdfWriter.getInstance(document, new FileOutputStream(fileSRC)); document.open(); Font f1 = new Font( BaseFont.createFont("/newpackage/vuArialBold.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); Font f2 = new Font( BaseFont.createFont("/newpackage/vuArial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); f2.setSize(9); f1.setSize(13); Paragraph paragraph2 = new Paragraph("", f2); Paragraph paragraph3 = new Paragraph(); paragraph2.setIndentationLeft(80); paragraph2.setIndentationRight(80); paragraph2.setAlignment(Element.ALIGN_LEFT); paragraph2.setSpacingAfter(15); Phrase phrase2 = new Phrase("Tn phn m?m: Tnh chi ph phn m?m"); Phrase phrase3 = new Phrase(" "); paragraph3.add(phrase3); paragraph2.add(phrase2); //Phu luc 3 Phrase phrase5 = new Phrase( "Ph lc III: Bng tnh ton im cc tc nhn (actors) tng tc, trao i thng tin"); Paragraph paragraph5 = new Paragraph("", f1); paragraph5.setIndentationLeft(80); paragraph5.setIndentationRight(80); paragraph5.setAlignment(Element.ALIGN_CENTER); paragraph5.setSpacingAfter(10); paragraph5.add(phrase5); document.add(paragraph5); document.add(paragraph2); PdfPTable table3 = new PdfPTable(5); table3.setWidthPercentage(400 / 5.23f); table3.setWidths(new int[] { 1, 5, 3, 2, 3 }); for (int i = 0; i < listTAW.size(); i++) { Paragraph p = new Paragraph(listTAW.get(i), f2); PdfPCell data = new PdfPCell(p); table3.addCell(data); } document.add(table3); document.add(paragraph3); document.add(paragraph3); document.add(paragraph3); // phu luc 4 Phrase phrase41 = new Phrase( "Ph lc IV: Bng tnh ton im cc tr?ng hp s dung (use case)"); Paragraph paragraph41 = new Paragraph("", f1); paragraph41.setIndentationLeft(80); paragraph41.setIndentationRight(80); paragraph41.setAlignment(Element.ALIGN_CENTER); paragraph41.setSpacingAfter(10); paragraph41.add(phrase41); document.add(paragraph41); document.add(paragraph2); PdfPTable table4 = new PdfPTable(4); table4.setWidthPercentage(400 / 5.23f); table4.setWidths(new int[] { 1, 3, 3, 4 }); for (int i = 0; i < listTBF.size(); i++) { PdfPCell data = new PdfPCell(new Paragraph(listTBF.get(i), f2)); table4.addCell(data); } document.add(table4); document.add(paragraph3); document.add(paragraph3); document.add(paragraph3); // phu luc 5 Phrase phrase51 = new Phrase( "Ph lc V: Bng tnh ton h s phc tp k thut - cng ngh"); Paragraph paragraph51 = new Paragraph("", f1); paragraph51.setIndentationLeft(80); paragraph51.setIndentationRight(80); paragraph51.setAlignment(Element.ALIGN_CENTER); paragraph51.setSpacingAfter(10); paragraph51.add(phrase51); document.add(paragraph51); document.add(paragraph2); PdfPTable table5 = new PdfPTable(5); table5.setWidthPercentage(400 / 5.23f); table5.setWidths(new int[] { 1, 6, 2, 2, 2 }); for (int i = 0; i < listTCF.size(); i++) { PdfPCell data = new PdfPCell(new Paragraph(listTCF.get(i), f2)); table5.addCell(data); } document.add(table5); document.add(paragraph3); document.add(paragraph3); document.add(paragraph3); //phu luc 6 Phrase phrase61 = new Phrase( "Ph lc VI: Bng tnh ton h s tc ng mi tr?ng v nhm lm vic, h s phc tp v? mi tr?ng"); Paragraph paragraph61 = new Paragraph("", f1); paragraph61.setIndentationLeft(80); paragraph61.setIndentationRight(80); paragraph61.setAlignment(Element.ALIGN_CENTER); paragraph61.setSpacingAfter(10); paragraph61.add(phrase61); document.add(paragraph61); document.add(paragraph2); PdfPTable table6 = new PdfPTable(6); table6.setWidthPercentage(400 / 5.23f); table6.setWidths(new int[] { 1, 6, 2, 2, 2, 3 }); for (int i = 0; i < listEF.size(); i++) { PdfPCell data = new PdfPCell(new Paragraph(listEF.get(i), f2)); table6.addCell(data); } document.add(table6); document.add(paragraph3); document.add(paragraph3); document.add(paragraph3); //phu luc 7 Phrase phrase7 = new Phrase("Ph lc VII: Bng tnh ton gi tr phn m?m"); Paragraph paragraph7 = new Paragraph("", f1); paragraph7.setIndentationLeft(80); paragraph7.setIndentationRight(80); paragraph7.setAlignment(Element.ALIGN_CENTER); paragraph7.setSpacingAfter(10); paragraph7.add(phrase7); document.add(paragraph7); document.add(paragraph2); PdfPTable table7 = new PdfPTable(5); table7.setWidthPercentage(400 / 5.23f); table7.setWidths(new int[] { 1, 5, 5, 4, 2 }); for (int i = 0; i < listG.size(); i++) { PdfPCell data = new PdfPCell(new Paragraph(listG.get(i), f2)); table7.addCell(data); } document.add(table7); document.add(paragraph3); document.add(paragraph3); document.add(paragraph3); // phu luc 8 Paragraph paragraph1 = new Paragraph("", f1); paragraph1.setIndentationLeft(80); paragraph1.setIndentationRight(80); paragraph1.setAlignment(Element.ALIGN_CENTER); paragraph1.setSpacingAfter(10); Phrase phrase1 = new Phrase("Ph lc VIII: Bng tng hp chi ph phn m?m"); paragraph1.add(phrase1); document.add(paragraph1); document.add(paragraph2); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(400 / 5.23f); table.setWidths(new int[] { 1, 5, 3, 4, 2 }); for (int i = 0; i < list.size(); i++) { PdfPCell data = new PdfPCell(new Paragraph(list.get(i), f2)); table.addCell(data); } document.add(table); document.close(); } catch (DocumentException | FileNotFoundException e) { } }
From source file:Model.Emprestimo.java
private void resultado() { Document documento = new Document(); Livro l;//from w w w. j a v a 2s .c om try { PdfWriter.getInstance(documento, new FileOutputStream("Emprestimo" + id() + ".pdf")); } catch (DocumentException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } documento.open(); try { Paragraph pa = new Paragraph(); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 28, Font.BOLD, new BaseColor(0, 0, 225)); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_CENTER); pa.setSpacingAfter(50); pa.add("Emprestimo"); documento.add(pa); fonte = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("id: " + Integer.toString(id())); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("ra: " + Integer.toString(this.getRa())); documento.add(pa); String lin = ""; String[] h = this.Livros.split("/"); for (int c = 0; c < h.length; c++) { l = new Livro(); l.consultar(Integer.parseInt(h[c])); lin = lin + l.getNome() + "\n"; } pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Livros: " + lin); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Data de Realizao: " + this.dataR); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Data de Devoluo: " + this.dataD); documento.add(pa); } catch (DocumentException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } documento.close(); }
From source file:net.sf.timecult.export.pdf.PdfTaskListExporter.java
License:Open Source License
public static void export(Workspace ws, String fileName) throws IOException { Document document = new Document(); try {//from w w w .j a va 2 s .c o m PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); Paragraph title = new Paragraph(ResourceHelper.getString("tasklist.title"), titleFont); title.setSpacingAfter(10); document.add(title); createTaskList(document, new TaskStatus(TaskStatus.IN_PROGRESS), Task.class); createTaskList(document, new TaskStatus(TaskStatus.FlagColor.RED), Task.class); createTaskList(document, new TaskStatus(TaskStatus.FlagColor.ORANGE), Task.class); createTaskList(document, new TaskStatus(TaskStatus.FlagColor.BLUE), Task.class); createTaskList(document, new TaskStatus(TaskStatus.FlagColor.GREEN), Task.class); createTaskList(document, new TaskStatus(TaskStatus.FlagColor.MAGENTA), Task.class); createTaskList(document, new TaskStatus(TaskStatus.NOT_STARTED), Task.class); createTaskList(document, new TaskStatus(TaskStatus.WAITING), Task.class); } catch (DocumentException e) { throw new IOException(e); } document.close(); }
From source file:net.sf.timecult.export.pdf.PdfTaskListExporter.java
License:Open Source License
private static void createTaskList(Document doc, TaskStatus taskStatus, Class<Task> taskSubtype) throws DocumentException, IOException { String tag = "tasklist." + taskStatus.toString(); if (taskStatus.getId() == TaskStatus.FLAGGED) { tag = taskStatus.getFlagColor().toString().toLowerCase() + "Flag"; }/*from www. j a v a 2 s . c o m*/ String titleText = ResourceHelper.getString("button." + tag + ".tooltip"); Paragraph subTitle = new Paragraph(titleText, sectionFont); subTitle.setSpacingAfter(10); subTitle.setSpacingBefore(10); doc.add(subTitle); Task filteredTasks[] = TimeTracker.getInstance().getWorkspace().getTasksByStatus(taskStatus); TreeMap<String, Task> sortedItems = new TreeMap<String, Task>(); for (int i = 0; i < filteredTasks.length; i++) { sortedItems.put(filteredTasks[i].toString(), filteredTasks[i]); } Collection<Task> tasks = sortedItems.values(); com.itextpdf.text.List taskList = new List(); for (Task task : tasks) { // // Add flagged items regardless of their subtype (task or activity) // if ((taskStatus.getId() == TaskStatus.FLAGGED && task.getStatus().getId() == TaskStatus.FLAGGED) || task.getClass().equals(taskSubtype)) { Paragraph namePar = new Paragraph(task.getName(), textFont); ListItem taskItem = new ListItem(); taskItem.add(namePar); if (taskStatus.getId() == TaskStatus.WAITING) { Paragraph reasonPar = new Paragraph(task.getWaitReason().getText(), commentFont); taskItem.add(reasonPar); } taskList.add(taskItem); } } doc.add(taskList); }
From source file:org.dspace.disseminate.CitationDocument.java
/** * Takes a DSpace {@link Bitstream} and uses its associated METADATA to * create a cover page./*from w ww . j a va2s .com*/ * * @param cDoc The cover page document to add cited information to. * @param writer * @param cMeta * METADATA retrieved from the parent collection. * @throws IOException * @throws DocumentException */ private void generateCoverPage(Document cDoc, PdfWriter writer, CitationMeta cMeta) throws DocumentException { cDoc.open(); writer.setCompressionLevel(0); Item item = cMeta.getItem(); //Set up some fonts Font helv26 = FontFactory.getFont(FontFactory.HELVETICA, 26f, BaseColor.BLACK); Font helv16 = FontFactory.getFont(FontFactory.HELVETICA, 16f, BaseColor.BLACK); Font helv12 = FontFactory.getFont(FontFactory.HELVETICA, 12f, BaseColor.BLACK); Font helv12_italic = FontFactory.getFont(FontFactory.HELVETICA_OBLIQUE, 12f, BaseColor.BLACK); Font helv11_bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11f, BaseColor.BLACK); Font helv9 = FontFactory.getFont(FontFactory.HELVETICA, 9f, BaseColor.BLACK); // 1 - Header: // University Name // Repository Name repository.url Paragraph university = new Paragraph("The Ohio State University", helv11_bold); cDoc.add(university); PdfPTable repositoryTable = new PdfPTable(2); repositoryTable.setWidthPercentage(100); Chunk repositoryName = new Chunk("Knowledge Bank", helv11_bold); PdfPCell nameCell = new PdfPCell(); nameCell.setBorderWidth(0); nameCell.addElement(repositoryName); Chunk repositoryURL = new Chunk("kb.osu.edu", helv11_bold); repositoryURL.setAnchor("http://kb.osu.edu"); PdfPCell urlCell = new PdfPCell(); urlCell.setHorizontalAlignment(Element.ALIGN_RIGHT); urlCell.setBorderWidth(0); urlCell.addElement(repositoryURL); repositoryTable.addCell(nameCell); repositoryTable.addCell(urlCell); repositoryTable.setSpacingAfter(5); cDoc.add(repositoryTable); // Line Separator LineSeparator lineSeparator = new LineSeparator(); cDoc.add(lineSeparator); // 2 - Bread Crumbs // Community Name Collection Name PdfPTable breadcrumbTable = new PdfPTable(2); breadcrumbTable.setWidthPercentage(100); Chunk communityName = new Chunk(getOwningCommunity(item), helv9); PdfPCell commCell = new PdfPCell(); commCell.setBorderWidth(0); commCell.addElement(communityName); Chunk collectionName = new Chunk(getOwningCollection(item), helv9); PdfPCell collCell = new PdfPCell(); collCell.setHorizontalAlignment(Element.ALIGN_RIGHT); collCell.setBorderWidth(0); collCell.addElement(collectionName); breadcrumbTable.addCell(commCell); breadcrumbTable.addCell(collCell); breadcrumbTable.setSpacingBefore(5); breadcrumbTable.setSpacingAfter(5); cDoc.add(breadcrumbTable); // Line Separator cDoc.add(lineSeparator); // 3 - Metadata // date.issued // dc.title // dc.creator; dc.creator Paragraph dateIssued = new Paragraph(getFirstMetadata(item, "dc.date.issued"), helv12); dateIssued.setSpacingBefore(20); cDoc.add(dateIssued); Paragraph title = new Paragraph(item.getName(), helv26); title.setSpacingBefore(15); cDoc.add(title); Paragraph creators = new Paragraph(getAllMetadataSeperated(item, "dc.creator"), helv16); creators.setSpacingBefore(30); creators.setSpacingAfter(20); cDoc.add(creators); // Line Separator cDoc.add(lineSeparator); // 4 - Citation // dc.identifier.citation // dc.identifier.uri Paragraph citation = new Paragraph(getFirstMetadata(item, "dc.identifier.citation"), helv12); Chunk identifierChunk = new Chunk(getFirstMetadata(item, "dc.identifier.uri"), helv12); identifierChunk.setAnchor(getFirstMetadata(item, "dc.identifier.uri")); Paragraph identifier = new Paragraph(); identifier.add(identifierChunk); cDoc.add(citation); cDoc.add(identifier); // 5 - License // Downloaded from the Knowledge Bank, The Ohio State University's institutional repository Paragraph license = new Paragraph( "Downloaded from the Knowledge Bank, The Ohio State University's institutional repository", helv12_italic); license.setSpacingBefore(10); cDoc.add(license); cDoc.close(); }
From source file:org.fatec.lpbd.projetocurriculo.controller.CurriculoHelper.java
public static Paragraph titleString(String text) { Font f = new Font(FontFamily.COURIER, 20, Font.BOLD); Paragraph p = new Paragraph(text, f); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(20); return p;//from ww w. ja v a 2 s . c o m }