List of usage examples for com.lowagie.text Font setSize
public void setSize(float size)
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private Font createHeaderFont() { /*//from ww w.j a va 2 s .c om * Font for the headers */ Font headerFont = new Font(); headerFont.setStyle(Font.BOLD); headerFont.setSize(headerFontSize); return headerFont; }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private void addReplyLink(Document document, String replyURL) throws DocumentException { PdfPTable replyTable = new PdfPTable(1); replyTable.setWidthPercentage(100f); replyTable.setSplitLate(false);// ww w.j a v a2 s . c o m replyTable.setSpacingBefore(5f); replyTable.setHorizontalAlignment(Element.ALIGN_LEFT); Font linkFont = new Font(); linkFont.setStyle(Font.BOLD); linkFont.setColor(0, 0, 255); linkFont.setSize(headerFontSize); Chunk anchor = new Chunk("Reply", linkFont); anchor.setAnchor(replyURL); Phrase phrase = new Phrase(); phrase.add(anchor); PdfPCell cell = new PdfPCell(phrase); cell.setBorder(Rectangle.NO_BORDER); replyTable.addCell(cell); document.add(replyTable); }
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;/*w w w . j a va 2 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:nl.dykema.jxmlnote.report.pdf.PdfParagraph.java
License:Open Source License
public Paragraph setStyle(XMLNoteParStyle style) { //System.out.println(super.getLeading()+","+super.getMultipliedLeading()); _style = style;//w w w . jav a2 s . co m if (style == null) { return this; } int chst = 0; if (style.bold()) { chst += Font.BOLD; } if (style.italics()) { chst += Font.ITALIC; } if (style.underline()) { chst += Font.UNDERLINE; } Font f = getFont(style.getFont()); f.setSize(style.pointSize()); f.setStyle(chst); float indentleft; indentleft = (float) style.leftIndent(); super.setIndentationLeft(indentleft); super.setSpacingAfter(style.bottomSkip()); super.setSpacingBefore(style.topSkip()); //super.setLeading(0.0f); DO DIT NIET! //System.out.println(super.getLeading()+","+super.getMultipliedLeading()); int p1align = getAlign(style); super.setAlignment(p1align); super.setFont(f); //System.out.println(super.getLeading()+","+super.getMultipliedLeading()); super.setLeading(0.0f, 1.2f); //System.out.println(super.getLeading()+","+super.getMultipliedLeading()); return this; }
From source file:org.apache.maven.doxia.module.itext.ITextFont.java
License:Apache License
/** * Convenience method to get a defined font depending the wanted style and size. * * @param style the font style./*from www . j av a2 s . com*/ * @param size the font size. * @param color the font color. * @return a font the font. */ public static Font getFont(int style, float size, Color color) { Font font = new Font(); font.setFamily(DEFAULT_FONT_NAME); font.setStyle(style); font.setSize(size); font.setColor(color); return font; }
From source file:org.egov.works.utils.AbstractPDFGenerator.java
License:Open Source License
protected Paragraph makeParaWithFont(final float fontSize, final Object value, final int alignment) { final Font font = new Font(); font.setSize(fontSize); final Paragraph header = new Paragraph(value == null ? "" : value.toString(), font); header.setAlignment(alignment);// w w w . ja v a 2s . com return header; }
From source file:org.egov.works.utils.AbstractPDFGenerator.java
License:Open Source License
protected Paragraph makeParaWithFont(final float fontSize, final Object value) { final Font font = new Font(); font.setSize(fontSize); return new Paragraph(value == null ? "" : value.toString(), font); }
From source file:org.egov.works.utils.AbstractPDFGenerator.java
License:Open Source License
protected Paragraph makePara(final float size, final Object value) { final Font font = new Font(); font.setSize(size); return new Paragraph(value == null ? "" : value.toString(), font); }
From source file:org.egov.works.utils.AbstractPDFGenerator.java
License:Open Source License
protected Paragraph rightPara(final float size, final Object value) { final Font font = new Font(); font.setSize(size); final Paragraph header = new Paragraph(value == null ? "" : value.toString(), font); header.setAlignment(Element.ALIGN_RIGHT); return header; }
From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java
License:Open Source License
private PdfPTable createMbTable() throws DocumentException { PdfPTable mbTable;/* www . j a v a 2 s .co m*/ if (includeRevisionTypeColumn) { mbTable = new PdfPTable(12); mbTable.setWidths(new float[] { 1f, 1.5f, 4f, 1.4f, 1.9f, 1.6f, 1.4f, 1.8f, 1.9f, 1.9f, 1.9f, 1.6f }); } else { mbTable = new PdfPTable(11); mbTable.setWidths(new float[] { 1f, 1.5f, 4f, 1.9f, 1.6f, 1.4f, 1.8f, 1.9f, 1.9f, 1.9f, 1.6f }); } // main table mbTable.setWidthPercentage(100); try { final Font font = new Font(); font.setSize(8); mbTable.getDefaultCell().setPadding(3); mbTable.getDefaultCell().setBorderWidth(1); mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.slno"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.schno"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.descofwork"), font))); if (includeRevisionTypeColumn) mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.revisiontype"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.completedmeasurement"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.unitrate"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.unit"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.totalvalueofcomplwork"), font))); // start creating tables for previous measurements final PdfPTable previousMbTable = createPreviousMbTable(); final PdfPCell previousMbCell = new PdfPCell(previousMbTable); previousMbCell.setColspan(2); mbTable.addCell(previousMbCell); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.currentmeasurement"), font))); // last column mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.currentcost"), font))); } catch (final RuntimeException e) { throw new ApplicationRuntimeException(MEASUREMENTBOOK_PDF_ERROR, e); } return mbTable; }