List of usage examples for com.lowagie.text Paragraph setAlignment
public void setAlignment(String alignment)
From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java
License:Open Source License
protected void writeInvoiceSectionTitle(com.lowagie.text.Document pdfDoc, String customerNameLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); paragraph.add(new Chunk(customerNameLine, font)); // blank line paragraph.add(new Chunk("", font)); try {// ww w.ja va 2s . co m pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java
License:Open Source License
protected void writeInvoiceSectionMessage(com.lowagie.text.Document pdfDoc, String resultLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); paragraph.add(new Chunk(resultLine, font)); // blank line paragraph.add(new Chunk("", font)); try {/*from w w w. j av a2s . c o m*/ pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java
License:Open Source License
protected void writeFileNameSectionTitle(Document pdfDoc, String filenameLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); Chunk chunk = new Chunk(filenameLine, font); chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5); paragraph.add(chunk);//from w w w.j ava2 s . c om // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java
License:Open Source License
protected void writeCustomerSectionTitle(Document pdfDoc, String customerNameLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD + Font.UNDERLINE); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); paragraph.add(new Chunk(customerNameLine, font)); // blank line paragraph.add(new Chunk("", font)); try {/*from w w w . j a va 2 s . c o m*/ pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java
License:Open Source License
protected void writeCustomerSectionResult(Document pdfDoc, String resultLine) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); paragraph.add(new Chunk(resultLine, font)); // blank line paragraph.add(new Chunk("", font)); try {/*from ww w .j a v a 2 s. c o m*/ pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerLoadServiceImpl.java
License:Open Source License
protected void writeMessageEntryLines(Document pdfDoc, List<String[]> messageLines) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL); Paragraph paragraph; String messageEntry;//from ww w . j a v a 2s .c om for (String[] messageLine : messageLines) { paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_LEFT); messageEntry = StringUtils.rightPad(messageLine[0], (12 - messageLine[0].length()), " ") + " - " + messageLine[1].toUpperCase(); paragraph.add(new Chunk(messageEntry, font)); // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } } }
From source file:org.kuali.kfs.module.ar.batch.service.impl.LockboxServiceImpl.java
License:Open Source License
protected void writeBatchGroupSectionTitle(com.lowagie.text.Document pdfDoc, String batchSeqNbr, java.sql.Date procInvDt, String cashControlDocNumber) { Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD); String lineText = "CASHCTL " + rightPad(cashControlDocNumber, 12) + " " + "BATCH GROUP: " + rightPad(batchSeqNbr, 5) + " " + rightPad((procInvDt == null ? "NONE" : procInvDt.toString()), 35); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); Chunk chunk = new Chunk(lineText, font); chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5); paragraph.add(chunk);//from w ww.j a va2 s .c o m // blank line paragraph.add(new Chunk("", font)); try { pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } }
From source file:org.kuali.kfs.module.ar.batch.service.impl.LockboxServiceImpl.java
License:Open Source License
protected void writeDetailLine(com.lowagie.text.Document pdfDoc, String detailLineText) { if (ObjectUtils.isNotNull(detailLineText)) { Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT); paragraph.add(new Chunk(detailLineText, font)); try {/*from w ww. j a v a2s . c om*/ pdfDoc.add(paragraph); } catch (DocumentException e) { LOG.error("iText DocumentException thrown when trying to write content.", e); throw new RuntimeException("iText DocumentException thrown when trying to write content.", e); } } }
From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java
License:Open Source License
/** * this method generated the actual pdf for the Contracts & Grants LOC Review Document. * * @param os//from w ww. j a v a2 s . co m * @param LOCDocument */ protected void generateLOCReviewInPdf(OutputStream os, ContractsGrantsLetterOfCreditReviewDocument locDocument) { try { Document document = new Document( new Rectangle(ArConstants.LOCReviewPdf.LENGTH, ArConstants.LOCReviewPdf.WIDTH)); PdfWriter.getInstance(document, os); document.open(); Paragraph header = new Paragraph(); Paragraph text = new Paragraph(); Paragraph title = new Paragraph(); // Lets write the header header.add(new Paragraph(configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_TITLE), ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT)); if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundGroupCode())) { header.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_GROUP_CODE) + locDocument.getLetterOfCreditFundGroupCode(), ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT)); } if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundCode())) { header.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_CODE) + locDocument.getLetterOfCreditFundCode(), ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT)); } header.add(new Paragraph(KFSConstants.BLANK_SPACE)); header.setAlignment(Element.ALIGN_CENTER); title.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_NUMBER) + locDocument.getDocumentNumber(), ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT)); Person person = getPersonService() .getPerson(locDocument.getFinancialSystemDocumentHeader().getInitiatorPrincipalId()); // writing the Document details title.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_APP_DOC_STATUS) + locDocument.getFinancialSystemDocumentHeader().getApplicationDocumentStatus(), ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT)); title.add( new Paragraph( configService.getPropertyValueAsString( ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_INITIATOR) + person.getName(), ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT)); title.add(new Paragraph( configService .getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_CREATE_DATE) + getDateTimeService().toDateString( locDocument.getFinancialSystemDocumentHeader().getWorkflowCreateDate()), ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT)); title.add(new Paragraph(KFSConstants.BLANK_SPACE)); title.setAlignment(Element.ALIGN_RIGHT); text.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_SUBHEADER_AWARDS), ArConstants.PdfReportFonts.LOC_REVIEW_SMALL_BOLD)); text.add(new Paragraph(KFSConstants.BLANK_SPACE)); document.add(header); document.add(title); document.add(text); PdfPTable table = new PdfPTable(11); table.setTotalWidth(ArConstants.LOCReviewPdf.RESULTS_TABLE_WIDTH); // fix the absolute width of the table table.setLockedWidth(true); // relative col widths in proportions - 1/11 float[] widths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f }; table.setWidths(widths); table.setHorizontalAlignment(0); addAwardHeaders(table); if (CollectionUtils.isNotEmpty(locDocument.getHeaderReviewDetails()) && CollectionUtils.isNotEmpty(locDocument.getAccountReviewDetails())) { for (ContractsGrantsLetterOfCreditReviewDetail item : locDocument.getHeaderReviewDetails()) { table.addCell(Long.toString(item.getProposalNumber())); table.addCell(item.getAwardDocumentNumber()); table.addCell(item.getAgencyNumber()); table.addCell(item.getCustomerNumber()); table.addCell(getDateTimeService().toDateString(item.getAwardBeginningDate())); table.addCell(getDateTimeService().toDateString(item.getAwardEndingDate())); table.addCell( contractsGrantsBillingUtilityService.formatForCurrency(item.getAwardBudgetAmount())); table.addCell( contractsGrantsBillingUtilityService.formatForCurrency(item.getLetterOfCreditAmount())); table.addCell( contractsGrantsBillingUtilityService.formatForCurrency(item.getClaimOnCashBalance())); table.addCell(contractsGrantsBillingUtilityService.formatForCurrency(item.getAmountToDraw())); table.addCell(contractsGrantsBillingUtilityService .formatForCurrency(item.getAmountAvailableToDraw())); PdfPCell cell = new PdfPCell(); cell.setPadding(ArConstants.LOCReviewPdf.RESULTS_TABLE_CELL_PADDING); cell.setColspan(ArConstants.LOCReviewPdf.RESULTS_TABLE_COLSPAN); PdfPTable newTable = new PdfPTable(ArConstants.LOCReviewPdf.INNER_TABLE_COLUMNS); newTable.setTotalWidth(ArConstants.LOCReviewPdf.INNER_TABLE_WIDTH); // fix the absolute width of the newTable newTable.setLockedWidth(true); // relative col widths in proportions - 1/8 float[] newWidths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f }; newTable.setWidths(newWidths); newTable.setHorizontalAlignment(0); addAccountsHeaders(newTable); for (ContractsGrantsLetterOfCreditReviewDetail newItem : locDocument .getAccountReviewDetails()) { if (item.getProposalNumber().equals(newItem.getProposalNumber())) { newTable.addCell(newItem.getAccountDescription()); newTable.addCell(newItem.getChartOfAccountsCode()); newTable.addCell(newItem.getAccountNumber()); String accountExpirationDate = KFSConstants.EMPTY_STRING; if (!ObjectUtils.isNull(newItem.getAccountExpirationDate())) { accountExpirationDate = getDateTimeService() .toDateString(newItem.getAccountExpirationDate()); } newTable.addCell(accountExpirationDate); newTable.addCell(contractsGrantsBillingUtilityService .formatForCurrency(newItem.getAwardBudgetAmount())); newTable.addCell(contractsGrantsBillingUtilityService .formatForCurrency(newItem.getClaimOnCashBalance())); newTable.addCell(contractsGrantsBillingUtilityService .formatForCurrency(newItem.getAmountToDraw())); newTable.addCell(contractsGrantsBillingUtilityService .formatForCurrency(newItem.getFundsNotDrawn())); } } cell.addElement(newTable); table.addCell(cell); } document.add(table); } document.close(); } catch (DocumentException e) { LOG.error("problem during ContractsGrantsInvoiceReportServiceImpl.generateInvoiceInPdf()", e); } }
From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java
License:Open Source License
/** * Generates the pdf file for printing the envelopes. * * @param list// w w w. ja v a 2 s.co m * @param outputStream * @throws DocumentException * @throws IOException */ protected void generateCombinedPdfForEnvelopes(Collection<ContractsGrantsInvoiceDocument> list, OutputStream outputStream) throws DocumentException, IOException { Document document = new Document( new Rectangle(ArConstants.InvoiceEnvelopePdf.LENGTH, ArConstants.InvoiceEnvelopePdf.WIDTH)); PdfWriter.getInstance(document, outputStream); boolean pageAdded = false; for (ContractsGrantsInvoiceDocument invoice : list) { // add a document for (InvoiceAddressDetail invoiceAddressDetail : invoice.getInvoiceAddressDetails()) { if (ArConstants.InvoiceTransmissionMethod.MAIL .equals(invoiceAddressDetail.getInvoiceTransmissionMethodCode())) { CustomerAddress address = invoiceAddressDetail.getCustomerAddress(); Integer numberOfEnvelopesToPrint = address.getCustomerEnvelopesToPrintQuantity(); if (ObjectUtils.isNull(numberOfEnvelopesToPrint)) { numberOfEnvelopesToPrint = 1; } for (int i = 0; i < numberOfEnvelopesToPrint; i++) { // if a page has not already been added then open the document. if (!pageAdded) { document.open(); } pageAdded = true; document.newPage(); // adding the sent From address Organization org = invoice.getInvoiceGeneralDetail().getAward() .getPrimaryAwardOrganization().getOrganization(); Paragraph sentBy = generateAddressParagraph(org.getOrganizationName(), org.getOrganizationLine1Address(), org.getOrganizationLine2Address(), org.getOrganizationCityName(), org.getOrganizationStateCode(), org.getOrganizationZipCode(), ArConstants.PdfReportFonts.ENVELOPE_SMALL_FONT); sentBy.setIndentationLeft(ArConstants.InvoiceEnvelopePdf.INDENTATION_LEFT); sentBy.setAlignment(Element.ALIGN_LEFT); // adding the send To address String string; Paragraph sendTo = generateAddressParagraph(address.getCustomerAddressName(), address.getCustomerLine1StreetAddress(), address.getCustomerLine2StreetAddress(), address.getCustomerCityName(), address.getCustomerStateCode(), address.getCustomerZipCode(), ArConstants.PdfReportFonts.ENVELOPE_TITLE_FONT); sendTo.setAlignment(Element.ALIGN_CENTER); sendTo.add(new Paragraph(KFSConstants.BLANK_SPACE)); document.add(sentBy); document.add(sendTo); } } } } if (pageAdded) { document.close(); } }