Example usage for com.lowagie.text Font setSize

List of usage examples for com.lowagie.text Font setSize

Introduction

In this page you can find the example usage for com.lowagie.text Font setSize.

Prototype

public void setSize(float size) 

Source Link

Document

Sets the size.

Usage

From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java

License:Open Source License

public PdfPTable createPreviousMbTable() {
    final PdfPTable previousMbTable = new PdfPTable(2);
    final Font font = new Font();
    font.setSize(8);
    previousMbTable.getDefaultCell().setBorderWidth(1);
    previousMbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    previousMbTable.getDefaultCell().setColspan(2);
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.previousmeasurement"), font)));
    previousMbTable.getDefaultCell().setColspan(1);
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.pageno"), font)));
    previousMbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.measurements"), font)));
    return previousMbTable;
}

From source file:org.lucee.extension.pdf.tag.PDF.java

License:Open Source License

private Font toFont(Struct sct) throws PageException {
    Cast caster = engine.getCastUtil();//from ww w. j  av a2  s. c  om
    Font f = getDefaultFont();
    // size
    float size = caster.toFloatValue(sct.get("size", null), 0);
    if (size > 0)
        f.setSize(size);

    // family
    Set fonts = FontFactory.getRegisteredFonts();
    String family = caster.toString(sct.get("family", null), null);
    if (!Util.isEmpty(family)) {
        String lc = family.toLowerCase();
        if (!fonts.contains(lc)) {
            StringBuilder sb = new StringBuilder();
            Iterator it = fonts.iterator();
            while (it.hasNext()) {
                if (sb.length() > 0)
                    sb.append(", ");
                sb.append(it.next());
            }
            throw engine.getExceptionUtil().createApplicationException(
                    "font family [" + family + "] is not available, available font families are [" + sb + "]");
        }
        f.setFamily(lc);
    }

    int style = 0;
    // bold
    boolean bold = caster.toBooleanValue(sct.get("bold", null), false);
    if (bold)
        style |= Font.BOLD;
    // italic
    boolean italic = caster.toBooleanValue(sct.get("italic", null), false);
    if (italic)
        style |= Font.ITALIC;
    // underline
    boolean underline = caster.toBooleanValue(sct.get("underline", null), false);
    if (underline)
        style |= Font.UNDERLINE;
    // strike
    boolean strike = caster.toBooleanValue(sct.get("strike", null), false);
    if (strike)
        style |= Font.STRIKETHRU;
    if (style != 0)
        f.setStyle(style);

    return f;
}

From source file:org.lucee.extension.pdf.tag.PDF.java

License:Open Source License

private static Font getDefaultFont() {
    Font font = new Font(Font.COURIER);
    font.setSize(10);
    return font;/*from  w w w . j  a  v a 2  s .  c om*/
}

From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java

License:Educational Community License

public void addSectionHeader(String headerText, boolean lastElementIsHeader, float theSize) {
    LOG.debug("Added a header with text: " + headerText + " and size: " + theSize
            + ". Previous element was another header: " + lastElementIsHeader);
    if (!lastElementIsHeader) {
        Paragraph emptyPara = new Paragraph(" ");
        this.addElementWithJump(emptyPara, true);
    }//from w w  w  .j ava  2 s.  co m
    Paragraph headerPara = new Paragraph(headerText);
    Font fuente = headerPara.getFont();
    fuente.setSize(theSize);
    headerPara.setFont(fuente);
    headerPara.setSpacingAfter(SPACING_AFTER_HEADER);
    this.addElementWithJump(headerPara, true);
}

From source file:ro.nextreports.engine.exporter.RtfExporter.java

License:Apache License

