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:at.reppeitsolutions.formbuilder.components.pdf.formbuilder.PdfFormBuilderHeading.java

License:Open Source License

@Override
public Element render() {
    Font font = new Font();
    switch (getProperties().getSize()) {
    case 1:/*w  w w  .  ja  v  a2s .c  o  m*/
        font.setSize(30);
        break;
    case 2:
        font.setSize(25);
        break;
    case 3:
        font.setSize(20);
        break;
    }
    Chunk chunk = new Chunk(getProperties().getValues(), font);
    return new ITextParagraph(chunk);
}

From source file:at.reppeitsolutions.formbuilder.components.pdf.formbuilder.PdfFormBuilderHorizontalRule.java

License:Open Source License

@Override
public Element render() {
    Chunk c = new Chunk(new LineSeparator());
    Font f = new Font();
    f.setSize(2);
    c.setFont(f);/* w  w w. ja  v a  2 s .co  m*/
    return c;
}

From source file:at.reppeitsolutions.formbuilder.components.pdf.formbuilder.PdfFormBuilderSpace.java

License:Open Source License

@Override
public Element render() {
    Font font = new Font();
    switch (getProperties().getSize()) {
    case 10:/*from w  w w . j  a  va  2s  .c  o  m*/
        font.setSize(1);
        break;
    case 30:
        font.setSize(6);
        break;
    case 50:
        font.setSize(10);
        break;
    }
    return new ITextParagraph(new Chunk(" ", font));
}

From source file:at.reppeitsolutions.formbuilder.components.pdf.itext.ITextCheckbox.java

License:Open Source License

