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:gov.medicaid.services.util.PDFHelper.java
License:Apache License
/** * Adds a centered cell to the given table. * * @param table the table to add the cell to * @param value the value text//from ww w .j a v a2 s . c o m */ public static void addCenterCell(PdfPTable table, String value) { PdfPCell val = new PdfPCell( new Phrase(Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7))); val.setBorder(Rectangle.NO_BORDER); val.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); val.setVerticalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(val); }
From source file:gov.utah.dts.det.ccl.documents.templating.templates.AbstractCaseloadTemplate.java
@Override public void render(Map<String, Object> context, OutputStream outputStream, FileDescriptor descriptor) throws TemplateException { Long specialistId = (Long) context.get("specId"); if (specialistId == null) { throw new TemplateException("Specialist id is required."); }//www . java 2 s. c om CaseloadSortBy sortBy = CaseloadSortBy.getDefaultSortBy(); String sortByStr = (String) context.get("sortBy"); if (sortByStr != null) { sortBy = CaseloadSortBy.valueOf(sortByStr); } Person specialist = personService.getPerson(specialistId); context.put(SPECIALIST_KEY, specialist); List<FacilityCaseloadView> caseload = getCaseload(specialistId, sortBy); setFileName(context, descriptor); try { Document document = new Document(PageSize.LETTER.rotate(), MARGIN, MARGIN, MARGIN, MARGIN); PdfWriter.getInstance(document, outputStream); document.open(); document.add(new Paragraph(getReportTitle() + " for " + specialist.getFirstAndLastName(), FONT)); //columns: name, facility id, address, phone, 1st director(s), status, type, capacity (<2) PdfPTable table = new PdfPTable(8); table.setWidths(new float[] { 23f, 25f, 11f, 13f, 5f, 9f, 7f, 7f }); table.setWidthPercentage(100); table.setSpacingBefore(FONT_SIZE); table.getDefaultCell().setPadding(TABLE_CELL_PADDING); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.getDefaultCell().setBorderWidthBottom(.5f); table.setHeaderRows(1); table.addCell(new Phrase("Facility Name", HEADER_FONT)); table.addCell(new Phrase("Address", HEADER_FONT)); table.addCell(new Phrase("Phone", HEADER_FONT)); table.addCell(new Phrase("1st Director(s)", HEADER_FONT)); table.addCell(new Phrase("Type", HEADER_FONT)); table.addCell(new Phrase("Exp Dt", HEADER_FONT)); table.addCell(new Phrase("Adult Cap", HEADER_FONT)); table.addCell(new Phrase("Youth Cap", HEADER_FONT)); boolean hasInProcess = false; for (FacilityCaseloadView fcv : caseload) { if (fcv.getStatus() == FacilityStatus.REGULATED || fcv.getStatus() == FacilityStatus.IN_PROCESS) { StringBuilder name = new StringBuilder(); if (fcv.getStatus() == FacilityStatus.IN_PROCESS) { hasInProcess = true; name.append("* "); } name.append(fcv.getName()); table.addCell(new Phrase(name.toString(), FONT)); table.addCell(new Phrase(fcv.getLocationAddress().toString(), FONT)); table.addCell(new Phrase(fcv.getPrimaryPhone().getFormattedPhoneNumber(), FONT)); table.addCell(new Phrase(fcv.getDirectorNames(), FONT)); String typeAbbrev = null; /* if (fcv.getLicenseType() != null) { typeAbbrev = applicationService.getApplicationPropertyValue("facility.license.type." + fcv.getLicenseType().getId()+ ".abbrev"); } */ table.addCell(new Phrase(typeAbbrev != null ? typeAbbrev : "", FONT)); // table.addCell(new Phrase(fcv.getExpirationDate() != null ? DATE_FORMATTER.format(fcv.getExpirationDate()) : "", FONT)); table.addCell(new Phrase("", FONT)); // if (fcv.getAdultTotalSlots() == null) { table.addCell(new Phrase("")); // } else { // table.addCell(new Phrase(fcv.getAdultTotalSlots().toString(), FONT)); // } // if (fcv.getYouthTotalSlots() == null) { table.addCell(new Phrase("")); // } else { // table.addCell(new Phrase(fcv.getYouthTotalSlots().toString(), FONT)); // } } } document.add(table); if (hasInProcess) { document.add(new Paragraph( "* - Facility is in the process of becoming a regulated child care facility.", FONT)); } document.close(); } catch (DocumentException de) { throw new TemplateException(de); } }
From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Mthode principale qui gre l'export d'un tableau vers un fichier ODS. * * @param export paramtres du document exporter * @param out flux de sortie//from www. j a va 2 s . c om * @throws DocumentException Exception */ public final void exportData(final Export export, final OutputStream out) throws DocumentException { // step 1: creation of a document-object final boolean landscape = export.getOrientation() == Export.Orientation.Landscape; final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4; final Document document = new Document(pageSize, 20, 20, 50, 50); // left, // right, // top, // bottom // step 2: we create a writer that listens to the document and directs a // PDF-stream to out createWriter(document, out); // we add some meta information to the document, and we open it final String title = export.getTitle(); if (title != null) { final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } final String author = export.getAuthor(); document.addAuthor(author); document.addCreator(CREATOR); document.open(); try { // pour ajouter l'ouverture automatique de la bote de dialogue // imprimer // (print(false) pour imprimer directement) // ((PdfWriter) writer).addJavaScript("this.print(true);", false); for (final ExportSheet exportSheet : export.getSheets()) { final Table datatable; if (exportSheet.hasDtObject()) { // table datatable = new Table(2); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // data rows renderObject(exportSheet, datatable); } else { // table datatable = new Table(exportSheet.getExportFields().size()); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // headers renderHeaders(exportSheet, datatable); // data rows renderList(exportSheet, datatable); } document.add(datatable); } } finally { // we close the document document.close(); } }
From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java
License:Apache License
/** * Mthode principale qui gre l'export d'un tableau vers un fichier ODS. * * @param export paramtres du document exporter * @param out flux de sortie//from w w w . j a v a2 s . c o m * @throws DocumentException Exception */ public final void exportData(final Export export, final OutputStream out) throws DocumentException { // step 1: creation of a document-object final boolean landscape = export.getOrientation() == Export.Orientation.Landscape; final Rectangle pageSize = landscape ? PageSize.A4.rotate() : PageSize.A4; final Document document = new Document(pageSize, 20, 20, 50, 50); // left, right, top, bottom // step 2: we create a writer that listens to the document and directs a PDF-stream to out createWriter(document, out); // we add some meta information to the document, and we open it final String title = export.getTitle(); if (title != null) { final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } final String author = export.getAuthor(); document.addAuthor(author); document.addCreator(CREATOR); document.open(); try { // pour ajouter l'ouverture automatique de la bote de dialogue imprimer (print(false) pour imprimer directement) // ((PdfWriter) writer).addJavaScript("this.print(true);", false); for (final ExportSheet exportSheet : export.getSheets()) { final Table datatable; if (exportSheet.hasDtObject()) { // table datatable = new Table(2); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // data rows renderObject(exportSheet, datatable); } else { // table datatable = new Table(exportSheet.getExportFields().size()); datatable.setCellsFitPage(true); datatable.setPadding(4); datatable.setSpacing(0); // headers renderHeaders(exportSheet, datatable); // data rows renderList(exportSheet, datatable); } document.add(datatable); } } finally { // we close the document document.close(); } }
From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java
License:Open Source License
public void createCommuneFooter(PdfWriter writer) throws Exception { PdfContentByte cb = writer.getDirectContent(); Font nameFont = getDefaultParagraphFont(); nameFont.setSize(9);/*from w ww .j a v a 2 s. c o m*/ Font textFont = getDefaultTextFont(); textFont.setSize(9); PdfPTable table = new PdfPTable(4); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.getDefaultCell().setNoWrap(true); IWBundle iwb = getIWApplicationContext().getIWMainApplication() .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER); table.addCell(new Phrase(iwb.getProperty("commune.name_mailaddr", "Mailaddress"), nameFont)); table.addCell(new Phrase(iwb.getProperty("commune.name_visitaddr", "Visitaddress"), nameFont)); table.addCell(new Phrase(iwb.getProperty("commune.name_contact", "Contact"), nameFont)); table.addCell(new Phrase(iwb.getProperty("commune.name_org_nr", "Organizationsnr"), nameFont)); table.addCell(new Phrase(iwb.getProperty("commune.mail_name", "Mail name"), getTextFont())); table.addCell(new Phrase(iwb.getProperty("commune.visit_name", "Visit name"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.website", "www.some-place.com"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.org_number", "XXXXXX-XXXX"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.mail_zip", "Zip code"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.visit_streetaddr", "Street and number,"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.support_email", "email@someplace.com"), textFont)); table.addCell(new Phrase(" ", textFont)); table.addCell(new Phrase(" ", textFont)); table.addCell(new Phrase(iwb.getProperty("commune.visit_zip", "Visit zip"), textFont)); table.addCell(new Phrase(iwb.getProperty("commune.office_phone", "office phone"), textFont)); table.addCell(new Phrase(" ", textFont)); int distFromBottomMM = 30; int[] widths = { 20, 20, 30, 20 }; table.setWidths(widths); table.setTotalWidth(getPointsFromMM(210 - 25 - 20)); table.writeSelectedRows(0, -1, getPointsFromMM(25), getPointsFromMM(distFromBottomMM), cb); PdfContentByte linebyte = new PdfContentByte(writer); // we add some crosses to visualize the destinations linebyte.moveTo(getPointsFromMM(25), getPointsFromMM(distFromBottomMM + 2)); linebyte.lineTo(getPointsFromMM(210 - 25), getPointsFromMM(distFromBottomMM + 2)); linebyte.stroke(); // we add the template on different positions cb.add(linebyte); }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private void addReplyLink(Document document, String replyURL) throws DocumentException { PdfPTable replyTable = new PdfPTable(1); replyTable.setWidthPercentage(100f); replyTable.setSplitLate(false);/* ww w . j a va2s . c o m*/ replyTable.setSpacingBefore(5f); replyTable.setHorizontalAlignment(Element.ALIGN_LEFT); Font linkFont = new Font(); linkFont.setStyle(Font.BOLD); linkFont.setColor(0, 0, 255); linkFont.setSize(headerFontSize); Chunk anchor = new Chunk("Reply", linkFont); anchor.setAnchor(replyURL); Phrase phrase = new Phrase(); phrase.add(anchor); PdfPCell cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); replyTable.addCell(cell); document.add(replyTable); }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
public void buildPDF(MimeMessage message, String replyURL, OutputStream pdfStream) throws DocumentException, MessagingException, IOException { Document document = createDocument(); PdfWriter pdfWriter = createPdfWriter(document, pdfStream); document.open();/* ww w .j a v a 2s .com*/ String[] froms = null; try { froms = EmailAddressUtils.addressesToStrings(message.getFrom(), true /* mime decode */); } catch (MessagingException e) { logger.warn("From address is not a valid email address."); } if (froms != null) { for (String from : froms) { document.addAuthor(from); } } String subject = null; try { subject = message.getSubject(); } catch (MessagingException e) { logger.error("Error getting subject.", e); } if (subject != null) { document.addSubject(subject); document.addTitle(subject); } String[] tos = null; try { tos = EmailAddressUtils.addressesToStrings(message.getRecipients(RecipientType.TO), true /* mime decode */); } catch (MessagingException e) { logger.warn("To is not a valid email address."); } String[] ccs = null; try { ccs = EmailAddressUtils.addressesToStrings(message.getRecipients(RecipientType.CC), true /* mime decode */); } catch (MessagingException e) { logger.warn("CC is not a valid email address."); } Date sentDate = null; try { sentDate = message.getSentDate(); } catch (MessagingException e) { logger.error("Error getting sent date.", e); } Collection<Part> attachments = new LinkedList<Part>(); String body = BodyPartUtils.getPlainBodyAndAttachments(message, attachments); attachments = preprocessAttachments(attachments); if (body == null) { body = MISSING_BODY; } /* * PDF does not have tab support so we convert tabs to spaces */ body = StringReplaceUtils.replaceTabsWithSpaces(body, tabWidth); PdfPTable headerTable = new PdfPTable(2); headerTable.setHorizontalAlignment(Element.ALIGN_LEFT); headerTable.setWidthPercentage(100); headerTable.setWidths(new int[] { 1, 6 }); headerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); Font headerFont = createHeaderFont(); FontSelector headerFontSelector = createHeaderFontSelector(); PdfPCell cell = new PdfPCell(new Paragraph("From:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); String decodedFroms = StringUtils.defaultString(StringUtils.join(froms, ", ")); headerTable.addCell(headerFontSelector.process(decodedFroms)); cell = new PdfPCell(new Paragraph("To:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(StringUtils.join(tos, ", ")))); cell = new PdfPCell(new Paragraph("CC:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(StringUtils.join(ccs, ", ")))); cell = new PdfPCell(new Paragraph("Subject:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(subject))); cell = new PdfPCell(new Paragraph("Date:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(ObjectUtils.toString(sentDate)); cell = new PdfPCell(new Paragraph("Attachments:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable .addCell(headerFontSelector.process(StringUtils.defaultString(getAttachmentHeader(attachments)))); document.add(headerTable); if (replyURL != null) { addReplyLink(document, replyURL); } /* * Body table will contain the body of the message */ PdfPTable bodyTable = new PdfPTable(1); bodyTable.setWidthPercentage(100f); bodyTable.setSplitLate(false); bodyTable.setSpacingBefore(15f); bodyTable.setHorizontalAlignment(Element.ALIGN_LEFT); addBodyAndAttachments(pdfWriter, document, bodyTable, body, attachments); Phrase footer = new Phrase(FOOTER_TEXT); PdfContentByte cb = pdfWriter.getDirectContent(); ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, footer, document.right(), document.bottom(), 0); document.close(); }
From source file:net.bull.javamelody.internal.web.pdf.PdfDocumentFactory.java
License:Apache License
private void createWriter(Document document, String title) throws DocumentException, IOException { final PdfWriter writer = PdfWriter.getInstance(document, output); //writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft); // title/* w w w .j av a 2 s .c o m*/ final HeaderFooter header = new HeaderFooter(new Phrase(title), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); // simple page numbers : x //HeaderFooter footer = new HeaderFooter(new Phrase(), true); //footer.setAlignment(Element.ALIGN_RIGHT); //footer.setBorder(Rectangle.TOP); //document.setFooter(footer); // add the event handler for advanced page numbers : x/y writer.setPageEvent(new PdfAdvancedPageNumberEvents()); }
From source file:net.bull.javamelody.swing.print.MPdfWriter.java
License:Apache License
/** * We create a writer that listens to the document and directs a PDF-stream to out * * @param table/* w w w. j a v a2 s.c o m*/ * MBasicTable * @param document * Document * @param out * OutputStream * @return DocWriter * @throws DocumentException * e */ protected DocWriter createWriter(final MBasicTable table, final Document document, final OutputStream out) throws DocumentException { final PdfWriter writer = PdfWriter.getInstance(document, out); // writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft); // title if (table.getName() != null) { final HeaderFooter header = new HeaderFooter(new Phrase(table.getName()), false); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(table.getName()); } // simple page numbers : x // HeaderFooter footer = new HeaderFooter(new Phrase(), true); // footer.setAlignment(Element.ALIGN_RIGHT); // footer.setBorder(Rectangle.TOP); // document.setFooter(footer); // add the event handler for advanced page numbers : x/y writer.setPageEvent(new AdvancedPageNumberEvents()); return writer; }
From source file:net.bull.javamelody.swing.print.MRtfWriter.java
License:Apache License
/** * We create a writer that listens to the document and directs a RTF-stream to out * * @param table//from w w w . ja va 2 s. c om * MBasicTable * @param document * Document * @param out * OutputStream * @return DocWriter */ @Override protected DocWriter createWriter(final MBasicTable table, final Document document, final OutputStream out) { final RtfWriter2 writer = RtfWriter2.getInstance(document, out); // title final String title = buildTitle(table); if (title != null) { final HeaderFooter header = new RtfHeaderFooter(new Paragraph(title)); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } // advanced page numbers : x/y final Paragraph footerParagraph = new Paragraph(); final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL); footerParagraph.add(new RtfPageNumber(font)); footerParagraph.add(new Phrase(" / ", font)); footerParagraph.add(new RtfTotalPageNumber(font)); footerParagraph.setAlignment(Element.ALIGN_CENTER); final HeaderFooter footer = new RtfHeaderFooter(footerParagraph); footer.setBorder(Rectangle.TOP); document.setFooter(footer); return writer; }