private void updateFont(Font fnt, Map<String, Object> style) {
    if (style != null) {
        if (style.containsKey(StyleFormatConstants.FONT_FAMILY_KEY)) {
            String val = (String) style.get(StyleFormatConstants.FONT_FAMILY_KEY);
            fnt.setFamily(val);
        }/*from  w  w w. j a  v a 2 s  .  co m*/
        if (style.containsKey(StyleFormatConstants.FONT_SIZE)) {
            Float val = (Float) style.get(StyleFormatConstants.FONT_SIZE);
            fnt.setSize(val);
        }
        if (style.containsKey(StyleFormatConstants.FONT_COLOR)) {
            Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR);
            fnt.setColor(val);
        }
        if (style.containsKey(StyleFormatConstants.FONT_STYLE_KEY)) {
            if (StyleFormatConstants.FONT_STYLE_NORMAL.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
                fnt.setStyle(com.lowagie.text.Font.NORMAL);
            }
            if (StyleFormatConstants.FONT_STYLE_BOLD.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
                fnt.setStyle(com.lowagie.text.Font.BOLD);
            }
            if (StyleFormatConstants.FONT_STYLE_ITALIC.equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
                fnt.setStyle(com.lowagie.text.Font.ITALIC);
            }
            if (StyleFormatConstants.FONT_STYLE_BOLDITALIC
                    .equals(style.get(StyleFormatConstants.FONT_STYLE_KEY))) {
                fnt.setStyle(com.lowagie.text.Font.BOLDITALIC);
            }
        }
    }
}

From source file:tufts.vue.PresentationNotes.java

License:Educational Community License

public static void createSpeakerNotes4PerPage(File file) {
    //page size notes:
    //martin-top,left,right,bottom = 36
    //widht :612//from www . j a  v a 2s . c  o m
    //height : 792
    //usable space 540 x 720
    // step 1: creation of a document-object

    Document document = new Document(PageSize.LETTER);

    try {
        GUI.activateWaitCursor();
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file            
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        //  writer.setDefaultColorspace(PdfName.DEFAULTRGB, null);
        // writer.setStrictImageSequence(true);

        // step 3: we open the document
        document.open();

        PdfPTable table;
        PdfPCell cell;
        int entryCount = 0;
        int entryOnPage = 0;
        int currentIndex = VUE.getActivePathway().getIndex();

        VUE.getActivePathway().setIndex(-1);

        for (LWPathway.Entry entry : VUE.getActivePathway().getEntries()) {

            final LWSlide slide = entry.produceSlide();
            final LWComponent toDraw = (slide == null ? entry.node : slide);
            final String notes = entry.getNotes();
            entryCount++;

            table = new PdfPTable(new float[] { 1, 1 });
            table.getDefaultCell().setBorder(0);
            //table.getDefaultCell().setPaddingBottom(50.0f);
            table.setSpacingAfter(20.0f);
            Paragraph p = new Paragraph();

            p.setAlignment(Element.ALIGN_CENTER);

            Phrase phrase = new Phrase(notes);
            Font f = phrase.getFont();
            f.setSize(8.0f);
            p.setFont(f);
            cell = new PdfPCell(phrase);
            cell.setBorder(0);

            PdfPCell i2 = new PdfPCell();
            i2.setFixedHeight(172);
            i2.setBorder(0);

            //Render the table then throw the images on
            PdfContentByte cb = writer.getDirectContent();
            PdfTemplate tp = cb.createTemplate(SlideSizeX, SlideSizeY);

            Point2D.Float offset = new Point2D.Float();
            // center vertically only if landscape mode
            //if (format.getOrientation() == PageFormat.LANDSCAPE)
            //TODO: allow horizontal centering, but not vertical centering (handle in computeZoomFit)

            Rectangle2D bounds = null;
            //if (!entry.isMapView())
            bounds = slide.getBounds();
            //else 
            //bounds = entry.getFocal().getBounds();

            Dimension page = null;

            page = new Dimension(SlideSizeX, 172);

            //PdfTemplate tp = cb.createTemplate(document.getPageSize().width()-80, document.getPageSize().height()-80);
            double scale = ZoomTool.computeZoomFit(page, 5, bounds, offset, true);
            PdfGraphics2D g2d = (PdfGraphics2D) tp.createGraphics(SlideSizeX, SlideSizeY, getFontMapper(),
                    false, 60.0f);
            DrawContext dc = new DrawContext(g2d, scale, -offset.x, -offset.y, null, // frame would be the PageFormat offset & size rectangle
                    entry.isMapView() ? entry.getFocal() : slide, false); // todo: absolute links shouldn't be spec'd here

            dc.setClipOptimized(false);
            dc.setPrintQuality();
            /*if (!entry.isMapView())                   
               slide.drawZero(dc);
            else
            {                
               entry.getFocal().draw(dc);
            }*/
            toDraw.drawFit(dc, 0);

            g2d.dispose();
            //document.add(Image.getInstance(tp));

            //  int position = cell.
            //     drawSequenceNumber(writer,36,position+203,entryCount);

            //     cb.addTemplate(tp,56, position);                                                           

            Image img = Image.getInstance(tp);
            table.addCell(img);
            table.addCell(cell);
            p.add(table);
            document.add(p);
        }
        VUE.getActivePathway().setIndex(currentIndex);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    } finally {
        GUI.clearWaitCursor();
    }

    // step 5: we close the document
    document.close();

}

