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:mesquite.lib.MesquitePDFFile.java
License:Open Source License
/** @arg s String holds the text that the pdf file will contain @arg font java.awt.Font the font is specified this way for compatibility with the similar method in MesquitePrintJob *//*from w w w . ja va2 s . com*/ public void printText(String s, java.awt.Font font) { final String exceptionMessage = "Error, an exception occurred while creating the pdf text document: "; if (s == null || font == null) return; //do the translation from logical to physical font here //currently, the only font this method ever gets called with is "Monospaced",PLAIN,10. So the //translation effort here will be minimal int desiredFontFamily; // "Monospaced" isn't defined in com.lowagie.text.Font if (font.getFamily().equals("Monospaced")) desiredFontFamily = com.lowagie.text.Font.COURIER; else desiredFontFamily = com.lowagie.text.Font.TIMES_ROMAN; com.lowagie.text.Font textFont; switch (font.getStyle()) { case java.awt.Font.BOLD: { textFont = new com.lowagie.text.Font(desiredFontFamily, font.getSize(), com.lowagie.text.Font.BOLD); break; } case java.awt.Font.ITALIC: { textFont = new com.lowagie.text.Font(desiredFontFamily, font.getSize(), com.lowagie.text.Font.ITALIC); break; } case java.awt.Font.PLAIN: { textFont = new com.lowagie.text.Font(desiredFontFamily, font.getSize(), com.lowagie.text.Font.NORMAL); break; } default: { textFont = new com.lowagie.text.Font(desiredFontFamily, font.getSize(), com.lowagie.text.Font.BOLDITALIC); } } document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(pdfPathString)); addMetaData(document); document.open(); document.add(new Paragraph(s, textFont)); } catch (DocumentException de) { MesquiteTrunk.mesquiteTrunk.alert(exceptionMessage + de.getMessage()); } catch (IOException ioe) { MesquiteTrunk.mesquiteTrunk.alert(exceptionMessage + ioe.getMessage()); } this.end(); }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private FontSelector createBodyFontSelector() { return createFontSelector(FontFactory.HELVETICA, bodyFontSize, Font.NORMAL, Color.BLACK); }
From source file:net.bull.javamelody.internal.web.pdf.PdfCoreReport.java
License:Apache License
private void writeGraphs(Collection<JRobin> jrobins, Map<String, byte[]> mySmallGraphs) throws IOException, DocumentException { if (collector.isStopped()) { // pas de graphs, ils seraient en erreur sans timer // mais un message d'avertissement la place final String message = getString("collect_server_misusage"); final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont()); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); addToDocument(jrobinParagraph);/*from w w w. j a v a2s . com*/ return; } if (collector.isStorageUsedByMultipleInstances()) { final String message = getString("storage_used_by_multiple_instances") + "\n\n"; final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont()); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); addToDocument(jrobinParagraph); } final Paragraph jrobinParagraph = new Paragraph("", FontFactory.getFont(FontFactory.HELVETICA, 9f, Font.NORMAL)); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); jrobinParagraph.add(new Phrase("\n\n\n\n")); final Collection<byte[]> graphs; if (mySmallGraphs != null) { // si les graphiques ont t prinitialiss (en Swing) alors on les utilise graphs = mySmallGraphs.values(); } else { if (jrobins.isEmpty()) { return; } graphs = new ArrayList<byte[]>(jrobins.size()); for (final JRobin jrobin : jrobins) { graphs.add(jrobin.graph(range, SMALL_GRAPH_WIDTH, SMALL_GRAPH_HEIGHT)); } } int i = 0; for (final byte[] graph : graphs) { if (i % 3 == 0 && i != 0) { // un retour aprs httpSessions et avant activeThreads pour l'alignement jrobinParagraph.add(new Phrase("\n\n\n\n\n")); } final Image image = Image.getInstance(graph); image.scalePercent(50); jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0))); jrobinParagraph.add(new Phrase(" ")); i++; } jrobinParagraph.add(new Phrase("\n")); addToDocument(jrobinParagraph); }
From source file:net.bull.javamelody.PdfCoreReport.java
License:Apache License
private void writeGraphs(Collection<JRobin> jrobins, Map<String, byte[]> mySmallGraphs) throws IOException, DocumentException { if (collector.isStopped()) { // pas de graphs, ils seraient en erreur sans timer // mais un message d'avertissement la place final String message = getString("collect_server_misusage"); final Paragraph jrobinParagraph = new Paragraph(message, PdfFonts.BOLD.getFont()); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); addToDocument(jrobinParagraph);//from w w w .jav a 2 s . c o m return; } final Paragraph jrobinParagraph = new Paragraph("", FontFactory.getFont(FontFactory.HELVETICA, 9f, Font.NORMAL)); jrobinParagraph.setAlignment(Element.ALIGN_CENTER); jrobinParagraph.add(new Phrase("\n\n\n\n")); int i = 0; if (mySmallGraphs != null) { // si les graphiques ont t prinitialiss (en Swing) alors on les utilise for (final byte[] imageData : mySmallGraphs.values()) { if (i % 3 == 0 && i != 0) { // un retour aprs httpSessions et avant activeThreads pour l'alignement jrobinParagraph.add(new Phrase("\n\n\n\n\n")); } final Image image = Image.getInstance(imageData); image.scalePercent(50); jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0))); jrobinParagraph.add(new Phrase(" ")); i++; } } else { if (jrobins.isEmpty()) { return; } for (final JRobin jrobin : jrobins) { if (i % 3 == 0 && i != 0) { // un retour aprs httpSessions et avant activeThreads pour l'alignement jrobinParagraph.add(new Phrase("\n\n\n\n\n")); } final Image image = Image.getInstance(jrobin.graph(range, SMALL_GRAPH_WIDTH, SMALL_GRAPH_HEIGHT)); image.scalePercent(50); jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0))); jrobinParagraph.add(new Phrase(" ")); i++; } } jrobinParagraph.add(new Phrase("\n")); addToDocument(jrobinParagraph); }
From source file:net.bull.javamelody.swing.print.MPdfWriter.java
License:Apache License
/** * Effectue le rendu de la liste.//ww w .ja va 2s . c o m * * @param table * MBasicTable * @param datatable * Table * @throws BadElementException * e */ protected void renderList(final MBasicTable table, final Table datatable) throws BadElementException { final int columnCount = table.getColumnCount(); final int rowCount = table.getRowCount(); // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // datatable.setDefaultCellGrayFill(0); Object value; String text; int horizontalAlignment; for (int k = 0; k < rowCount; k++) { for (int i = 0; i < columnCount; i++) { value = getValueAt(table, k, i); if (value instanceof Number || value instanceof Date) { horizontalAlignment = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignment = Element.ALIGN_CENTER; } else { horizontalAlignment = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignment); text = getTextAt(table, k, i); datatable.addCell(new Phrase(8, text != null ? text : "", font)); } } }
From source file:net.bull.javamelody.swing.print.MRtfWriter.java
License:Apache License
/** * We create a writer that listens to the document and directs a RTF-stream to out * * @param table// ww w. ja va2 s. c o m * MBasicTable * @param document * Document * @param out * OutputStream * @return DocWriter */ @Override protected DocWriter createWriter(final MBasicTable table, final Document document, final OutputStream out) { final RtfWriter2 writer = RtfWriter2.getInstance(document, out); // title final String title = buildTitle(table); if (title != null) { final HeaderFooter header = new RtfHeaderFooter(new Paragraph(title)); header.setAlignment(Element.ALIGN_LEFT); header.setBorder(Rectangle.NO_BORDER); document.setHeader(header); document.addTitle(title); } // advanced page numbers : x/y final Paragraph footerParagraph = new Paragraph(); final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL); footerParagraph.add(new RtfPageNumber(font)); footerParagraph.add(new Phrase(" / ", font)); footerParagraph.add(new RtfTotalPageNumber(font)); footerParagraph.setAlignment(Element.ALIGN_CENTER); final HeaderFooter footer = new RtfHeaderFooter(footerParagraph); footer.setBorder(Rectangle.TOP); document.setFooter(footer); return writer; }
From source file:net.nosleep.superanalyzer.Share.java
License:Open Source License
public static void saveAnalysisPdf(JFrame window, Analysis analysis, JProgressBar progressBar) { File pdfFile = askForFile(window, "pdf"); if (pdfFile == null) return;/* ww w .j av a 2 s .c o m*/ Misc.printMemoryInfo("pdfstart"); DateFormat dateFormat = new SimpleDateFormat().getDateInstance(DateFormat.SHORT); String infoString = Misc.getString("CREATED_ON") + " " + dateFormat.format(Calendar.getInstance().getTime()); int viewCount = 15; int viewsDone = 0; progressBar.setMinimum(0); progressBar.setMaximum(viewCount); Dimension d = new Dimension(500, 400); try { String tmpPath = System.getProperty("java.io.tmpdir") + "/image.png"; // create the pdf document object Document document = new Document(); // create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.getInstance(document, new FileOutputStream(pdfFile)); // we open the document document.open(); Font titleFont = FontFactory.getFont(FontFactory.HELVETICA, 18, Font.NORMAL, new Color(0x00, 0x00, 0x00)); Paragraph p = new Paragraph(Misc.getString("MY_MUSIC_COLLECTION"), titleFont); p.setSpacingAfter(4); document.add(p); Font subtitleFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, new Color(0x88, 0x88, 0x88)); p = new Paragraph("The Super Analyzer by Nosleep Software", subtitleFont); p.setSpacingAfter(-2); document.add(p); p = new Paragraph(infoString, subtitleFont); p.setSpacingAfter(30); document.add(p); PdfPTable table = new PdfPTable(2); table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); table.setTotalWidth(500f); table.setLockedWidth(true); Font statNameFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, new Color(0x66, 0x66, 0x66)); Font statValueFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, new Color(0x00, 0x00, 0x00)); Vector<StringTriple> statPairs = SummaryView.createStatPairs(analysis); Paragraph statParagraph = new Paragraph(); Font summaryTitleFont = FontFactory.getFont(FontFactory.HELVETICA, 11, Font.BOLD, new Color(0x00, 0x00, 0x00)); Paragraph titleParagraph = new Paragraph(Misc.getString("SUMMARY"), summaryTitleFont); statParagraph.add(titleParagraph); Paragraph spaceParagraph = new Paragraph("", statNameFont); statParagraph.add(spaceParagraph); for (int i = 0; i < statPairs.size(); i++) { Paragraph statLine = new Paragraph(); StringTriple triple = statPairs.elementAt(i); Phrase namePhrase = new Phrase(triple.Name + ": ", statNameFont); Phrase valuePhrase = new Phrase(triple.Value, statValueFont); statLine.add(namePhrase); statLine.add(valuePhrase); statParagraph.add(statLine); } table.addCell(statParagraph); viewsDone++; progressBar.setValue(viewsDone); GenreView genreView = new GenreView(analysis); genreView.saveImage(new File(tmpPath), d); genreView = null; Image img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); LikesView likesView = new LikesView(analysis); likesView.saveImage(new File(tmpPath), d); likesView = null; img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); YearView yearView = new YearView(analysis); yearView.saveImage(new File(tmpPath), d); yearView = null; img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); RatingView ratingView = new RatingView(analysis); ratingView.saveImage(new File(tmpPath), d); ratingView = null; img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); TimeView timeView = new TimeView(analysis); timeView.saveImage(new File(tmpPath), d); timeView = null; img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); QualityView qualityView = new QualityView(analysis); qualityView.saveImage(new File(tmpPath), d); qualityView = null; img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); PlayCountView playCountView = new PlayCountView(analysis); playCountView.saveImage(new File(tmpPath), d); playCountView = null; img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); MostPlayedAAView mostPlayedAAView = new MostPlayedAAView(analysis); mostPlayedAAView.saveImage(new File(tmpPath), d); img = Image.getInstance(tmpPath); table.addCell(img); mostPlayedAAView.saveImageExtra(new File(tmpPath), d); img = Image.getInstance(tmpPath); table.addCell(img); mostPlayedAAView = null; viewsDone++; progressBar.setValue(viewsDone); MostPlayedDGView mostPlayedDGView = new MostPlayedDGView(analysis); mostPlayedDGView.saveImage(new File(tmpPath), d); img = Image.getInstance(tmpPath); table.addCell(img); mostPlayedDGView.saveImageExtra(new File(tmpPath), d); img = Image.getInstance(tmpPath); table.addCell(img); mostPlayedDGView = null; viewsDone++; progressBar.setValue(viewsDone); EncodingKindView encodingKindView = new EncodingKindView(analysis); encodingKindView.saveImage(new File(tmpPath), d); encodingKindView = null; img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); GrowthView growthView = new GrowthView(analysis); growthView.saveImage(new File(tmpPath), d); growthView = null; img = Image.getInstance(tmpPath); table.addCell(img); viewsDone++; progressBar.setValue(viewsDone); WordView wordView = new WordView(analysis); wordView.saveImage(new File(tmpPath), d); wordView = null; img = Image.getInstance(tmpPath); table.addCell(img); table.addCell(""); viewsDone++; progressBar.setValue(viewsDone); Misc.printMemoryInfo("pdfend"); document.add(table); // step 5: we close the document document.close(); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } }
From source file:net.nosleep.superanalyzer.Share.java
License:Open Source License
public static void saveListOfAlbumsAsPdf(JFrame window, Analysis analysis, JProgressBar progressBar) { File file = askForFile(window, "pdf"); if (file == null) return;//from w ww .j a v a2 s . c o m Hashtable albums = analysis.getHash(Analysis.KIND_ALBUM); DecimalFormat timeFormat = new DecimalFormat("0.0"); StringPair list[] = new StringPair[albums.size()]; Enumeration keys = albums.keys(); Integer index = 0; String regex = Album.SeparatorRegEx; while (keys.hasMoreElements()) { String albumartist = (String) keys.nextElement(); String[] parts = albumartist.split(regex); StringPair pair = new StringPair(parts[1], parts[0]); list[index] = pair; index++; } Arrays.sort(list, new StringPairComparator()); int done = 0; progressBar.setMinimum(0); progressBar.setMaximum(list.length); String infoString = NumberFormat.getInstance().format(list.length) + " "; if (list.length == 1) infoString += Misc.getString("ALBUM") + ", "; else infoString += Misc.getString("ALBUMS") + ", "; DateFormat dateFormat = new SimpleDateFormat().getDateInstance(DateFormat.SHORT); infoString += "created on " + dateFormat.format(Calendar.getInstance().getTime()); try { String tmpPath = System.getProperty("java.io.tmpdir") + "/image.png"; // create the pdf document object Document document = new Document(); // create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter.getInstance(document, new FileOutputStream(file)); // we open the document document.open(); Font titleFont = FontFactory.getFont(FontFactory.HELVETICA, 18, Font.NORMAL, new Color(0x00, 0x00, 0x00)); Paragraph p = new Paragraph(Misc.getString("MY_ALBUMS"), titleFont); p.setSpacingAfter(4); document.add(p); Font subtitleFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, new Color(0x88, 0x88, 0x88)); p = new Paragraph("The Super Analyzer by Nosleep Software", subtitleFont); p.setSpacingAfter(-2); document.add(p); p = new Paragraph(infoString, subtitleFont); p.setSpacingAfter(30); document.add(p); FontSelector albumSelector = new FontSelector(); Color albumColor = new Color(0x55, 0x55, 0x55); albumSelector.addFont(FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, albumColor)); Font albumAsianFont = FontFactory.getFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED); albumAsianFont.setSize(8); albumAsianFont.setColor(albumColor); albumSelector.addFont(albumAsianFont); FontSelector artistSelector = new FontSelector(); Color artistColor = new Color(0x77, 0x77, 0x77); artistSelector.addFont(FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, artistColor)); Font artistAsianFont = FontFactory.getFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED); artistAsianFont.setSize(8); artistAsianFont.setColor(artistColor); artistSelector.addFont(artistAsianFont); for (index = 0; index < list.length; index++) { p = new Paragraph(); p.setLeading(9); // separate the string into the album and artist parts Phrase phrase = albumSelector.process(list[index].Value); p.add(phrase); phrase = artistSelector.process(" " + Misc.getString("BY") + " " + list[index].Name); p.add(phrase); document.add(p); done++; progressBar.setValue(done); } // step 5: we close the document document.close(); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } }
From source file:open.dolphin.client.AuditController.java
License:Open Source License
private void makePDF() { //- ?/* w w w . j a v a 2 s . c o m*/ Document doc = new Document(PageSize.A4, 20.0F, 20.0F, 40.0F, 40.0F); try { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String fileName = "_" + sdf.format(new java.util.Date()) + ".pdf"; //()?? FileOutputStream fos = new FileOutputStream(outputDir.getText() + fileName); PdfWriter pdfwriter = PdfWriter.getInstance(doc, fos); Font font_header = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 15.0F, 1); Font font_g11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F); Font font_g10 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 10.0F); //- ? Font font_m8 = new Font(BaseFont.createFont("HeiseiMin-W3", "UniJIS-UCS2-HW-H", false), 8.0F); Font font_underline_11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F, 4); Font font_red_11 = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 11.0F); font_red_11.setColor(new Color(255, 0, 0)); Font font_empty = new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 9.0F); font_empty.setColor(new Color(255, 255, 255)); Paragraph para_NF = new Paragraph(5, "\r\n", new Font(BaseFont.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H", false), 13, Font.NORMAL)); para_NF.setAlignment(Element.ALIGN_CENTER); // ?? String author = Project.getProjectStub().getUserModel().getCommonName(); doc.addAuthor(author); doc.addSubject(""); HeaderFooter header = new HeaderFooter(new Phrase("", font_header), false); header.setAlignment(1); doc.setHeader(header); HeaderFooter footer = new HeaderFooter(new Phrase("--"), new Phrase("--")); footer.setAlignment(1); footer.setBorder(0); doc.setFooter(footer); doc.open(); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy''MM''dd'' HH''mm''"); String today = sdf1.format(new java.util.Date()); Paragraph para_0 = new Paragraph("?" + today, font_g11); para_0.setAlignment(2); doc.add(para_0); Paragraph para_1 = new Paragraph("?" + author, font_g11); para_1.setAlignment(2); doc.add(para_1); doc.add(new Paragraph("")); // doc.add(para_NF); doc.add(para_NF); for (int cnt = 0; cnt < outputList.size(); cnt++) { InnerBean bean = outputList.get(cnt); Person person = bean.getPerson(); Paragraph para_2 = new Paragraph("ID" + person.idProperty().get(), font_underline_11); para_2.setAlignment(0); doc.add(para_2); Paragraph para_3 = new Paragraph("???" + person.nameProperty().get(), font_underline_11); para_3.setAlignment(0); doc.add(para_3); Paragraph para_4 = new Paragraph("" + person.nameKanaProperty().get(), font_underline_11); para_4.setAlignment(0); doc.add(para_4); Paragraph para_5 = new Paragraph("" + person.sexProperty().get(), font_underline_11); para_5.setAlignment(0); doc.add(para_5); Paragraph para_6 = new Paragraph("" + person.birthdayProperty().get(), font_underline_11); para_6.setAlignment(0); doc.add(para_6); Table karteHistoryTable = new Table(5); karteHistoryTable.setWidth(100.0F); int[] uriage_table_width = { 25, 20, 30, 20, 25 }; karteHistoryTable.setWidths(uriage_table_width); //karteHistoryTable.setDefaultHorizontalAlignment(1); //karteHistoryTable.setDefaultVerticalAlignment(5); karteHistoryTable.setPadding(3.0F); karteHistoryTable.setSpacing(0.0F); karteHistoryTable.setBorderColor(new Color(0, 0, 0)); Cell cell_01 = new Cell(new Phrase("?", font_g10)); cell_01.setGrayFill(0.8F); cell_01.setHorizontalAlignment(Element.ALIGN_CENTER); Cell cell_11 = new Cell(new Phrase("?", font_g10)); cell_11.setGrayFill(0.8F); cell_11.setHorizontalAlignment(Element.ALIGN_CENTER); Cell cell_21 = new Cell(new Phrase("", font_g10)); cell_21.setGrayFill(0.8F); cell_21.setHorizontalAlignment(Element.ALIGN_CENTER); Cell cell_31 = new Cell(new Phrase("", font_g10)); cell_31.setGrayFill(0.8F); cell_31.setHorizontalAlignment(Element.ALIGN_CENTER); Cell cell_41 = new Cell(new Phrase("", font_g10)); cell_41.setGrayFill(0.8F); cell_41.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell_01); karteHistoryTable.addCell(cell_11); karteHistoryTable.addCell(cell_21); karteHistoryTable.addCell(cell_31); karteHistoryTable.addCell(cell_41); List<KarteBean> list = bean.getResult(); KarteBean karteInfo = list.get(0); List<DocInfoModel> docInfoList = karteInfo.getDocInfoList(); //- ??? int stepCount = 22; int tempCount = 0; int pageCount = 0; String firstKarteMaker = null; String karteMakeDate = null; if (docInfoList != null) { for (int i = 0; i < docInfoList.size(); ++i) { DocInfoModel docInfo = docInfoList.get(i); Cell cell = new Cell(new Phrase(docInfo.getFirstConfirmDateTime(), font_m8)); if (karteMakeDate == null || !karteMakeDate.equals(docInfo.getFirstConfirmDateTime())) { karteMakeDate = docInfo.getFirstConfirmDateTime(); firstKarteMaker = docInfo.getPurpose(); } cell.setHorizontalAlignment(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell); cell = new Cell(new Phrase(firstKarteMaker, font_m8)); cell.setHorizontalAlignment(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell); //- String addTitle = docInfo.getTitle(); addTitle = addTitle.replace("\r\n", ""); addTitle = addTitle.replace("\n", ""); cell = new Cell(new Phrase(addTitle, font_m8)); cell.setHorizontalAlignment(0); karteHistoryTable.addCell(cell); cell = new Cell(new Phrase(docInfo.getPurpose(), font_m8)); cell.setHorizontalAlignment(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell); cell = new Cell(new Phrase(docInfo.getConfirmDateTime(), font_m8)); cell.setHorizontalAlignment(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); karteHistoryTable.addCell(cell); if (stepCount == tempCount) { if (pageCount == 0) { stepCount += 5; pageCount++; } tempCount = 0; doc.add(karteHistoryTable); doc.newPage(); karteHistoryTable.deleteAllRows(); karteHistoryTable.addCell(cell_01); karteHistoryTable.addCell(cell_11); karteHistoryTable.addCell(cell_21); karteHistoryTable.addCell(cell_31); karteHistoryTable.addCell(cell_41); } else { tempCount++; } } // Cell Empty_Cell = new Cell(new Phrase("empty", font_empty)); // for (int i = docInfoList.size(); i < docInfoList.size() + 4; ++i) { // for (int j = 0; j < 4; ++j) { // karteHistoryTable.addCell(Empty_Cell); // } // } // // Cell cell_goukei = new Cell(new Phrase("?", font_g10)); // cell_goukei.setGrayFill(0.8F); // cell_goukei.setColspan(3); // karteHistoryTable.addCell(cell_goukei); // Cell cell_sum = new Cell(new Phrase("136,900", font_m10)); // cell_sum.setHorizontalAlignment(2); // karteHistoryTable.addCell(cell_sum); doc.add(karteHistoryTable); doc.newPage(); } else { // doc.add(para_NF); Paragraph noData = new Paragraph("??", font_m8); noData.setAlignment(0); doc.add(noData); doc.newPage(); } } } catch (DocumentException | IOException e) { Logger.getLogger(AuditController.class.getName()).log(Level.SEVERE, null, e); } finally { doc.close(); } }
From source file:org.activityinfo.server.report.renderer.itext.ItextChartRenderer.java
License:Open Source License
@Override public void render(DocWriter writer, Document doc, PivotChartReportElement element) throws DocumentException { doc.add(ThemeHelper.elementTitle(element.getTitle())); ItextRendererHelper.addFilterDescription(doc, element.getContent().getFilterDescriptions()); ItextRendererHelper.addDateFilterDescription(doc, element.getFilter().getDateRange()); if (element.getContent().getData().isEmpty()) { Paragraph para = new Paragraph(I18N.CONSTANTS.noData()); para.setFont(new Font(Font.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 0))); doc.add(para);/*from w w w . ja va 2s .co m*/ } else { float width = doc.getPageSize().getWidth() - doc.rightMargin() - doc.leftMargin(); float height = (doc.getPageSize().getHeight() - doc.topMargin() - doc.bottomMargin()) / 3f; renderImage(writer, doc, element, width, height); } }