Example usage for com.itextpdf.text Font setSize

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

Introduction

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

Prototype

public void setSize(final float size) 

Source Link

Document

Sets the size.

Usage

From source file:Servicios.GeneradorPDF.java

public void addTitulo(String texto) {

    try {/*from   w  w w  .  j a  v  a2  s  .c o  m*/
        Font fuente = new Font();
        fuente.setSize(this.tamTitulo);
        fuente.setStyle(1);
        Paragraph obj = new Paragraph(texto, fuente);
        obj.setAlignment(Element.ALIGN_CENTER);
        this.doc.add(obj);

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Error" + e.getMessage());
    }
}

From source file:Servicios.GeneradorPDF.java

public void addSubTitulo(String texto) {

    try {/*from  w w  w .  j a v  a  2  s . c  o m*/
        Font fuente = new Font();
        fuente.setSize(this.tamSubTitulos);
        Paragraph obj = new Paragraph(texto, fuente);
        obj.setAlignment(Element.ALIGN_CENTER);
        this.doc.add(obj);

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Error" + e.getMessage());
    }
}

From source file:storehausimport.SaveToPdf.java

public boolean save(String inputFilePath, String outputFilePath) throws Exception {
    if (outputFilePath.isEmpty()) {
        throw new Exception("Trkst parametrs outputFilePath");
    }//from w  w w.  j  av a2s . c o m
    if (inputFilePath.isEmpty()) {
        throw new Exception("Trkst parametrs inputFilePath");
    }
    File inputFile = new File(inputFilePath);
    Document pdfDoc = new Document();
    try {
        PdfWriter writer = PdfWriter.getInstance(pdfDoc, new FileOutputStream(outputFilePath));
        pdfDoc.open();
        pdfDoc.setMarginMirroring(true);
        pdfDoc.setMargins(36, 72, 108, 180);
        pdfDoc.topMargin();

        BaseFont helvetica = BaseFont.createFont("Helvetica", BaseFont.CP1257, BaseFont.NOT_EMBEDDED);
        Font normal_font = new Font(helvetica, 10, Font.NORMAL);
        Font bold_font = new Font();
        bold_font.setStyle(Font.BOLD);
        bold_font.setSize(10);
        pdfDoc.add(new Paragraph("\n"));
        if (inputFile.exists()) {
            iStream = new FileInputStream(inputFile);
            in = new DataInputStream(iStream);
            is = new InputStreamReader(in);
            br = new BufferedReader(is);
            String strLine;
            while ((strLine = br.readLine()) != null) {
                Paragraph para = new Paragraph(strLine + "\n", normal_font);
                para.setAlignment(Element.ALIGN_LEFT);
                pdfDoc.add(para);
            }
        } else {
            pdfDoc.close();
            throw new Exception("Trkst parametrs inputFilePath");
        }
        pdfDoc.close();
    } catch (Exception ex) {
        throw new Exception(ex);
    }
    return true;
}

From source file:utils.PrintUtils.java

public static Font setUpFont(final float size, final int style, final BaseColor color) {
    Font font = new Font();
    font.setStyle(style);//  ww  w  .  j  av a 2s.c  o m
    font.setSize(size);
    font.setColor(color);
    return font;
}