From source file:tufts.vue.PresentationNotes.java

License:Educational Community License

public static void createNodeNotes4PerPage(File file) {
    //page size notes:
    //martin-top,left,right,bottom = 36
    //widht :612/*from ww  w  .j  a  v  a2s  . com*/
    //height : 792
    //usable space 540 x 720
    // step 1: creation of a document-object

    Document document = new Document(PageSize.LETTER);

    try {
        GUI.activateWaitCursor();
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file            
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        //  writer.setDefaultColorspace(PdfName.DEFAULTRGB, null);
        // writer.setStrictImageSequence(true);

        // step 3: we open the document
        document.open();

        PdfPTable table;
        PdfPCell cell;
        int entryCount = 0;
        int entryOnPage = 0;

        Iterator i = VUE.getActiveMap().getAllDescendents(LWComponent.ChildKind.PROPER).iterator();
        while (i.hasNext()) {
            LWComponent component = (LWComponent) i.next();
            if (component instanceof LWNode) {
                final LWNode node = (LWNode) component;

                final String notes = node.getNotes();

                entryCount++;

                table = new PdfPTable(new float[] { 1, 1 });
                table.getDefaultCell().setBorder(0);

                table.setSpacingAfter(20.0f);
                Paragraph p = new Paragraph();

                p.setAlignment(Element.ALIGN_CENTER);

                Phrase phrase = new Phrase(notes);

                Font f = phrase.getFont();
                f.setSize(8.0f);
                p.setFont(f);
                cell = new PdfPCell(phrase);
                cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                cell.setBorder(0);

                PdfPCell i2 = new PdfPCell();
                i2.setFixedHeight(172);
                i2.setBorder(0);

                //Render the table then throw the images on
                PdfContentByte cb = writer.getDirectContent();
                PdfTemplate tp = cb.createTemplate(SlideSizeX, SlideSizeY);

                Point2D.Float offset = new Point2D.Float();
                //center vertically only if landscape mode
                //if (format.getOrientation() == PageFormat.LANDSCAPE)
                //TODO: allow horizontal centering, but not vertical centering (handle in computeZoomFit)

                Rectangle2D bounds = null;

                bounds = node.getBounds();

                Dimension page = null;

                page = new Dimension(SlideSizeX, 172);

                //   PdfTemplate tp = cb.createTemplate(document.getPageSize().width()-80, document.getPageSize().height()-80);
                double scale = ZoomTool.computeZoomFit(page, 15, bounds, offset, true);
                PdfGraphics2D g2d = (PdfGraphics2D) tp.createGraphics(SlideSizeX, SlideSizeY, getFontMapper(),
                        false, 60.0f);
                DrawContext dc = new DrawContext(g2d, scale, -offset.x, -offset.y, null, // frame would be the PageFormat offset & size rectangle
                        node, false); // todo: absolute links shouldn't be spec'd here

                dc.setClipOptimized(false);
                dc.setPrintQuality();
                node.drawFit(dc, 15);

                g2d.dispose();

                Image img = Image.getInstance(tp);
                table.addCell(img);
                table.addCell(cell);
                p.add(table);
                document.add(p);
            }
        }

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    } finally {
        GUI.clearWaitCursor();
    }

    // step 5: we close the document
    document.close();

}

