List of usage examples for com.lowagie.text Font NORMAL
int NORMAL
To view the source code for com.lowagie.text Font NORMAL.
Click Source Link
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_equipmentWord(String filename, String roomname, String cabinetname, String uselect, String unumber, String rate) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;//from ww w . jav a 2 s .co m return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // title.setFont(titleFont); List equipmentlist = (List) reportHash.get("equipmentlist"); Paragraph context = new Paragraph(); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // // context.setSpacingBefore(0); // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); Table aTable = new Table(6); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(4);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase(roomname + cabinetname + "", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + roomname, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + cabinetname, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U:" + uselect, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + unumber, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + rate, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); EquipmentReport equipmentReport = null; if (equipmentlist != null && equipmentlist.size() > 0) { for (int i = 0; i < equipmentlist.size(); i++) { equipmentReport = (EquipmentReport) equipmentlist.get(i); cell = new Cell(new Phrase(1 + i + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getEquipmentdesc(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getOperation(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getContactname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(equipmentReport.getContactphone(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_OperEquipmentWord(String filename, String opername, String contactname, String contactphone) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;//from w w w .j a v a2 s.co m return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // new File(filename) BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); // title.setFont(titleFont); List equipmentlist = (List) reportHash.get("equipmentlist"); Paragraph context = new Paragraph(); // context.setAlignment(Element.ALIGN_CENTER); // context.setFont(contextFont); // // context.setSpacingBefore(0); // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); Table aTable = new Table(7); // float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f }; // aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // // aTable.setBorderWidth(1); // // aTable.setBorderColor(new Color(0, 125, 255)); // // aTable.setPadding(2);// // aTable.setSpacing(4);// // aTable.setBorder(2);// Cell cell = null; cell = new Cell(new Phrase(opername + "", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + opername, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + contactname, titleFont)); cell.setColspan(2); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(":" + contactphone, titleFont)); cell.setColspan(3); this.setCellFormat(cell, false); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); OperCabinet operCabinet = null; if (equipmentlist != null && equipmentlist.size() > 0) { for (int i = 0; i < equipmentlist.size(); i++) { operCabinet = (OperCabinet) equipmentlist.get(i); cell = new Cell(new Phrase(operCabinet.getRoomname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getCabinetname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getUseu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getIpaddress(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getCabinetname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(operCabinet.getContactphone(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); } } document.add(aTable); document.close(); } catch (Exception e) { // TODO: handle exception } }
From source file:com.allinfinance.system.util.PdfUtil.java
License:Open Source License
public static void create(String mchtId, String selMchtId, String path, List<Object[]> list, LinkedHashMap<String, List<Object[]>> map, Set<String> set) throws Exception { BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); ////from w w w. j av a2 s .c o m Font font17 = new Font(bfChinese, 17, Font.BOLD); Font font8 = new Font(bfChinese, 8, Font.NORMAL); Font font9 = new Font(bfChinese, 9, Font.NORMAL); Font font9Bold = new Font(bfChinese, 9, Font.BOLD); Font font8Red = new Font(bfChinese, 8, Font.NORMAL); font8Red.setColor(Color.RED); Font font8Green = new Font(bfChinese, 8, Font.NORMAL); font8Green.setColor(Color.GREEN); logger.info("Starting build document..."); Document document = new Document(PageSize.A4, 36, 36, 36, 36); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path)); document.open(); LINECANVAS border = new LINECANVAS(); // float[] widths = { 0.1f, 0.35f, 0.35f, 0.1f, 0.1f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(100); table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); table.getDefaultCell().setFixedHeight(12); //CELL PdfPCell cellMchntId = new PdfPCell(new Paragraph(mchtId, font8)); cellMchntId.setBorder(PdfPCell.BOTTOM); cellMchntId.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cellMchntName = new PdfPCell(new Paragraph(InformationUtil.getMchtName(mchtId), font8)); cellMchntName.setBorder(PdfPCell.BOTTOM); cellMchntName.setHorizontalAlignment(Element.ALIGN_CENTER); String point = InformationUtil.getCurPaperPoint(selMchtId); PdfPCell cellPoint; cellPoint = new PdfPCell(new Paragraph(point, font8Red)); cellPoint.setBorder(PdfPCell.NO_BORDER); cellPoint.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cellLevel; String level = InformationUtil.getCurPaperLevel(selMchtId); if (Integer.valueOf(point) >= 60) { cellLevel = new PdfPCell(new Paragraph(level, font8Green)); } else { cellLevel = new PdfPCell(new Paragraph(level, font8Red)); } cellLevel.setBorder(PdfPCell.NO_BORDER); cellLevel.setHorizontalAlignment(Element.ALIGN_CENTER); // Image img = Image.getInstance( ServletActionContext.getServletContext().getResource("/ext/resources/images/Title_logo.gif")); img.scalePercent(70); float w = img.getScaledWidth(); float h = img.getScaledHeight(); writer.getDirectContent().addImage(img, w, 0, 0, h, 36, PageSize.A4.getHeight() - 36 - h); // PdfPCell cell = new PdfPCell(new Paragraph("?", font17)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setColspan(5); cell.setFixedHeight(h); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); cell = new PdfPCell(); cell.setFixedHeight(20); cell.setColspan(5); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); table.addCell(new Paragraph("?", font8)); table.addCell(cellMchntId); table.addCell(" "); table.addCell(new Paragraph(": ", font8)); table.addCell(cellPoint); table.addCell(new Paragraph("??", font8)); table.addCell(cellMchntName); table.addCell(" "); table.addCell(new Paragraph(": ", font8)); table.addCell(cellLevel); document.add(table); document.add(new Paragraph("\n\n")); //? PdfPTable t = new PdfPTable(1); Iterator<Object[]> it0 = list.iterator(); int i = 1; while (it0.hasNext()) { Object[] obj = it0.next(); PdfPCell c = new PdfPCell(); c.addElement(new Paragraph("Q" + String.valueOf(i++) + "" + obj[1].toString(), font9Bold)); List<Object[]> opts = map.get(obj[0].toString()); String opt = ""; Iterator<Object[]> it1 = opts.iterator(); while (it1.hasNext()) { Object[] o = it1.next(); if (set.contains(o[0])) { opt += "? "; opt += o[1].toString(); opt += " "; } else { opt += " "; opt += o[1].toString(); opt += " "; } } c.addElement(new Paragraph(opt.trim(), font9)); c.setBorder(PdfPCell.NO_BORDER); if (i - 1 != list.size()) { c.setCellEvent(border); } t.addCell(c); } PdfPTable oTable = new PdfPTable(1); oTable.setWidthPercentage(100); PdfPCell ce = new PdfPCell(t); ce.setBorderColor(Color.GRAY); oTable.addCell(ce); document.add(oTable); document.close(); logger.info("Finish build document..."); }
From source file:com.allinfinance.system.util.PdfUtil.java
License:Open Source License
public static void create(String path, List<Object[]> list, LinkedHashMap<String, List<Object[]>> map) throws Exception { BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); ////from w w w . j a v a2s . c om Font font17 = new Font(bfChinese, 17, Font.BOLD); Font font8 = new Font(bfChinese, 8, Font.NORMAL); Font font10 = new Font(bfChinese, 10, Font.NORMAL); Font font10Bold = new Font(bfChinese, 10, Font.BOLD); Font font8Red = new Font(bfChinese, 8, Font.NORMAL); font8Red.setColor(Color.RED); Font font8Green = new Font(bfChinese, 8, Font.NORMAL); font8Green.setColor(Color.GREEN); logger.info("Starting build document..."); Document document = new Document(PageSize.A4, 36, 36, 36, 36); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path)); document.open(); LINECANVAS border = new LINECANVAS(); // float[] widths = { 0.1f, 0.35f, 0.55f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(100); table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); table.getDefaultCell().setFixedHeight(12); //CELL PdfPCell cellMchntId = new PdfPCell(new Paragraph("XXXXXXXXXXXXXXX", font8)); cellMchntId.setBorder(PdfPCell.BOTTOM); cellMchntId.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cellMchntName = new PdfPCell(new Paragraph("?", font8)); cellMchntName.setBorder(PdfPCell.BOTTOM); cellMchntName.setHorizontalAlignment(Element.ALIGN_CENTER); // Image img = Image.getInstance( ServletActionContext.getServletContext().getResource("/ext/resources/images/Title_logo.gif")); img.scalePercent(70); float w = img.getScaledWidth(); float h = img.getScaledHeight(); writer.getDirectContent().addImage(img, w, 0, 0, h, 36, PageSize.A4.getHeight() - 36 - h); // PdfPCell cell = new PdfPCell(new Paragraph("?", font17)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setColspan(3); cell.setFixedHeight(h); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); cell = new PdfPCell(); cell.setFixedHeight(20); cell.setColspan(3); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); table.addCell(new Paragraph("?", font8)); table.addCell(cellMchntId); table.addCell(" "); table.addCell(new Paragraph("??", font8)); table.addCell(cellMchntName); table.addCell(" "); document.add(table); document.add(new Paragraph("\n\n")); //? PdfPTable t = new PdfPTable(1); Iterator<Object[]> it0 = list.iterator(); int i = 1; while (it0.hasNext()) { Object[] obj = it0.next(); PdfPCell c = new PdfPCell(); c.addElement(new Paragraph("Q" + String.valueOf(i++) + "" + obj[1].toString(), font10Bold)); List<Object[]> opts = map.get(obj[0].toString()); String opt = ""; Iterator<Object[]> it1 = opts.iterator(); while (it1.hasNext()) { Object[] o = it1.next(); opt += " "; opt += o[1].toString(); opt += " "; } c.addElement(new Paragraph(opt.trim(), font10)); c.setBorder(PdfPCell.NO_BORDER); if (i - 1 != list.size()) { c.setCellEvent(border); } t.addCell(c); } PdfPTable oTable = new PdfPTable(1); oTable.setWidthPercentage(100); PdfPCell ce = new PdfPCell(t); ce.setBorderColor(Color.GRAY); oTable.addCell(ce); document.add(oTable); document.close(); logger.info("Finish build document..."); }
From source file:com.aripd.clms.service.ContractServiceBean.java
@Override public void generatePdf(ContractEntity contract) { String baseFontUrl = "/fonts/Quivira.otf"; FontFactory.register(baseFontUrl);//from w w w . ja v a2 s . c om ByteArrayOutputStream output = new ByteArrayOutputStream(); try { BaseFont bf = BaseFont.createFont(baseFontUrl, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font font18n = new Font(bf, 18, Font.NORMAL); Font font12n = new Font(bf, 12, Font.NORMAL); Font font8n = new Font(bf, 8, Font.NORMAL); Font font8nbu = new Font(bf, 8, Font.BOLD | Font.UNDERLINE); Font font8ng = new Font(bf, 8, Font.NORMAL, Color.DARK_GRAY); Font font6n = new Font(bf, 6, Font.NORMAL); Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.getInstance(document, output); document.open(); addMetaData(document); addTitlePage(document, contract); Image imgBlue = Image.getInstance(1, 1, 3, 8, new byte[] { (byte) 0, (byte) 0, (byte) 255, }); imgBlue.scaleAbsolute(document.getPageSize().getWidth(), 10); imgBlue.setAbsolutePosition(0, document.getPageSize().getHeight() - imgBlue.getScaledHeight()); PdfImage stream = new PdfImage(imgBlue, "", null); stream.put(new PdfName("ITXT_SpecialId"), new PdfName("123456789")); PdfIndirectObject ref = writer.addToBody(stream); imgBlue.setDirectReference(ref.getIndirectReference()); document.add(imgBlue); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); PdfPCell cell = new PdfPCell(new Paragraph(contract.getName(), font18n)); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); cell.setPadding(5); table.addCell(cell); cell = new PdfPCell(new Paragraph("Version: " + contract.getVersion(), font8n)); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); cell.setPadding(5); table.addCell(cell); cell = new PdfPCell(new Paragraph("Review: " + contract.getReview(), font8n)); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); cell.setPadding(5); table.addCell(cell); cell = new PdfPCell(new Paragraph(contract.getRemark(), font12n)); cell.setBorder(Rectangle.NO_BORDER); cell.setColspan(2); cell.setPadding(5); table.addCell(cell); document.add(table); // Start a new page document.newPage(); HTMLWorker htmlWorker = new HTMLWorker(document); htmlWorker.parse(new StringReader(contract.getRemark())); // Start a new page document.newPage(); document.add(new Paragraph("Review Board", font18n)); document.add(new LineSeparator(0.5f, 100, null, 0, -5)); table = new PdfPTable(3); table.setWidthPercentage(100); cell = new PdfPCell(new Paragraph("Review Board", font18n)); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Paragraph("Version", font12n)); table.addCell(cell); cell = new PdfPCell(new Paragraph("Date", font12n)); table.addCell(cell); cell = new PdfPCell(new Paragraph("Review", font12n)); table.addCell(cell); for (HistoryContractEntity history : historyContractService.listing(contract)) { cell = new PdfPCell(new Paragraph(history.getVersion().toString(), font8n)); table.addCell(cell); cell = new PdfPCell(new Paragraph(history.getStartdate().toString(), font8n)); table.addCell(cell); cell = new PdfPCell(new Paragraph(history.getReview(), font8n)); table.addCell(cell); } document.add(table); document.close(); FacesContext context = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); response.reset(); response.addHeader("Content-Type", "application/force-download"); String filename = URLEncoder.encode(contract.getName() + ".pdf", "UTF-8"); // response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + filename); response.getOutputStream().write(output.toByteArray()); response.getOutputStream().flush(); context.responseComplete(); context.renderResponse(); } catch (BadPdfFormatException | IOException ex) { Logger.getLogger(ContractServiceBean.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(ContractServiceBean.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.aryjr.nheengatu.util.GraphicsState.java
License:Open Source License
public GraphicsState() { font = FontFactory.getFont(Style.DEFAULT_FONT_FAMILY, Style.DEFAULT_FONT_SIZE, Font.NORMAL, Style.DEFAULT_FONT_COLOR); align = Element.ALIGN_LEFT;// w w w . j a v a2 s. c o m valign = Element.ALIGN_MIDDLE; bgcolor = new Color(0, 0, 0); spacingBefore = 8f; spacingAfter = 8f; textIndent = 0f * GraphicsState.CM_UNIT; marginLeft = 0f * GraphicsState.CM_UNIT; listStyleType = null; }
From source file:com.centurylink.mdw.designer.pages.ExportHelper.java
License:Apache License
private void initialize(boolean isUseCase) { chapterFont = FontFactory.getFont(FontFactory.TIMES, isUseCase ? 16 : 20, Font.BOLD, new Color(0, 0, 0)); sectionFont = FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLD, new Color(0, 0, 0)); subSectionFont = FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, new Color(0, 0, 0)); normalFont = FontFactory.getFont(FontFactory.TIMES, 12, Font.NORMAL, new Color(0, 0, 0)); boldFont = FontFactory.getFont(FontFactory.TIMES, 12, Font.BOLD, new Color(0, 0, 0)); fixedWidthFont = FontFactory.getFont(FontFactory.COURIER, 11, Font.NORMAL, new Color(0, 0, 0)); excludedAttributes = new HashSet<String>(); excludedAttributes.add(WorkAttributeConstant.LOGICAL_ID); excludedAttributes.add(WorkAttributeConstant.REFERENCE_ID); excludedAttributes.add(WorkAttributeConstant.WORK_DISPLAY_INFO); excludedAttributes.add(WorkAttributeConstant.REFERENCES); excludedAttributes.add(WorkAttributeConstant.DOCUMENTATION); excludedAttributes.add(WorkAttributeConstant.SIMULATION_STUB_MODE); excludedAttributes.add(WorkAttributeConstant.SIMULATION_RESPONSE); excludedAttributes.add(WorkAttributeConstant.DESCRIPTION); excludedAttributes.add(WorkAttributeConstant.BAM_START_MSGDEF); excludedAttributes.add(WorkAttributeConstant.BAM_FINISH_MSGDEF); excludedAttributesForSpecificValues = new HashMap<String, String>(); excludedAttributesForSpecificValues.put("DoNotNotifyCaller", "false"); excludedAttributesForSpecificValues.put("DO_LOGGING", "True"); tabularAttributes = new HashMap<String, List<String>>(); tabularAttributes.put("Notices", Arrays.asList(new String[] { "Outcome", "Template", "Notifier Class(es)" })); tabularAttributes.put("Variables", Arrays.asList(new String[] { "Variable", "ReferredAs", "Display", "Seq.", "Index" })); tabularAttributes.put("WAIT_EVENT_NAMES", Arrays.asList(new String[] { "Event Name", "Completion Code", "Recurring" })); tabularAttributes.put("variables", Arrays.asList(new String[] { "=", "SubProcess Variable", "Binding Expression" })); tabularAttributes.put("processmap", Arrays.asList(new String[] { "=", "Logical Name", "Process Name", "Process Version" })); tabularAttributes.put("Bindings", Arrays.asList(new String[] { "=", "Variable", "LDAP Attribute" })); tabularAttributes.put("Parameters", Arrays.asList(new String[] { "=", "Input Variable", "Binding Expression" })); textboxAttributes = new HashMap<String, String>(); textboxAttributes.put("Rule", "Code"); textboxAttributes.put("Java", "Java"); textboxAttributes.put("PreScript", "Pre-Script"); textboxAttributes.put("PostScript", "Post-Script"); }
From source file:com.centurylink.mdw.designer.pages.ExportHelper.java
License:Apache License
private void printNodePdf(Node node, Chapter chapter) throws Exception { Section section;//w w w . j a va 2 s. c o m String id = node.getDisplayId(nodeIdType); if (id == null || id.length() == 0) id = node.getId().toString(); String tmp = "Activity " + id + ": \"" + node.getName().replace('\n', ' ') + "\n"; Paragraph sTitle = new Paragraph(tmp, sectionFont); section = chapter.addSection(sTitle, options.contains(SECTION_NUMBER) ? 2 : 0); String summary = node.getAttribute(WorkAttributeConstant.DESCRIPTION); if (summary != null && summary.length() > 0) { printBoldParagraphsPdf(section, summary); } if (options.contains(DOCUMENTATION)) { String detail = node.getAttribute(WorkAttributeConstant.DOCUMENTATION); if (detail != null && detail.length() > 0) { printHtmlParagraphsPdf(section, detail, options.contains(SECTION_NUMBER) ? 2 : 0); section.add(new Paragraph("\n", FontFactory.getFont(FontFactory.TIMES, 4, Font.NORMAL, new Color(0, 0, 0)))); } } if (options.contains(ATTRIBUTES) && !node.getAttributes().isEmpty()) { printAttributesPdf(section, node.getAttributes(), options.contains(SECTION_NUMBER) ? 2 : 0); } section.add(new Paragraph("\n", normalFont)); }
From source file:com.concursive.connect.web.modules.wiki.utils.WikiPDFUtils.java
License:Open Source License
public static boolean functionsToUse(Project project, Wiki wiki, File file, HashMap imageList) throws Exception { // remove this. Document document = new Document(); // Parse each line to see if paragraph, table, section heading, list // Parse within the line to see if bold, italic, links, code fragment, images // Define styles Font exampleFont = FontFactory.getFont(FontFactory.HELVETICA, 24, Font.NORMAL, new Color(255, 0, 0)); // Add title and paragraphs // TODO: Construct a title page... with logo Paragraph title = new Paragraph(wiki.getSubject(), exampleFont); //Chunk title = new Chunk(wiki.getSubject()); //title.setBackground(new Color(0xFF, 0xDE, 0xAD)); ////title.setUnderline(new Color(0xFF, 0x00, 0x00), 3.0f, 0.0f, -4.0f, 0.0f, PdfContentByte.LINE_CAP_ROUND); //title.setUnderline(0.2f, -2f); LOG.debug("document.add(title)"); document.add(title);//from w w w. j av a2 s . co m // Link from // a paragraph with a local goto //Paragraph p1 = new Paragraph("We will do something special with this paragraph. If you click on ", FontFactory.getFont(FontFactory.HELVETICA, 12)); //p1.add(new Chunk("this word", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255))).setLocalGoto("test")); //p1.add(" you will automatically jump to another location in this document."); // a paragraph with a local destination //Paragraph p3 = new Paragraph("This paragraph contains a "); //p3.add(new Chunk("local destination", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 255, 0))).setLocalDestination("test")); // Ext A Href //Paragraph paragraph = new Paragraph("Please visit my "); //Anchor anchor1 = new Anchor("website (external reference)", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255))); //anchor1.setReference("http://www.lowagie.com/iText/"); //anchor1.setName("top"); //paragraph.add(anchor1); //Image jpg = Image.getInstance("otsoe.jpg"); //document.add(jpg); return false; }
From source file:com.concursive.connect.web.modules.wiki.utils.WikiPDFUtils.java
License:Open Source License
private static boolean parseLine(WikiPDFContext context, String line, Paragraph main, Connection db, ArrayList<Integer> wikiListTodo, float cellWidth, PdfPCell cell) throws Exception { LOG.debug("PARSING LINE: " + line); // Context Objects Project project = context.getProject(); WikiExportBean exportBean = context.getExportBean(); HashMap<String, ImageInfo> imageList = context.getImageList(); String fileLibrary = context.getFileLibrary(); boolean needsCRLF = true; boolean bold = false; boolean italic = false; boolean bolditalic = false; StringBuffer subject = new StringBuffer(); StringBuffer data = new StringBuffer(); int linkL = 0; int linkR = 0; int attr = 0; int underlineAttr = 0; // parse characters for (int i = 0; i < line.length(); i++) { char c1 = line.charAt(i); String c = String.valueOf(c1); // False attr/links if (!"'".equals(c) && attr == 1) { data.append("'").append(c); attr = 0;/*from www . j a v a 2 s . com*/ continue; } if (!"_".equals(c) && underlineAttr == 1) { data.append("_").append(c); underlineAttr = 0; continue; } if (!"[".equals(c) && linkL == 1) { data.append("[").append(c); linkL = 0; continue; } if (!"]".equals(c) && linkR == 1) { data.append("]").append(c); linkR = 0; continue; } // Links if ("[".equals(c)) { ++linkL; continue; } if ("]".equals(c)) { ++linkR; if (linkL == 2 && linkR == 2) { LOG.debug("main.add(new Chunk(data.toString()))"); main.add(new Chunk(data.toString())); data.setLength(0); // Different type of links... String link = subject.toString().trim(); if (link.startsWith("Image:") || link.startsWith("image:")) { // @note From WikiImageLink.java String image = link.substring(6); String title = null; int frame = -1; int thumbnail = -1; int left = -1; int right = -1; int center = -1; int none = -1; int imageLink = -1; int alt = -1; if (image.indexOf("|") > 0) { // the image is first image = image.substring(0, image.indexOf("|")); // any directives are next frame = link.indexOf("|frame"); thumbnail = link.indexOf("|thumb"); left = link.indexOf("|left"); right = link.indexOf("|right"); center = link.indexOf("|center"); none = link.indexOf("|none"); imageLink = link.indexOf("|link="); alt = link.indexOf("|alt="); // the optional caption is last int last = link.lastIndexOf("|"); if (last > frame && last > thumbnail && last > left && last > right && last > center && last > none && last > imageLink && last > alt) { title = link.substring(last + 1); } } //A picture, including alternate text: //[[Image:Wiki.png|The logo for this Wiki]] //You can put the image in a frame with a caption: //[[Image:Wiki.png|frame|The logo for this Wiki]] // Access some image details int width = 0; int height = 0; ImageInfo imageInfo = imageList.get(image + (thumbnail > -1 ? "-TH" : "")); if (imageInfo != null) { width = imageInfo.getWidth(); height = imageInfo.getHeight(); } // Alt String altText = null; if (alt > -1) { int startIndex = alt + 4; int endIndex = link.indexOf("|", startIndex); if (endIndex == -1) { endIndex = link.length(); } altText = link.substring(startIndex, endIndex); } // Looks like the image needs a link (which is always last) String url = null; if (imageLink > -1) { // Get the entered link int startIndex = imageLink + 6; int endIndex = link.length(); String href = link.substring(startIndex, endIndex); // Treat as a wikiLink to validate and to create a proper url WikiLink wikiLink = new WikiLink(project.getId(), (altText != null ? href + " " + altText : href)); url = wikiLink.getUrl(""); if (!url.startsWith("http://") && !url.startsWith("https://")) { // @todo Use a local link // @todo Use an external link } } // Determine if local or external image if ((image.startsWith("http://") || image.startsWith("https://"))) { // retrieve external image String imageUrl = null; try { URL imageURL = new URL(image); imageUrl = image; } catch (Exception e) { } } else { // local image try { // @todo image alignment and links Image thisImage = Image.getInstance( getImageFilename(db, fileLibrary, project, image, (thumbnail > -1))); LOG.debug("Drawing image for area: " + cellWidth); if (cellWidth > 0f) { LOG.debug(" Image is embedded in cell"); // Guess the size of the cell float cellPixels = (500f * (cellWidth / 100f)); if (cellPixels > 0f && (float) width > cellPixels) { // Shrink image to fit the cell LOG.debug(" Scaling to fit"); thisImage.scaleToFit(cellPixels, 500f); } else { // Align image to left instead of scaling it to fit thisImage.setAlignment(Image.LEFT); } LOG.debug("cell.addElement(thisImage)"); cell.addElement(thisImage); } else { LOG.debug(" Image is inline"); if (width > 500) { LOG.debug(" Scaling to fit"); thisImage.scaleToFit(500f, 500f); } LOG.debug("main.add(thisImage)"); main.add(thisImage); } // thisImage.setAlignment(); // thisImage.Alignment = Image.TEXTWRAP | Image.ALIGN_RIGHT; // main.add(thisImage); } catch (FileNotFoundException fnfe) { LOG.warn("WikiPDFUtils-> Image was not found in the FileLibrary (" + getImageFilename(db, fileLibrary, project, image, (thumbnail > -1)) + ")... will continue."); } } /* if (frame > -1 || thumbnail > -1) { sb.append("</div>"); sb.append("<div id=\"caption\" style=\"margin-bottom: 5px; margin-left: 5px; margin-right: 5px; text-align: left;\">"); } if (thumbnail > -1) { sb.append("<div style=\"float:right\"><a target=\"_blank\" href=\"ProjectManagementWiki.do?command=Img&pid=" + wiki.getProjectId() + "&subject=" + StringUtils.replace(StringUtils.jsEscape(image), "%20", "+") + "\"><img src=\"images/magnify-clip.png\" width=\"15\" height=\"11\" alt=\"Enlarge\" border=\"0\" /></a></div>"); } if (frame > -1 || thumbnail > -1) { if (title != null) { sb.append(StringUtils.toHtml(title)); } sb.append( " </div>\n" + "</div>"); } */ /* if (none > -1) { sb.append("<br clear=\"all\">"); } */ if (i + 1 == line.length() && (right > -1 || left > -1) || none > -1) { needsCRLF = false; } } else { // This is most likely a Wiki link String title = subject.toString().trim(); if (link.indexOf("|") > 0) { link = link.substring(0, link.indexOf("|")).trim(); title = title.substring(title.indexOf("|") + 1); } if (link.indexOf("http://") > -1 || link.indexOf("https://") > -1) { String label = link; if (link.indexOf(" ") > 0) { label = link.substring(link.indexOf(" ") + 1); link = link.substring(0, link.indexOf(" ")); } Anchor anchor1 = new Anchor(label, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255))); anchor1.setReference(link); anchor1.setName("top"); main.add(anchor1); } else { // Place a wiki link if (exportBean.getFollowLinks()) { // See if target link exists before creating a link to it int linkedWikiId = -1; if (StringUtils.hasText(title) && !title.startsWith("|")) { Wiki subwiki = WikiList.queryBySubject(db, title, project.getId()); if (subwiki.getId() > -1) { linkedWikiId = subwiki.getId(); } } // Display the linked item if (linkedWikiId > -1) { // Display as an anchor Anchor linkToWiki = new Anchor(title, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255))); linkToWiki.setReference("#" + title.toLowerCase()); LOG.debug("Link to: #" + title.toLowerCase()); main.add(linkToWiki); LOG.debug(" main.add(linkToWiki)"); // main.add(new Chunk(title, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255))).setLocalGoto(link)); // Add this wiki to the to do list... if (!wikiListTodo.contains(linkedWikiId)) { wikiListTodo.add(linkedWikiId); } } else { // Display without the link main.add(new Chunk(title, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255)))); } } else { // Not following links, so display... perhaps as an external link someday main.add(new Chunk(title, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255)))); } } } subject.setLength(0); linkL = 0; linkR = 0; } continue; } if (!"[".equals(c) && linkL == 2 && !"]".equals(c)) { subject.append(c); continue; } // Attribute properties if ("'".equals(c)) { ++attr; continue; } if (!"'".equals(c) && attr > 1) { if (attr == 2) { if (!italic) { main.add(new Chunk(data.toString())); data.setLength(0); data.append(c); italic = true; } else { data.append(c); main.add(new Chunk(data.toString(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC, new Color(0, 0, 0)))); data.setLength(0); italic = false; } attr = 0; continue; } if (attr == 3) { if (!bold) { main.add(new Chunk(data.toString())); data.setLength(0); data.append(c); bold = true; } else { data.append(c); main.add(new Chunk(data.toString(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); data.setLength(0); bold = false; } attr = 0; continue; } if (attr == 5) { if (!bolditalic) { main.add(new Chunk(data.toString())); data.setLength(0); data.append(c); bolditalic = true; } else { data.append(c); main.add(new Chunk(data.toString(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLDITALIC, new Color(0, 0, 0)))); data.setLength(0); bolditalic = false; } attr = 0; continue; } } data.append(c); } for (int x = 0; x < linkR; x++) { data.append("]"); } for (int x = 0; x < linkL; x++) { data.append("["); } if (attr == 1) { data.append("'"); } if (italic) { main.add(new Chunk(data.toString(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC, new Color(0, 0, 0)))); } else if (bold) { main.add(new Chunk(data.toString(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); } else if (bolditalic) { main.add(new Chunk(data.toString(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLDITALIC, new Color(0, 0, 0)))); } else { main.add(new Chunk(data.toString())); } data.setLength(0); return needsCRLF; }