List of usage examples for com.lowagie.text Font BOLD
int BOLD
To view the source code for com.lowagie.text Font BOLD.
Click Source Link
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_equipmentPdf(String filename, String roomname, String cabinetname, String uselect, String unumber, String rate) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/*from w w w. j av a 2 s . c om*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.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); // Paragraph title = new Paragraph(room + "", titleFont); // // title.setAlignment(Element.ALIGN_CENTER); // // title.setFont(titleFont); // document.add(title); List equipmentlist = (List) reportHash.get("equipmentlist"); // Paragraph context = new Paragraph(); // // // context.setAlignment(Element.ALIGN_LEFT); //// context.setFont(contextFont); // // // context.setSpacingBefore(5); // // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(6); PdfPCell cell = null; cell = new PdfPCell(new Phrase(roomname + cabinetname + "", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + roomname, titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + cabinetname, titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("U:" + uselect, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + unumber, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + rate, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(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 PdfPCell(new Phrase(1 + i + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getEquipmentdesc(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getOperation(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(equipmentReport.getContactname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(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_OperEquipmentPdf(String filename, String opername, String contactname, String contactphone) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/*from www . ja v a2 s. co m*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.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); // Paragraph title = new Paragraph(room + "", titleFont); // // title.setAlignment(Element.ALIGN_CENTER); // // title.setFont(titleFont); // document.add(title); List equipmentlist = (List) reportHash.get("equipmentlist"); // Paragraph context = new Paragraph(); // // // context.setAlignment(Element.ALIGN_LEFT); //// context.setFont(contextFont); // // // context.setSpacingBefore(5); // // // context.setFirstLineIndent(6); // document.add(context); // document.add(new Paragraph("\n")); PdfPTable aTable = new PdfPTable(7); PdfPCell cell = null; cell = new PdfPCell(new Phrase(opername + "", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + opername, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + contactname, titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(":" + contactphone, titleFont)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("U", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(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 PdfPCell(new Phrase(operCabinet.getRoomname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getCabinetname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getUseu(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getEquipmentname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getIpaddress(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase(operCabinet.getContactname(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(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.afunms.report.abstraction.ExcelReport1.java
public void createReport_cabinetWord(String filename, String room) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;//from w ww .j av a 2s . com 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 cabinetlist = (List) reportHash.get("cabinetlist"); 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(room + "", titleFont)); cell.setRowspan(2); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("U(%)", titleFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Cabinet cabinet = null; if (cabinetlist != null && cabinetlist.size() > 0) { for (int i = 0; i < cabinetlist.size(); i++) { cabinet = (Cabinet) cabinetlist.get(i); cell = new Cell(new Phrase(1 + i + "", contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getName(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getAllu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getUseu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getTempu(), contextFont)); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(cabinet.getRateu(), contextFont)); cell.setRowspan(2); 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_equipmentWord(String filename, String roomname, String cabinetname, String uselect, String unumber, String rate) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;//ww w. j ava2 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 ww w . ja va 2s .c o 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 a 2 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 ww . j a va 2 s . co m*/ 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.amphisoft.epub2pdf.content.TextFactory.java
License:Open Source License
public Paragraph newHeadline(int i) { if (i < 1) { i = 1;//from w w w . j a va 2 s . c o m } if (i > 6) { i = 6; } Font hFont = FontFactory.getFont(_defaultFont.getFamilyname(), FontFactory.defaultEncoding, BaseFont.EMBEDDED, baseFontSize * HMULTS[i - 1], Font.BOLD); Paragraph h = new Paragraph(); h.setAlignment(ITAlignment.CENTER.value); h.setFont(hFont); currentFont = hFont; h.setLeading(0F, getCurrentLeadingMultiplier()); h.setSpacingAfter(_defaultFont.getSize() * 0.33F); currentParagraph = h; return h; }
From source file:com.amphisoft.epub2pdf.content.TextFactory.java
License:Open Source License
void modifyFontInPlace(Font font, StyleSpecText styleSpec) { int style = font.getStyle(); if (styleSpec.isBold()) { style |= Font.BOLD; }//from w w w. j av a2 s.co m if (styleSpec.isItalic()) { style |= Font.ITALIC; } font.setStyle(style); }
From source file:com.amphisoft.epub2pdf.content.XhtmlHandler.java
License:Open Source License
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) { /*//from w w w .j a v a2 s. c om if("ol".equals(qName) || "ul".equals(qName) || "li".equals(qName)) { System.err.print(qName + " "); } */ currentSaxElemId = saxElemIdCounter; Map<String, String> attrMap = new HashMap<String, String>(); // parse attributes for (int ai = 0; ai < attributes.getLength(); ai++) { attrMap.put(attributes.getQName(ai), attributes.getValue(ai)); } String idAttr = attrMap.get("id"); if (idAttr == null) { idAttr = ""; } String className = attrMap.get("class"); if (className == null) { className = ""; } SaxElement sE = new SaxElement(qName, saxElemIdCounter++, className, idAttr, currentITextStyle); //printlnerr("startElement: " + sE.toString()); saxElementStack.push(sE); try { if (attrMap.get("class") != null) { String[] elemClasses = attrMap.get("class").split(" "); for (String eClass : elemClasses) { StyleSpecText classTextStyles = styleMap.getTextStyleSpecFor(qName, eClass); if (classTextStyles != null) { sE.applyTextStyles(classTextStyles); } } } if (attrMap.get("style") != null) { // TODO this needs more thought, and careful tracking of which tags are still open, etc. //String styleSource = attrMap.get("style"); //CssStyleMap styleTagStyles = cssParser.getStylesFromStyleTag(styleSource); // ... } if (sE.textStyles == null) { try { int stackSize = saxElementStack.size(); if (stackSize > 1) { SaxElement enclosingElement = saxElementStack.elementAt(stackSize - 2); StyleSpecText enclosingSST = enclosingElement.textStyles; if (enclosingSST != null) sE.applyTextStyles(enclosingSST); } } catch (Exception e) { } } StyleSpecText currentTextStyles = sE.textStyles; if (currentTextStyles != null) { if (currentTextStyles.isBold()) { currentITextStyle |= Font.BOLD; } if (currentTextStyles.isItalic()) { currentITextStyle |= Font.ITALIC; } } //System.err.println("PUSH -> " + saxElementStack); previousTag = currentTag; currentTag = qName; if (document.isOpen()) { if (XhtmlTags.NEWLINE.equals(qName)) { if (stack.size() > 0) { TextElementArray currentTEA = (TextElementArray) stack.peek(); currentTEA.add(Chunk.NEWLINE); } else if (specialParagraph != null) { specialParagraph.add(Chunk.NEWLINE); } } updateStack(); String xmlElementId = attrMap.get("id"); if (XhtmlTags.ANCHOR.equals(qName)) { //concession to nonconformists... if (xmlElementId == null) { xmlElementId = attrMap.get("name"); } Anchor anchor = textFactory.newAnchor(); String ref = attrMap.get(XhtmlTags.REFERENCE); if (ref != null) { int aNameStartIdx = ref.lastIndexOf("#") + 1; ref = ref.substring(aNameStartIdx); anchor.setReference(ref); } if (xmlElementId != null) { anchor.setName(xmlElementId); } pushToStack(anchor); } else { if (xmlElementId != null) { //flushStack(); Anchor dest = textFactory.newAnchor(); dest.setName(xmlElementId); pushToStack(dest); //flushStack(); } for (int i = 0; i < 6; i++) { if (XhtmlTags.H[i].equals(qName)) { flushStack(); freshParagraph = true; currentITextStyle |= Font.BOLD; specialParagraph = textFactory.newHeadline(i + 1); return; } } if ("blockquote".equals(qName)) { flushStack(); freshParagraph = true; Paragraph p = textFactory.newParagraph(); p.setIndentationLeft(50); p.setIndentationRight(20); p.setAlignment(defaultAlignment); pushToStack(p); } else if (XhtmlTags.PARAGRAPH.equals(qName)) { flushStack(); freshParagraph = true; Paragraph p = textFactory.newParagraph(); pushToStack(p); } else if (XhtmlTags.DIV.equals(qName)) { if (stack.size() > 0 && stack.peek().getChunks().size() > 0) { flushStack(); } if (stack.size() == 0) { Paragraph brandNewParagraph = textFactory.newParagraph(); pushToStack(brandNewParagraph); freshParagraph = true; } } else if (XhtmlTags.PRE.equals(qName)) { flushStack(); freshParagraph = true; Paragraph p = textFactory.newParagraphPre(); pushToStack(p); } else if (XhtmlTags.ORDEREDLIST.equals(qName)) { flushStack(); List oList = new List(List.ORDERED, 10); pushToStack(oList); } else if (XhtmlTags.UNORDEREDLIST.equals(qName)) { flushStack(); List uList = new List(List.UNORDERED, 10); pushToStack(uList); } else if (XhtmlTags.LISTITEM.equals(qName)) { freshParagraph = true; ListItem listItem = new ListItem(); pushToStack(listItem); } else if (XhtmlTags.IMAGE.equals(qName)) { handleImage(attributes); } else if (qName != null && qName.endsWith("image")) { handleSvgImage(attributes); } else if (XhtmlTags.LINK.equals(qName)) { // if it's a stylesheet, parse it & update current-style if ("stylesheet".equals(attrMap.get("rel")) && "text/css".equals(attrMap.get("type")) && attrMap.get("href") != null) { String cssHref = xhtmlDir.getAbsoluteFile().toURI().toString() + attrMap.get("href"); CssStyleMap stylesFromLink = cssParser.getStylesFromFileURI(cssHref); if (stylesFromLink != null) { styleMap.updateWith(stylesFromLink); } } } else if (XhtmlTags.STYLE.equals(qName)) { inStyleTag = true; } else if (XhtmlTags.EM.equals(qName) || "I".equals(qName.toUpperCase())) { currentITextStyle |= Font.ITALIC; } else if (XhtmlTags.STRONG.equals(currentTag) || "B".equals(qName.toUpperCase())) { currentITextStyle |= Font.BOLD; } } } else if (XhtmlTags.BODY.equals(qName)) { document.open(); freshParagraph = true; } } catch (Exception e) { e.printStackTrace(); } //printlnerr("leaving startElement " + localName + "; stack: " + stackStatus()); }