From source file:tufts.vue.PresentationNotes.java

License:Educational Community License

public static void createNodeOutline(File file) {
    //page size notes:
    //martin-top,left,right,bottom = 36
    //widht :612/*from w ww .  ja  v  a2  s .  c  o  m*/
    //height : 792
    //usable space 540 x 720
    // step 1: creation of a document-object               
    Document document = new Document(PageSize.LETTER);

    try {
        GUI.activateWaitCursor();
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file            
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        //  writer.setDefaultColorspace(PdfName.DEFAULTRGB, null);
        // writer.setStrictImageSequence(true);

        // step 3: we open the document
        document.open();

        Paragraph p1 = new Paragraph(VUE.getActiveMap().getLabel());

        p1.setSpacingAfter(15.0f);
        Font f = p1.getFont();
        f.setStyle(Font.BOLD);
        f.setSize(18f);
        p1.setFont(f);
        document.add(p1);

        String n2 = VUE.getActiveMap().getNotes();
        if (n2 != null && n2.length() > 0) {
            Paragraph p2 = new Paragraph(n2);
            p2.setIndentationLeft(30.0f);
            p2.setSpacingAfter(15.0f);
            //   f = p2.getFont();
            //f.setSize(f.getSize()-2);
            //p2.setFont(f);
            document.add(p2);
        }

        int entryCount = 1;
        float indentation = 0.0f;
        Iterator it = VUE.getActiveMap().getAllDescendents(LWComponent.ChildKind.PROPER).iterator();

        while (it.hasNext()) {
            LWComponent c = (LWComponent) it.next();
            if (c instanceof LWNode) {
                LWNode n = (LWNode) c;
                outlineChildNode(document, indentation, n, entryCount);
                entryCount++;
                iterateChildren(document, indentation + 10, n, 1);
            }

        }

        it = VUE.getActiveMap().getAllDescendents(LWComponent.ChildKind.PROPER).iterator();
        while (it.hasNext()) {
            LWComponent c = (LWComponent) it.next();
            if (c instanceof LWLink) {
                LWLink l = (LWLink) c;
                String notes = l.getNotes();
                String linkLabel = l.getLabel();

                if ((notes == null || notes.length() == 0) && (linkLabel == null || linkLabel.length() == 0))
                    continue;

                if (linkLabel == null || linkLabel.length() == 0)
                    linkLabel = "Link";

                Paragraph p = new Paragraph(entryCount + ".  " + linkLabel.replaceAll("\\n", ""));
                f = p.getFont();
                f.setStyle(Font.BOLD);
                f.setSize(14f);
                p.setFont(f);
                Paragraph notesP = new Paragraph(notes);

                // f = notesP.getFont();
                //   f.setSize(f.getSize()-2);
                notesP.setIndentationLeft(30.0f);
                notesP.setSpacingAfter(15.0f);
                document.add(p);
                document.add(notesP);

                entryCount++;
            }
        }

    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    } finally {
        GUI.clearWaitCursor();
    }
    // step 5: we close the document
    document.close();

}

From source file:tufts.vue.PresentationNotes.java

License:Educational Community License

private static void outlineChildNode(Document d, float indentation, LWNode n, int entryCount) {
    String notes = n.getNotes();//from  w w w .  ja v  a2s .co m
    String nodeLabel = n.getLabel();

    if (nodeLabel == null || nodeLabel.length() == 0)
        nodeLabel = "Node";

    Paragraph p = new Paragraph(entryCount + ".  " + n.getLabel().replaceAll("\\n", ""));
    Font f = p.getFont();
    f.setStyle(Font.BOLD);
    f.setSize(14f);
    p.setFont(f);
    p.setIndentationLeft(indentation);
    Paragraph notesP = new Paragraph(notes);

    notesP.setIndentationLeft(indentation + 20);
    notesP.setSpacingAfter(15.0f);
    try {
        d.add(p);
        d.add(notesP);
    } catch (DocumentException e) {
        e.printStackTrace();
    }

}