List of usage examples for com.lowagie.text FontFactory getFont
public static Font getFont(String fontname, float size, int style)
Font
-object. From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java
License:Open Source License
/** * Creates instructions section of the coverpage * * @returns a {@link Paragraph} for the PDF *///w ww .j av a2 s. com protected Paragraph getInstructionsParagraph() { final Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL); final Paragraph retval = new Paragraph(); retval.add(new Chunk("Instructions", headerFont)); retval.add(Chunk.NEWLINE); retval.add(new Phrase(getInstructions(), normalFont)); return retval; }
From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java
License:Open Source License
/** * Creates mailTo section for the coversheet. The MailTo section is where the coversheet will be mailed. * * @returns a {@link Paragraph} for the PDF *//* w w w . ja va 2 s . c o m*/ protected Paragraph getMailtoParagraph() { final Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL); final Paragraph retval = new Paragraph(); retval.add(new Chunk("Mail coversheet to:", headerFont)); retval.add(Chunk.NEWLINE); retval.add(new Phrase(getMailTo(), normalFont)); return retval; }
From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java
License:Open Source License
/** * Helper method to create a Header Cell from text * * @returns {@link Cell} with the header flag set */// w ww . j a v a 2 s . c om protected Cell getBorderlessCell(final String text) throws BadElementException { final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL); final Cell retval = new Cell(new Chunk(text, normalFont)); retval.setBorder(NO_BORDER); return retval; }
From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java
License:Open Source License
/** * Helper method to create a Header Cell from text * * @returns {@link Cell} with the header flag set *//* w w w. j a v a 2 s .c om*/ protected Cell getHeaderCell(final String text) throws BadElementException { final Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Cell retval = new Cell(new Chunk(text, headerFont)); retval.setBorder(NO_BORDER); retval.setHeader(true); return retval; }
From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java
License:Open Source License
/** * @see org.kuali.kfs.module.tem.pdf.PdfStream#print(java.io.OutputStream) * @throws Exception//from w ww . j a va2 s . co m */ @Override public void print(final OutputStream stream) throws Exception { final Font titleFont = FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD); final Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL); final Document doc = new Document(); final PdfWriter writer = PdfWriter.getInstance(doc, stream); doc.open(); if (getDocumentNumber() != null) { Image image = Image.getInstance(new BarcodeHelper().generateBarcodeImage(getDocumentNumber()), null); doc.add(image); } final Paragraph title = new Paragraph("TEM Coversheet", titleFont); doc.add(title); final Paragraph faxNumber = new Paragraph( "Fax this page to " + SpringContext.getBean(ParameterService.class) .getParameterValueAsString(TravelReimbursementDocument.class, FAX_NUMBER), normalFont); doc.add(faxNumber); final Paragraph header = new Paragraph("", headerFont); header.setAlignment(ALIGN_RIGHT); header.add("Document Number: " + getDocumentNumber()); doc.add(header); doc.add(getInstructionsParagraph()); doc.add(getMailtoParagraph()); doc.add(Chunk.NEWLINE); doc.add(getTripInfo()); doc.add(Chunk.NEWLINE); doc.add(getPersonalInfo()); doc.add(Chunk.NEWLINE); doc.add(getExpenses()); drawAlignmentMarks(writer.getDirectContent()); doc.close(); writer.close(); }
From source file:org.kuali.kfs.pdp.batch.service.impl.DailyReportServiceImpl.java
License:Educational Community License
public DailyReportServiceImpl() { headerFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD); textFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL); }
From source file:org.mapfish.print.config.layout.FontBlock.java
License:Open Source License
protected Font getPdfFont() { Font result = FontFactory.getFont(font, fontEncoding, (float) getFontSize()); result.setColor(getFontColorVal()); return result; }
From source file:org.mapfish.print.config.layout.LegendsBlock.java
License:Open Source License
protected Font getLayerPdfFont() { return FontFactory.getFont(layerFont, fontEncoding, (float) layerFontSize); }
From source file:org.mapfish.print.config.layout.LegendsBlock.java
License:Open Source License
protected Font getClassPdfFont() { return FontFactory.getFont(classFont, fontEncoding, (float) classFontSize); }
From source file:org.posterita.businesslogic.administration.CustomerManager.java
License:Open Source License
public static String fidelityCard(Properties ctx, ArrayList<CustomerBean> customerList) throws OperationException { String reportName = RandomStringGenerator.randomstring() + ".pdf"; String reportPath = ReportManager.getReportPath(reportName); boolean shouldPrintCard = false; for (CustomerBean b : customerList) { if (b.getIsActive()) { shouldPrintCard = true;/*from www. j a v a 2s.c o m*/ break; } } if (!shouldPrintCard) { throw new NoCustomerFoundException("Cannot print fidelity card. Cause no active customers were found."); } Document document = new Document(PageSize.A4, 3, 3, 2, 4);//l,r,t,b try { // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.getInstance(document, new FileOutputStream(reportPath)); // step 3: we open the document document.open(); PdfPTable main = new PdfPTable(2); main.setWidthPercentage(71.0f); main.getDefaultCell().setBorderColor(Color.gray); PdfPCell cell = new PdfPCell(); cell.setMinimumHeight(150.0f); Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD); //Font spaceFont = FontFactory.getFont(FontFactory.HELVETICA,6,Font.BOLD); //Font spaceFont2 = FontFactory.getFont(FontFactory.HELVETICA,15,Font.BOLD); //ResourceBundle rb = ResourceBundle.getBundle("MessageResources"); for (CustomerBean bean : customerList) { if (bean.getIsActive()) { String name = bean.getPartnerName(); String name1 = ""; String add2 = ""; String add1 = ""; String city = ""; if (bean.getAddress1() != null) add1 = bean.getAddress1(); if (bean.getAddress2() != null) add2 = bean.getAddress2(); if (bean.getCity() != null) city = bean.getCity(); String Address = " " + add1; String Add2 = " " + add2; String Add3 = " " + city; String BackPriv1Path = PathInfo.PROJECT_HOME + "/images/BackPriv1.jpg"; String backPriv2Path = PathInfo.PROJECT_HOME + "/images/backPriv2.jpg"; String frontImgPath = PathInfo.PROJECT_HOME + "/images/pc.png"; float WIDTH = 205; float HEIGHT = 135; Image Back1 = Image.getInstance(BackPriv1Path); Back1.scaleAbsolute(WIDTH - 40, HEIGHT / 3); Image Back2 = Image.getInstance(backPriv2Path); Back2.scaleAbsolute(WIDTH, HEIGHT / 3); Image frontImg = Image.getInstance(frontImgPath); frontImg.scaleAbsolute(WIDTH, HEIGHT); if (bean.getSurname() != null && bean.getSurname().trim().length() > 0) name1 = " " + name + " " + name1 + bean.getSurname(); byte[] barcode = BarcodeManager.getBarcodeAsByte(bean.getBpartnerId().toString()); Image barcodeImg = Image.getInstance(barcode); barcodeImg.setRotation(1.57f); barcodeImg.scaleAbsolute(HEIGHT - 55f, WIDTH / 5); //document.add(barcodeImg); PdfPTable card = new PdfPTable(2); card.getDefaultCell().setBorderWidth(0.0f); PdfPCell c = null; card.setWidthPercentage(50.0f); PdfPTable t = new PdfPTable(1); PdfPTable nametable = new PdfPTable(1); c = new PdfPCell(Back1); c.setBorderWidth(0.0f); nametable.addCell(c); c = new PdfPCell(new Phrase(name1, smallFont)); c.setHorizontalAlignment(Element.ALIGN_CENTER); c.setVerticalAlignment(Element.ALIGN_CENTER); c.setBorderWidth(0.0f); nametable.addCell(c); c = new PdfPCell(new Phrase(Address, smallFont)); c.setHorizontalAlignment(Element.ALIGN_CENTER); c.setVerticalAlignment(Element.ALIGN_CENTER); c.setBorderWidth(0.0f); //c.setColspan(2); nametable.addCell(c); c = new PdfPCell(new Phrase(Add2, smallFont)); c.setHorizontalAlignment(Element.ALIGN_CENTER); c.setVerticalAlignment(Element.ALIGN_CENTER); c.setBorderWidth(0.0f); //c.setColspan(2); nametable.addCell(c); c = new PdfPCell(new Phrase(Add3, smallFont)); c.setHorizontalAlignment(Element.ALIGN_CENTER); c.setVerticalAlignment(Element.ALIGN_CENTER); c.setBorderWidth(0.0f); //c.setColspan(2); nametable.addCell(c); //nametable.getDefaultCell(); nametable.getDefaultCell().setBorderWidth(0.0f); nametable.setHorizontalAlignment(Element.ALIGN_CENTER); card.addCell(nametable); c = new PdfPCell(barcodeImg); c.setBorderWidth(0.0f); //c.setColspan(2); c.setHorizontalAlignment(Element.ALIGN_RIGHT); c.setVerticalAlignment(Element.ALIGN_MIDDLE); c.setPadding(5.0f); card.addCell(c); c = new PdfPCell(Back2); c.setBorderWidth(0.0f); c.setColspan(2); card.addCell(c); c = new PdfPCell(new Phrase(name1, smallFont)); c.setBorderWidth(0.0f); t.addCell(c); c = new PdfPCell(new Phrase(Address, smallFont)); c.setBorderWidth(0.0f); t.addCell(c); c = new PdfPCell(new Phrase(Add3, smallFont)); c.setBorderWidth(0.0f); t.addCell(c); PdfPTable card1 = new PdfPTable(1); card.getDefaultCell().setBorderWidth(0.0f); PdfPCell c1 = null; card.setWidthPercentage(50.0f); c1 = new PdfPCell(frontImg); c1.setBorderWidth(0.0f); card1.addCell(c1); main.addCell(card); main.addCell(card1); } } document.add(main); } // TODO handle the following exception neatly catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5: we close the document document.close(); return reportName; }