@Override
public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
    PdfWriter writer = canvases[0].getPdfWriter();
    PdfAppearance[] onOff = new PdfAppearance[2];
    onOff[0] = canvases[0].createAppearance(20, 20);
    onOff[0].rectangle(1, 1, 18, 18);/*from   ww  w .  j  av a2s.  co m*/
    onOff[0].stroke();
    onOff[1] = canvases[0].createAppearance(20, 20);
    onOff[1].setRGBColorFill(255, 128, 128);
    onOff[1].rectangle(1, 1, 18, 18);
    onOff[1].fillStroke();
    onOff[1].moveTo(1, 1);
    onOff[1].lineTo(19, 19);
    onOff[1].moveTo(1, 19);
    onOff[1].lineTo(19, 1);
    onOff[1].stroke();
    RadioCheckField checkbox;
    Font f = new Font();
    f.setSize(ITextInputText.FONTSIZE);
    for (int i = 0; i < values.length; i++) {
        try {
            Rectangle rect = ITextRadio.getBoxRectangle(rectangle, i);
            checkbox = new RadioCheckField(writer, rect, UUID.randomUUID().toString(), "Yes");
            boolean checked = false;
            if (selectedValues != null) {
                for (int i2 = 0; i2 < selectedValues.length; i2++) {
                    if (values[i].equals(selectedValues[i2])) {
                        checked = true;
                        break;
                    }
                }
            }
            checkbox.setChecked(checked);
            PdfFormField field = checkbox.getCheckField();
            field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", onOff[0]);
            field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Yes", onOff[1]);
            if (locked) {
                field.setFieldFlags(BaseField.READ_ONLY);
            }
            writer.addAnnotation(field);
            ITextRadio.addBoxDescription(rectangle, i, values, canvases);
        } catch (IOException ex) {
            Logger.getLogger(ITextCheckbox.class.getName()).log(Level.SEVERE, null, ex);
        } catch (DocumentException ex) {
            Logger.getLogger(ITextCheckbox.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:at.reppeitsolutions.formbuilder.components.pdf.itext.ITextRadio.java

License:Open Source License

public static void addBoxDescription(Rectangle rectangle, int i, String[] values, PdfContentByte[] canvases) {
    Font f = new Font();
    f.setSize(ITextInputText.FONTSIZE);
    ColumnText.showTextAligned(canvases[0], Element.ALIGN_LEFT, new Phrase(values[i], f), 190,
            rectangle.getTop(i * 20) - 15, 0);
}

From source file:be.fedict.eid.applet.service.impl.PdfGenerator.java

License:Open Source License

public byte[] generatePdf(EIdData eIdData) throws DocumentException {
    Document document = new Document();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter writer = PdfWriter.getInstance(document, baos);

    document.open();/* w w w  . j av a 2  s .c om*/

    Paragraph titleParagraph = new Paragraph("eID Identity Data");
    titleParagraph.setAlignment(Paragraph.ALIGN_CENTER);

    Font titleFont = titleParagraph.getFont();
    titleFont.setSize((float) 20.0);
    titleFont.setStyle(Font.BOLD);
    titleParagraph.setSpacingAfter(20);
    document.add(titleParagraph);

    if (null != eIdData && null != eIdData.getIdentity()) {
        if (null != eIdData.getPhoto()) {
            try {
                Image image = createImageFromPhoto(eIdData.getPhoto());
                document.add(image);
            } catch (Exception e) {
                LOG.error("Error getting photo: " + e.getMessage());
            }

            Identity identity = eIdData.getIdentity();

            // metadata
            setDocumentMetadata(document, identity.firstName, identity.name);
            writer.createXmpMetadata();

            // create a table with the data of the eID card
            PdfPTable table = new PdfPTable(2);
            table.getDefaultCell().setBorder(0);

            table.addCell("Name");
            table.addCell(identity.name);

            table.addCell("First name");
            String firstName = identity.firstName;
            if (null != identity.middleName) {
                firstName += " " + identity.middleName;
            }
            table.addCell(firstName);

            table.addCell("Nationality");
            table.addCell(identity.nationality);

            table.addCell("National Registration Number");
            table.addCell(identity.nationalNumber);

            table.addCell("Gender");
            table.addCell(identity.gender.toString());

            table.addCell("Date of birth");
            SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
            table.addCell(formatter.format(identity.dateOfBirth.getTime()));

            table.addCell("Place of birth");
            table.addCell(identity.placeOfBirth);

            if (null != eIdData.getAddress()) {
                Address address = eIdData.getAddress();
                table.addCell("Address");
                PdfPCell cell = new PdfPCell();
                cell.setBorder(0);
                cell.addElement(new Paragraph(address.streetAndNumber));
                cell.addElement(new Paragraph(address.zip + " " + address.municipality));
                table.addCell(cell);
            }

            document.add(table);

            // TODO: to be tested
            /*
            try {
                Image barcodeImage =
                    createBarcodeImage(identity.nationalNumber, identity.cardNumber);
                    
                barcodeImage.setAlignment(Element.ALIGN_CENTER);
                Paragraph barcodePara = new Paragraph();
                barcodePara.add(barcodeImage);
                    
                document.add(barcodeImage);
            } catch (Exception e) {
                LOG.error("Error adding barcode: " + e.getMessage());
            }
            */
        } else {
            document.add(new Paragraph("No eID identity data available."));
        }
    }
    document.close();
    return baos.toByteArray();
}

From source file:br.gov.jfrj.siga.ex.util.GeradorRTF.java

License:Open Source License

public byte[] geraRTF(ExDocumento doc) throws Exception {

    html = doc.getConteudoBlobHtmlString();
    html = (new ProcessadorHtml()).canonicalizarHtml(html, true, false, true, true, false);
    html = html.replace("<!-- INICIO MIOLO -->", "<MIOLO>");
    html = html.replace("<!-- FIM MIOLO -->", "</MIOLO>");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    RtfWriter2.getInstance(document, baos);
    document.open();//from   w ww  .  j  a  v a 2  s . co  m
    document.setMargins(29, 340, 29, 29);
    parser.setInput(new StringReader(html));

    BaseFont arial = BaseFont.createFont("C:\\WINDOWS\\FONTS\\ARIAL.TTF", BaseFont.CP1252, true);
    Font fonte = new Font(arial);
    fonte.setSize(7);
    Paragraph paragrafoBase = new Paragraph("", fonte);

    paragrafoBase.add("\t" + doc.getOrgaoUsuario().getDescricaoMaiusculas());
    paragrafoBase.add("\n\n");
    paragrafoBase
            .add("\t" + doc.getExFormaDocumento().getDescricao().toUpperCase() + " " + doc.getCodigoString());
    if (doc.getDtDocDDMMYY() != null && doc.getDtDocDDMMYY().length() > 0)
        paragrafoBase.add(" DE " + doc.getDtDocDDMMYY());
    paragrafoBase.add("\n\n");

    try {

        seekTag("MIOLO");
        paragrafoBase = (Paragraph) percorreProximoBloco(paragrafoBase, 0, true);

        document.add(paragrafoBase);
    } catch (XmlPullParserException xppe) {
        int a = 2;
    } catch (IOException ioe) {
        int a = 2;
    } finally {
        document.close();
    }

    /*
     * Pattern p1 = Pattern .compile("^.<!-- INICIO MIOLO -->.<!--
     * FIM MIOLO -->."); final Matcher m = p1.matcher(html);
     */

    byte[] retorno = baos.toByteArray();

    baos.close();

    return retorno;

}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public static boolean setDefaultFontByName(String fontName) {
    fontName = fontName.toLowerCase().trim();
    if (TextFactory.fontFamilyRegistered(fontName)) {
        Font newDefaultFont = null;
        try {//from  w ww .j a v a2s  .c o m
            newDefaultFont = FontFactory.getFont(fontName, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        } catch (ExceptionConverter eC) {
            if (eC.getException() instanceof UnsupportedEncodingException) {
                newDefaultFont = FontFactory.getFont(fontName, FontFactory.defaultEncoding, BaseFont.EMBEDDED);
            } else {
                throw new RuntimeException(eC);
            }
        }
        newDefaultFont.setSize(_defaultFontSize);
        _defaultFont = newDefaultFont;
        return true;
    } else {
        return false;
    }
}

From source file:com.amphisoft.epub2pdf.content.TextFactory.java

License:Open Source License

public static boolean setDefaultFontMonoByName(String fontName) {
    fontName = fontName.toLowerCase();/*  w  ww  .  j  a  v  a  2  s  .com*/
    if (TextFactory.fontFamilyRegistered(fontName)) {
        Font newDefaultMonoFont = FontFactory.getFont(fontName, FontFactory.defaultEncoding, BaseFont.EMBEDDED);
        newDefaultMonoFont.setSize(_defaultFontMonoSize);
        _defaultFontMono = newDefaultMonoFont;
        return true;
    } else {
        return false;
    }
}

From source file:com.bibisco.export.ITextExporter.java

License:GNU General Public License

@Override
public void startChapter(String pStrChapterTitle) {

    Font lFont = new Font();
    lFont.setFamily(mFont.getFamilyname());
    lFont.setSize(mFont.getSize());
    lFont.setStyle(Font.BOLD);/*from  ww w.  j  ava 2s  . c  o m*/

    Anchor anchor = new Anchor(pStrChapterTitle, lFont);
    anchor.setName(pStrChapterTitle);

    mChapter = new Chapter(new Paragraph(anchor), ++mIntChapterPosition);
    addEmptyLines(1);
}