List of usage examples for com.lowagie.text Rectangle NO_BORDER
int NO_BORDER
To view the source code for com.lowagie.text Rectangle NO_BORDER.
Click Source Link
From source file:org.kuali.kfs.module.endow.report.util.TransactionSummaryReportPrint.java
License:Educational Community License
/** * Generates the report in PDF using iText * /*from w ww.j a v a2 s. com*/ * @param reportRequestHeaderDataHolder * @param transactionStatementDataReportHolders * @return pdfStream */ public ByteArrayOutputStream printTransactionSummaryReport( EndowmentReportHeaderDataHolder reportRequestHeaderDataHolder, List<TransactionSummaryReportDataHolder> transactionSummaryDataReportHolders, String listKemidsInHeader, String reportOption, String summaryTotalsOnly) { Document document = new Document(); document.setPageSize(LETTER_PORTRAIT); document.addTitle("Endowment Transaction Summary"); ByteArrayOutputStream pdfStream = new ByteArrayOutputStream(); try { PdfWriter.getInstance(document, pdfStream); document.open(); // page HeaderFooter header = new HeaderFooter(new Phrase(new Date().toString() + " Page: ", headerFont), true); header.setBorder(Rectangle.NO_BORDER); header.setAlignment(Element.ALIGN_RIGHT); header.setPageNumber(0); document.setHeader(header); // print the report header if (printReportHeaderPage(reportRequestHeaderDataHolder, document, listKemidsInHeader)) { if (transactionSummaryDataReportHolders != null && transactionSummaryDataReportHolders.size() > 0) { if ("Y".equalsIgnoreCase(summaryTotalsOnly)) { printReportBodyBySummaryTotals(transactionSummaryDataReportHolders, document, reportOption); } else { printReportBodyByAllTotals(transactionSummaryDataReportHolders, document, reportOption); } } } else { LOG.error("Transaction Summary Report Header Error"); } document.close(); } catch (Exception e) { LOG.error("PDF Error: " + e.getMessage()); return null; } return pdfStream; }
From source file:org.kuali.kfs.module.endow.report.util.TrialBalanceReportPrint.java
License:Educational Community License
/** * Generates the report in PDF using iText * /* ww w . ja va2 s. c om*/ * @param reportRequestHeaderDataHolder * @param trialBalanceDataReportHolders * @return ByteArrayOutputStream */ public ByteArrayOutputStream printTrialBalanceReport( EndowmentReportHeaderDataHolder reportRequestHeaderDataHolder, List<TrialBalanceReportDataHolder> trialBalanceDataReportHolders, String listKemidsInHeader) { final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(TrialBalanceReportPrint.class); Document document = new Document(); document.setPageSize(LETTER_PORTRAIT); document.addTitle("Endowment Trial Balance"); // get the stream for PDF ByteArrayOutputStream pdfStream = new ByteArrayOutputStream(); try { PdfWriter.getInstance(document, pdfStream); document.open(); // page HeaderFooter header = new HeaderFooter(new Phrase(new Date().toString() + " Page: ", headerFont), true); header.setBorder(Rectangle.NO_BORDER); header.setAlignment(Element.ALIGN_RIGHT); header.setPageNumber(0); document.setHeader(header); // print the report header if (printReportHeaderPage(reportRequestHeaderDataHolder, document, listKemidsInHeader)) { if (trialBalanceDataReportHolders != null && trialBalanceDataReportHolders.size() > 0) { document.setPageSize(LETTER_LANDSCAPE); document.resetPageCount(); header.setPageNumber(1); document.newPage(); printTrialBalanceReportBody(trialBalanceDataReportHolders, document); } else { LOG.error("Trial Balance Report Header Error"); } } document.close(); } catch (Exception e) { LOG.error("PDF Error: " + e.getMessage()); return null; } return pdfStream; }
From source file:org.kuali.kfs.pdp.batch.service.impl.DailyReportServiceImpl.java
License:Educational Community License
protected void addRow(PdfPTable dataTable, DailyReport dr, boolean bold, String name) { DecimalFormat af = new DecimalFormat("###,###,##0.00"); DecimalFormat nf = new DecimalFormat("###,##0"); Font f = null;/*from w w w. ja va2s. c o m*/ if (bold) { f = headerFont; for (int i = 0; i < 5; i++) { PdfPCell cell = new PdfPCell(new Phrase(" ", f)); cell.setBorder(Rectangle.NO_BORDER); dataTable.addCell(cell); } } else { f = textFont; } PdfPCell cell = new PdfPCell(new Phrase(name, f)); cell.setBorder(Rectangle.NO_BORDER); dataTable.addCell(cell); if (!bold) { cell = new PdfPCell(new Phrase(dr.getCustomer(), f)); } else { cell = new PdfPCell(new Phrase("", f)); } cell.setBorder(Rectangle.NO_BORDER); dataTable.addCell(cell); cell = new PdfPCell(new Phrase(af.format(dr.getAmount()), f)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); dataTable.addCell(cell); cell = new PdfPCell(new Phrase(nf.format(dr.getPayments()), f)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); dataTable.addCell(cell); cell = new PdfPCell(new Phrase(nf.format(dr.getPayees()), f)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); dataTable.addCell(cell); if (bold) { for (int i = 0; i < 5; i++) { PdfPCell cell2 = new PdfPCell(new Phrase(" ", f)); cell2.setBorder(Rectangle.NO_BORDER); dataTable.addCell(cell2); } } }
From source file:org.netxilia.server.rest.pdf.SheetPdfProvider.java
License:Open Source License
@Override public void writeTo(SheetFullName sheetName, Class<?> clazz, Type type, Annotation[] ann, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream out) throws IOException, WebApplicationException { if (sheetName == null) { return;//from ww w . ja v a2s . c o m } /** * This is the table, added as an Element to the PDF document. It contains all the data, needed to represent the * visible table into the PDF */ Table tablePDF; /** * The default font used in the document. */ Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0, 0, 0)); ISheet summarySheet = null; ISheet sheet = null; try { sheet = workbookProcessor.getWorkbook(sheetName.getWorkbookId()).getSheet(sheetName.getSheetName()); try { // get the corresponding summary sheet SheetFullName summarySheetName = SheetFullName.summarySheetName(sheetName, userService.getCurrentUser()); summarySheet = workbookProcessor.getWorkbook(summarySheetName.getWorkbookId()) .getSheet(summarySheetName.getSheetName()); } catch (Exception e) { // no summary sheet - go without one } // Initialize the Document and register it with PdfWriter listener and the OutputStream Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40); document.addCreationDate(); HeaderFooter footer = new HeaderFooter(new Phrase("", smallFont), true); footer.setBorder(Rectangle.NO_BORDER); footer.setAlignment(Element.ALIGN_CENTER); PdfWriter.getInstance(document, out); // Fill the virtual PDF table with the necessary data // Initialize the table with the appropriate number of columns tablePDF = initTable(sheet); // take tha maximum numbers of columns int columnCount = sheet.getDimensions().getNonBlocking().getColumnCount(); if (summarySheet != null) { columnCount = Math.max(columnCount, summarySheet.getDimensions().getNonBlocking().getColumnCount()); } generateHeaders(sheet, tablePDF, smallFont, columnCount); tablePDF.endHeaders(); generateRows(sheet, false, tablePDF, smallFont, columnCount); if (summarySheet != null) { generateRows(summarySheet, true, tablePDF, smallFont, columnCount); } document.open(); document.setFooter(footer); document.add(tablePDF); document.close(); out.flush(); out.close(); } catch (Exception e) { throw new IOException(e); } }
From source file:org.opentestsystem.delivery.testreg.rest.view.PDFReportView.java
License:Open Source License
private PdfPTable createMessageHeaders(final String[] headerColumns, final HierarchyLevel level, final String message) throws BadElementException { PdfPTable table = null;/*from ww w . j a va2 s. c om*/ if (level != null && level == HierarchyLevel.CLIENT) { table = new PdfPTable(headerColumns.length - 3); } else { table = new PdfPTable(headerColumns.length); } table.setWidthPercentage(100); PdfPCell cell; cell = new PdfPCell(new Paragraph(message, HEADER_MESSAGE_FONT)); cell.setColspan(headerColumns.length); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); return table; }
From source file:org.sonar.report.pdf.DefaultPDFReporter.java
License:Open Source License
@Override protected void printFrontPage(Document frontPageDocument, PdfWriter frontPageWriter) throws org.dom4j.DocumentException, ReportException { try {//ww w.j a va 2s. c o m URL largeLogo; if (super.getConfigProperty("front.page.logo").startsWith("http://")) { largeLogo = new URL(super.getConfigProperty("front.page.logo")); } else { largeLogo = this.getClass().getClassLoader() .getResource(super.getConfigProperty("front.page.logo")); } Image logoImage = Image.getInstance(largeLogo); Rectangle pageSize = frontPageDocument.getPageSize(); float positionX = pageSize.getWidth() / 2f - logoImage.getWidth() / 2f; logoImage.setAbsolutePosition(positionX, pageSize.getHeight() - logoImage.getHeight() - 100); frontPageDocument.add(logoImage); PdfPTable title = new PdfPTable(1); title.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER); title.getDefaultCell().setBorder(Rectangle.NO_BORDER); String projectRow = super.getTextProperty("general.project") + ": " + super.getProject().getName(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String dateRow = df.format(super.getProject().getMeasures().getDate()); String descriptionRow = super.getProject().getDescription(); title.addCell(new Phrase(projectRow, Style.FRONTPAGE_FONT_1)); title.addCell(new Phrase(descriptionRow, Style.FRONTPAGE_FONT_2)); title.addCell(new Phrase(dateRow, Style.FRONTPAGE_FONT_3)); title.setTotalWidth( pageSize.getWidth() - frontPageDocument.leftMargin() - frontPageDocument.rightMargin()); title.writeSelectedRows(0, -1, frontPageDocument.leftMargin(), pageSize.getHeight() - logoImage.getHeight() - 150, frontPageWriter.getDirectContent()); } catch (IOException e) { e.printStackTrace(); } catch (BadElementException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:org.sonar.report.pdf.ExecutivePDFReporter.java
License:Open Source License
@Override protected void printFrontPage(Document frontPageDocument, PdfWriter frontPageWriter) throws org.dom4j.DocumentException, ReportException { try {//from w w w. j a v a 2 s. c o m URL largeLogo; if (super.getConfigProperty("front.page.logo").startsWith("http://")) { largeLogo = new URL(super.getConfigProperty("front.page.logo")); } else { largeLogo = this.getClass().getClassLoader() .getResource(super.getConfigProperty("front.page.logo")); } Image logoImage = Image.getInstance(largeLogo); logoImage.scaleAbsolute(360, 200); Rectangle pageSize = frontPageDocument.getPageSize(); logoImage.setAbsolutePosition(Style.FRONTPAGE_LOGO_POSITION_X, Style.FRONTPAGE_LOGO_POSITION_Y); frontPageDocument.add(logoImage); PdfPTable title = new PdfPTable(1); title.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER); title.getDefaultCell().setBorder(Rectangle.NO_BORDER); String projectRow = super.getProject().getName(); String versionRow = super.getProject().getMeasures().getVersion(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String dateRow = df.format(super.getProject().getMeasures().getDate()); String descriptionRow = super.getProject().getDescription(); title.addCell(new Phrase(projectRow, Style.FRONTPAGE_FONT_1)); title.addCell(new Phrase(versionRow, Style.FRONTPAGE_FONT_1)); title.addCell(new Phrase(descriptionRow, Style.FRONTPAGE_FONT_2)); title.addCell(new Phrase(super.getProject().getMeasure(MetricKeys.PROFILE).getDataValue(), Style.FRONTPAGE_FONT_3)); title.addCell(new Phrase(dateRow, Style.FRONTPAGE_FONT_3)); title.setTotalWidth( pageSize.getWidth() - frontPageDocument.leftMargin() - frontPageDocument.rightMargin()); title.writeSelectedRows(0, -1, frontPageDocument.leftMargin(), Style.FRONTPAGE_LOGO_POSITION_Y - 150, frontPageWriter.getDirectContent()); } catch (IOException e) { e.printStackTrace(); } catch (BadElementException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:org.unitime.timetable.export.PDFPrinter.java
License:Open Source License
@Override public void printLine(String... fields) { PdfPCellEvent setLineDashEvent = new PdfPCellEvent() { @Override/*from ww w .j ava 2 s .com*/ public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) { PdfContentByte cb = canvas[PdfPTable.LINECANVAS]; cb.setLineDash(new float[] { 2, 2 }, 0); } }; for (int idx = 0; idx < fields.length; idx++) { if (iHiddenColumns.contains(idx)) continue; String f = fields[idx]; if (f == null || f.isEmpty() || (iCheckLast && f.equals(iLastLine == null || idx >= iLastLine.length ? null : iLastLine[idx]))) f = ""; boolean number = sNumber.matcher(f).matches(); Font font = PdfFont.getFont(); Phrase p = new Phrase(f, PdfFont.getSmallFont()); PdfPCell cell = new PdfPCell(p); cell.setBorder(iLastLine == null ? Rectangle.TOP : Rectangle.NO_BORDER); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(number ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT); cell.setPaddingBottom(4f); cell.setCellEvent(setLineDashEvent); if (number) cell.setPaddingRight(10f); iTable.addCell(cell); float width = 0; if (f.indexOf('\n') >= 0) { for (StringTokenizer s = new StringTokenizer(f, "\n"); s.hasMoreTokens();) width = Math.max(width, font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize())); } else width = Math.max(width, font.getBaseFont().getWidthPoint(f, font.getSize())); iMaxWidth[idx] = Math.max(iMaxWidth[idx], width + (number ? 10 : 0)); } iLastLine = fields; }
From source file:org.webguitoolkit.ui.util.export.PDFEvent.java
License:Apache License
public void onEndPage(PdfWriter writer, Document document) { TableExportOptions exportOptions = wgtTable.getExportOptions(); try {/*from w ww.ja v a2s.com*/ Rectangle page = document.getPageSize(); if (exportOptions.isShowDefaultHeader() || StringUtils.isNotEmpty(exportOptions.getHeaderImage())) { PdfPTable head = new PdfPTable(3); head.getDefaultCell().setBorder(Rectangle.NO_BORDER); Paragraph title = new Paragraph(wgtTable.getTitle()); title.setAlignment(Element.ALIGN_LEFT); head.addCell(title); Paragraph empty = new Paragraph(""); head.addCell(empty); if (StringUtils.isNotEmpty(exportOptions.getHeaderImage())) { try { URL absoluteFileUrl = wgtTable.getPage().getClass() .getResource("/" + exportOptions.getHeaderImage()); if (absoluteFileUrl != null) { String path = absoluteFileUrl.getPath(); Image jpg = Image.getInstance(path); jpg.scaleAbsoluteHeight(40); jpg.scaleAbsoluteWidth(200); head.addCell(jpg); } } catch (Exception e) { logger.error(e.getMessage()); Paragraph noImage = new Paragraph("Image not found!"); head.addCell(noImage); } } else { head.addCell(empty); } head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin()); head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent()); } if (exportOptions.isShowDefaultFooter() || StringUtils.isNotEmpty(exportOptions.getFooterText()) || exportOptions.isShowPageNumber()) { PdfPTable foot = new PdfPTable(3); String footerText = exportOptions.getFooterText() != null ? exportOptions.getFooterText() : ""; if (!exportOptions.isShowDefaultFooter()) { foot.addCell(new Paragraph(footerText)); foot.addCell(new Paragraph("")); } else { foot.getDefaultCell().setBorder(Rectangle.NO_BORDER); String leftText = ""; if (StringUtils.isNotEmpty(exportOptions.getFooterText())) { leftText = exportOptions.getFooterText(); } Paragraph left = new Paragraph(leftText); left.setAlignment(Element.ALIGN_LEFT); foot.addCell(left); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM, TextService.getLocale()); Date today = new Date(); String date = df.format(today); Paragraph center = new Paragraph(date); center.setAlignment(Element.ALIGN_CENTER); foot.addCell(center); } if (exportOptions.isShowPageNumber()) { Paragraph right = new Paragraph( TextService.getString("pdf.page@Page:") + " " + writer.getPageNumber()); right.setAlignment(Element.ALIGN_LEFT); foot.addCell(right); foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin()); foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(), writer.getDirectContent()); } else { foot.addCell(new Paragraph("")); } } } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:permit.InvoicePdf.java
License:Open Source License
/** * handles the letter header//w w w. j a v a 2 s. c o m */ PdfPTable getHeader() { // String str = ""; String spacer = " "; PdfPTable headTable = null; try { // // for http url use // Image image = Image.getInstance(url + "js/images/city_logo3.jpg"); Font fnt = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL); Font fntb = new Font(Font.TIMES_ROMAN, 10, Font.BOLD); float[] widths = { 25f, 40f, 35f }; // percentages headTable = new PdfPTable(widths); headTable.setWidthPercentage(100); headTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); headTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); image.scalePercent(15f); PdfPCell cell = new PdfPCell(image); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); headTable.addCell(cell); // float[] width = { 33f }; PdfPTable midTable = new PdfPTable(width); midTable.setWidthPercentage(33); midTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); midTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); Phrase phrase = new Phrase(); Chunk ch = new Chunk("City of Bloomington ", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); midTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("Planning and Transportation Department ", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); midTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("bloomington.in.gov", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); midTable.addCell(cell); // headTable.addCell(midTable); // PdfPTable rightTable = new PdfPTable(width); rightTable.setWidthPercentage(33); rightTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); rightTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); phrase = new Phrase(); ch = new Chunk("401 N Morton St Suite 130 ", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("PO Box 100 \nBloomington, IN 47404", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); // phrase = new Phrase(); ch = new Chunk("\n Phone: (812) 349-3423\nFax (812) 349-3520\nEmail: planning@bloomington.in.gov", fntb); phrase.add(ch); cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); rightTable.addCell(cell); headTable.addCell(rightTable); } catch (Exception ex) { logger.error(ex); } return headTable; }