List of usage examples for com.itextpdf.io.font FontConstants HELVETICA
String HELVETICA
To view the source code for com.itextpdf.io.font FontConstants HELVETICA.
Click Source Link
From source file:com.tcay.slalom.UI.PDF.PDF_Results.java
License:Open Source License
public void doit(String title, ArrayList<RaceRun> runs, boolean breakOnClassChange) { Document doc = null;/*from w w w . j a v a2 s .c o m*/ Table table = null; try { File file = new File(DEST); file.getParentFile().mkdirs(); // new PDF_Results().manipulatePdf(DEST); PdfDocument pdfDoc = new PdfDocument(new PdfWriter(DEST)); //Document doc = new Document(pdfDoc); table = new Table(9); // # of columns // for (int i = 0; i < 16; i++) { // table.addCell("hi"); // } } catch (Exception e) { System.out.println(e); e.printStackTrace(); } String lastBoatClass = null; for (RaceRun r : runs) { float totalTime; if (breakOnClassChange) { if (lastBoatClass != null) { if (lastBoatClass.compareTo(r.getBoat().getBoatClass()) != 0) ; // log.info("---"); } lastBoatClass = r.getBoat().getBoatClass(); } totalTime = (float) r.getTotalPenalties(); totalTime += r.getElapsed(); } try { ArrayList<Result> sorted = Race.getInstance().getTempResults(); for (Result r : sorted) { if (true || breakOnClassChange) { //Fixme constant true if (lastBoatClass != null) { if (lastBoatClass.compareTo(r.getBoat().getBoatClass()) != 0) ; // output.newLine(); } if (lastBoatClass == null || lastBoatClass.compareTo(r.getBoat().getBoatClass()) != 0) { // output.write(r.getBoat().getBoatClass()); // output.newLine(); } lastBoatClass = r.getBoat().getBoatClass(); } String s1; // Cell cell23 = new Cell(1, 6).add("a Class ???multi 1,3 and 1,4"); // table.addCell(cell23); // table.startNewRow(); s1 = String.format("%1$3s", r.getBoat().getRacer().getBibNumber()); table.addCell(s1); String s = r.getBoat().getRacer().getShortName(); s1 = String.format("%1$-15s", s); table.addCell(s1); s1 = r.getRun1().getResultString(); table.addCell(s1); s1 = r.getRun1().getPenaltyString(); table.addCell(s1); s1 = r.getRun1().getTotalTimeString(); table.addCell(s1); if (r.getRun2() != null) { table.startNewRow(); table.addCell("."); table.addCell(".."); s1 = r.getRun2().getResultString(); table.addCell(s1); s1 = r.getRun2().getPenaltyString(); table.addCell(s1); s1 = r.getRun2().getTotalTimeString(); table.addCell(s1); } // else { // table.addCell("")//; //} table.startNewRow(); /// todo must integrate TH results before sort - DONE VERIFY 10/11/2013 // output.write(" best="); // s1 = r.getBestRun() != null ? r.getBestRun().formatTimeTotalOnly() : RaceRun.TIME_ONLY_FILL; // output.write(s1); // if (r.getBestRun().getPhotoCellRaceRun() != null) { /// todo must integrate TH results before sort // output.write(ResultsTable.TIMINGMODE_AUTOMATIC); // } // output.newLine(); } PdfFont f = PdfFontFactory.createFont(FontConstants.HELVETICA); Cell cell = new Cell(1, 3); cell.add(new Paragraph("Class K1 ... or whateever")).setFont(f).setFontSize(13) .setFontColor(DeviceGray.WHITE).setBackgroundColor(DeviceGray.BLACK); // .setTextAlignment(TextAlignment.CENTER); table.addHeaderCell(cell); /* for (int i = 0; i < 2; i++) { Cell[] headerFooter = new Cell[] { new Cell().setBackgroundColor(new DeviceGray(0.75f)).add("#"), new Cell().setBackgroundColor(new DeviceGray(0.75f)).add("Key"), new Cell().setBackgroundColor(new DeviceGray(0.75f)).add("Value") }; for (Cell hfCell : headerFooter) { if (i == 0) { table.addHeaderCell(hfCell); } else { table.addFooterCell(hfCell); } } } for (int counter = 1; counter < 20; counter++) { table.addCell(new Cell().setTextAlignment(TextAlignment.CENTER).add(String.valueOf(counter))); table.addCell(new Cell().setTextAlignment(TextAlignment.CENTER).add("key " + counter)); table.addCell(new Cell().setTextAlignment(TextAlignment.CENTER).add("value " + counter)); } */ doc.add(table); doc.close(); } catch (Exception e) { System.out.println(e); System.out.println(e.getStackTrace()); e.printStackTrace(); // log.write(e); } finally { try { // output.close(); } catch (Exception ex) { System.out.println(ex); System.out.println(ex.getStackTrace()); ex.printStackTrace(); } } }
From source file:modelo.dao.VariableHeaderEventHandler.java
@Override public void handleEvent(Event event) { PdfDocumentEvent documentEvent = (PdfDocumentEvent) event; try {//from w w w . ja v a2s . c om new PdfCanvas(documentEvent.getPage()).beginText() .setFontAndSize(PdfFontFactory.createFont(FontConstants.HELVETICA), 12).moveText(450, 806) .showText(header).endText().stroke(); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.nih.nci.App.java
protected void generatePdf(String dest, NCIDosePdfObject jObject) throws Exception { PdfWriter writer = new PdfWriter(dest, new WriterProperties().addXmpMetadata()); PdfDocument pdfDoc = new PdfDocument(writer); Document document = new Document(pdfDoc, PageSize.LETTER, false); pdfDoc.setTagged();// w ww .j a v a2s. co m pdfDoc.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); pdfDoc.getCatalog().setLang(new PdfString("en-US")); pdfDoc.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); PdfDocumentInfo info = pdfDoc.getDocumentInfo(); info.setTitle("Software Transfer Agreement"); Style headerStyle = new Style(); PdfFont headerFont = PdfFontFactory.createFont(FontConstants.HELVETICA); headerStyle.setFont(headerFont).setFontSize(10); HeaderEventHandler handler = new HeaderEventHandler(); pdfDoc.addEventHandler(PdfDocumentEvent.END_PAGE, handler); handler.setHeader("NCI Reference # ___________________"); Style titleStyle = new Style(); PdfFont titleFont = PdfFontFactory.createFont(FontConstants.TIMES_BOLD, true); titleStyle.setFont(titleFont).setFontSize(14); Style normalStyle = new Style(); PdfFont normalFont = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN, true); normalStyle.setFont(normalFont).setFontSize(12); Style italicStyle = new Style(); PdfFont italicFont = PdfFontFactory.createFont(FontConstants.TIMES_ITALIC, true); italicStyle.setFont(italicFont).setFontSize(12); InputStream istream = getClass().getResourceAsStream("/FreeSerif.ttf"); byte[] bytes = IOUtils.toByteArray(istream); PdfFont symbol = PdfFontFactory.createFont(bytes, PdfEncodings.IDENTITY_H, true); Text checkbox = new Text("\u2611");// checkbox.setFont(symbol); checkbox.setFontSize(12); Paragraph p = new Paragraph(); p.setMarginTop(20); p.setTextAlignment(TextAlignment.CENTER); Text text = new Text("SOFTWARE TRANSFER AGREEMENT").addStyle(titleStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(56f); text = new Text("Provider: National Cancer Institute (NCI)").addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(56f); text = new Text("Recipient Institution: ").addStyle(normalStyle); p.add(text); text = new Text(jObject.getInstitution()).addStyle(italicStyle).setUnderline(); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("WHEREAS, Provider has certain proprietary software and associated material described " + "below (hereinafter, collectively referred to as Software) "); text.addStyle(normalStyle); p.add(text).add(new Text("[Describe all items being " + "transferred such as; software, executable code, source code, documentation, data and all " + "other associated materials]").addStyle(italicStyle)); p.add(new Text(":").addStyle(normalStyle)); document.add(p); for (String str : jObject.getSoftwareText()) { p = new Paragraph(); p.setMarginLeft(56f); text = new Text(str); text.addStyle(normalStyle).setBold(); p.add(checkbox).add(text); document.add(p); } p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Provider agrees to transfer such Software to Recipient Investigator, to be used solely in " + "connection with the following research activity and for the following reasons (hereinafter " + "Project)"); text.addStyle(normalStyle); p.add(text).add(new Text("[Describe with specificity the scope of use of Software under this agreement]") .addStyle(italicStyle)); p.add(new Text(":").addStyle(normalStyle)); document.add(p); p = new Paragraph(); p.setMarginLeft(56f); text = new Text(jObject.getPurpose()); text.addStyle(italicStyle).setUnderline(); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("NOW, THEREFORE, in consideration of the premises and mutual covenants contained " + "herein, the Provider and Recipient agree as follows:"); text.addStyle(normalStyle); p.add(text); document.add(p); List mainList = new List(); mainList.setListSymbol(""); List numberedList = new List(ListNumberingType.DECIMAL); numberedList.setMarginLeft(56f); numberedList.addStyle(normalStyle); numberedList.add("SOFTWARE SHALL NOT BE USED FOR TREATING OR DIAGNOSING " + "HUMAN SUBJECTS."); numberedList.add("Recipient will not license or sell or use Software for commercial purposes or " + "applications. Recipient Investigator shall retain control over Software and further " + "will not transfer the Software to individuals not under Recipient Investigators " + "direct supervision without the advance written approval of Provider. Recipient " + "agrees to comply with all regulations applicable to the Project and the use of the " + "Software."); numberedList.add("Recipient agrees not to copy Software, in whole or in part, except as required for " + "use by Recipient Investigator for the conduct of the Project. Recipient shall not " + "modify, extend, decompile, make derivatives of or reverse engineer the Software " + "without written permission from Provider."); numberedList.add("Information deemed confidential under this Agreement (Confidential Information?) " + "shall be clearly marked CONFIDENTIAL.? Any information that is orally " + "disclosed must be reduced to writing and marked CONFIDENTIAL? by the " + "provider of the information within thirty (30) days of such disclosure. To the extent " + "permitted by applicable law, the Recipient agrees to employ all reasonable efforts to " + "safeguard Providers Confidential Information to ensure that no unauthorized " + "person shall have access thereto and that no unauthorized copy, publication, " + "disclosure or distribution, in whole or in part, in any form shall be made."); numberedList.add("In all oral presentations or written publications concerning the Project, Recipient " + "will acknowledge Providers contribution of Software unless requested otherwise. " + "Recipient may publish or otherwise publicly disclose the results of the Project, but " + "if Provider has given Confidential Information to Recipient, such public disclosure " + "may be made only after Provider has had 30 days to review the proposed disclosure, " + "except when a shortened time period under court order or the Freedom of " + "Information Act pertains."); numberedList.add("The obligations of Recipient under Paragraph 4 above shall not extend to any part " + "of the Confidential Information:"); ListItem item1 = new ListItem(); item1.add(numberedList); mainList.add(item1); List subList = new List(ListNumberingType.ENGLISH_LOWER); subList.addStyle(normalStyle); subList.setMarginLeft(84f); subList.add("that can be demonstrated to have been publicly known at the time of " + "disclosure; or"); subList.add("that can be demonstrated to have been properly in the Recipients " + "possession or that can be demonstrated to have been readily available to the " + "Recipient from another proper source prior to the disclosure; or"); subList.add("that becomes part of the public domain or publicly known by publication or " + "otherwise, not due to any unauthorized act by the Recipient or its " + "subsidiaries; or"); subList.add("that can be demonstrated as independently developed or acquired by the " + "Recipient without reference to or reliance upon such information; or"); subList.add("that is required to be disclosed by law, provided that the Recipient takes " + "reasonable and lawful actions to avoid and/or minimize such disclosure."); ListItem item2 = new ListItem(); item2.add(subList); mainList.add(item2); numberedList = new List(ListNumberingType.DECIMAL); numberedList.setMarginLeft(56f); numberedList.addStyle(normalStyle); numberedList.setItemStartIndex(7); numberedList.add("The Recipients obligations under Paragraphs 4 and 5 shall extend for a period of " + "three (3) years from the date of disclosure."); numberedList.add("Title in the Software shall remain with the Provider. It is understood that nothing " + "herein shall be deemed to constitute, by implication or otherwise, the grant to either " + "Party by the other of any license or other rights under any patent, patent application " + "or other intellectual property right or interest. Provider reserves the right to " + "distribute Software to others and to use it for Providers own purposes."); numberedList.add("When the Project is completed or this Agreement is terminated, whichever occurs " + "first, Recipient will destroy all copies of Software and Providers Confidential " + "Information unless directed otherwise by Provider in writing."); numberedList.add("This Agreement may be terminated by either Recipient or Provider by providing 30 " + "days advance notice."); numberedList.add("The Provider and Recipient each shall retain title to any patent or other intellectual " + "property of their respective employees developed or created in the course of the " + "Project defined in this Agreement. Neither Provider nor Recipient promise rights in " + "advance for inventions developed under this Agreement."); numberedList.add("No indemnification for any loss, claim, damage, or liability is intended or provided " + "by any party under this Agreement. Each party shall be liable for any loss, claim, " + "damage, or liability that said party incurs as a result of said partys activities under " + "this Agreement, except that the NIH, as an agency of the United States, assumes " + "liability only to the extent as provided under the United States Federal Tort Claims " + "Act (28 U.S.C. Chapter 171)."); numberedList.add("Software is supplied AS IS, without any accompanying services or improvements\n" + "from Provider. SOFTWARE IS SUPPLIED TO RECIPIENT WITH NO\n" + "WARRANTIES, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF\n" + "MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Provider\n" + "makes no representations that the use of Software will not infringe any patent or\n" + "proprietary rights of third parties."); ListItem item3 = new ListItem(); item3.add(numberedList); mainList.add(item3); document.add(mainList); p = new Paragraph(); p.setMarginTop(20); p.setTextAlignment(TextAlignment.CENTER); text = new Text("Signatures Begin on Next Page").addStyle(titleStyle).setFontSize(12); p.add(text); document.add(p); document.add(new AreaBreak(AreaBreakType.NEXT_PAGE)); p = new Paragraph(); p.setMarginTop(20f); p.setMarginLeft(28f); text = new Text("For Recipient:").addStyle(titleStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Authorized Official for Recipient:").addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginTop(10); p.setMarginLeft(28f); text = new Text("Name: _________________________________________ Title: _____________________\n") .addStyle(normalStyle); p.add(text); text = new Text("Signature: ______________________________________ Date: _____________________") .addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text("Read and Understood by Recipient Investigator:").addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); p.add(new Text("Name: ").addStyle(normalStyle)).add(new Text(jObject.getFirst()).addStyle(italicStyle)) .add(new Text(" ")).add(new Text(jObject.getLast()).addStyle(italicStyle)).add(new Tab()) .add(new Text("Title: ").addStyle(normalStyle)) .add(new Text(jObject.getTitle()).addStyle(italicStyle)).add(new Text("\n")); text = new Text("Signature: ____________________________________ Date: _____________________") .addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text("Recipients Mailing Address for Legal Notices:").addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text(jObject.getAddress()).addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); p.add(new Text("Email: ").addStyle(normalStyle)).add(new Text(jObject.getEmail()).addStyle(italicStyle)) .add(new Tab()).add(new Text("Phone: ").addStyle(normalStyle)) .add(new Text(jObject.getPhone()).addStyle(italicStyle)); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(20); text = new Text("For Provider:").addStyle(titleStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Authorized Official for Provider:").addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Name: _________________________________________ Title: _____________________\n") .addStyle(normalStyle); p.add(text); text = new Text("Signature: ______________________________________ Date: _____________________") .addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text("Read and Understood by Providers Investigator:").addStyle(italicStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); p.setMarginTop(10); text = new Text("Signature: ______________________________________ Date: _____________________\n" + "Choonsik Lee, PhD\n" + "Senior Investigator\n" + "Radiation Epidemiology Branch\n" + "Division of Cancer Epidemiology & Genetics, NCI, NIH").addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(28f); text = new Text("Providers Mailing Address for Legal Notices:").addStyle(normalStyle); p.add(text); document.add(p); p = new Paragraph(); p.setMarginLeft(56f); text = new Text( "National Institutes of Health\n" + "National Cancer Institute\n" + "Technology Transfer Center\n" + "9609 Medical Center Dr. Rm 1E530, MSC 9702 Bethesda, MD 20892-9702\n" + "Phone: 240-276-5530 Fax: 240-276-5504").addStyle(normalStyle); p.add(text); document.add(p); addPageNumbers(pdfDoc); document.close(); }
From source file:org.nih.nci.App.java
protected void addPageNumbers(PdfDocument pdfDocument) { int numPages = pdfDocument.getNumberOfPages(); for (int i = 1; i <= numPages; i++) { PdfPage page = pdfDocument.getPage(i); page.put(new PdfName("Tabs"), PdfName.S); try {//from w ww .j ava 2 s . c o m new PdfCanvas(page).beginText() .setFontAndSize(PdfFontFactory.createFont(FontConstants.HELVETICA), 10) .beginMarkedContent(PdfName.Artifact).moveText(255, 25) .showText("Page " + i + " of " + numPages).endText().stroke().endMarkedContent(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:org.zafritech.zidingorms.io.pdf.PdfServiceImpl.java
private static Map<String, Style> createPdfStyles(Document doc) throws IOException { Map<String, Style> styles = new HashMap<String, Style>(); PdfFont font = PdfFontFactory.createFont(FontConstants.HELVETICA); PdfFont fontItalic = PdfFontFactory.createFont(FontConstants.TIMES_ITALIC); // Normal Style Style normalStyle = new Style(); normalStyle.setFont(font).setFontSize(11); styles.put("Normal", normalStyle); // Title Style Style titleStyle = new Style(); titleStyle.setFont(font).setFontSize(16); titleStyle.setBold();/*from w w w .j a v a2s.com*/ titleStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); styles.put("Title", titleStyle); // Subtitle Style Style subTitleStyle = new Style(); subTitleStyle.setFont(font).setFontSize(14); subTitleStyle.setBold(); subTitleStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); styles.put("Subtitle", subTitleStyle); // Header1 Style Style header1Style = new Style(); header1Style.setFont(font).setFontSize(14); header1Style.setBold(); header1Style.setHorizontalAlignment(HorizontalAlignment.LEFT); styles.put("Header1", header1Style); // Header2 Style Style header2Style = new Style(); header2Style.setFont(font).setFontSize(13); header2Style.setBold(); header2Style.setHorizontalAlignment(HorizontalAlignment.LEFT); styles.put("Header2", header2Style); // Header3 Style Style header3Style = new Style(); header3Style.setFont(font).setFontSize(12); header3Style.setBold(); header3Style.setHorizontalAlignment(HorizontalAlignment.LEFT); styles.put("Header3", header3Style); // Header4 Style Style header4Style = new Style(); header4Style.setFont(font).setFontSize(11); header4Style.setBold(); header4Style.setHorizontalAlignment(HorizontalAlignment.LEFT); styles.put("Header4", header4Style); // Header5 Style Style header5Style = new Style(); header5Style.setFont(fontItalic).setFontSize(11); header5Style.setBold(); header5Style.setHorizontalAlignment(HorizontalAlignment.LEFT); styles.put("Header5", header5Style); return styles; }
From source file:wbs.jsf1.pdf.LottoReceiptBean0.java
public byte[] createPdfFrom(Lottoschein lottoschein) { try {//from w w w .j a v a 2 s .c o m zahlen = lottoschein; ByteArrayOutputStream pdfStream = new ByteArrayOutputStream(); PdfWriter writer = new PdfWriter(pdfStream); PdfDocument pdf = new PdfDocument(writer); PageSize pageSize = new PageSize(PageSize.A6); Document document = new Document(pdf, pageSize); document.setMargins(20, 20, 40, 20); PdfFont font = PdfFontFactory.createFont(FontConstants.HELVETICA); PdfFont bold = PdfFontFactory.createFont(FontConstants.HELVETICA_BOLD); // Header document.add(getHeaderTable()); // Lottozahlen auflisten document.add(getZiehungsDatenTable(font, bold)); // Losnummer document.add(getLosnummerTable(font, bold)); // Spieltage document.add(getSpieltageTable(font, bold)); // Laufzeit document.add(getLaufzeitTable(font, bold)); // Betrag document.add(getBetragTable(font, bold)); document.close(); LOG.log(Level.INFO, "PDF succesfully created."); return pdfStream.toByteArray(); } catch (IOException ex) { Logger.getLogger(LottoReceiptBean0.class.getName()).log(Level.SEVERE, "pdf creation problem", ex); } return null; }