Example usage for com.itextpdf.text Font NORMAL

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

Introduction

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

Prototype

int NORMAL

To view the source code for com.itextpdf.text Font NORMAL.

Click Source Link

Document

this is a possible style.

Usage

From source file:watermark.java

public static void main(String[] args) {
    try {/*from www .  jav  a  2 s. c om*/
        PdfReader reader = new PdfReader(args[0]);
        PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(args[1]));
        stamp.getWriter().setCompressionLevel(9); // without this code it'll 3 times bigger

        int bottom_margin = Integer.parseInt(args[2]);
        String lic = String.format(LIC, args[3]);

        BaseFont bf = BaseFont.createFont(FONTFILE, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        Chunk c = new Chunk(lic, new Font(bf, 7, Font.NORMAL, TCOLOR));
        c.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 1 / 800f, null);

        Phrase phrase = new Phrase(c);

        int pages = reader.getNumberOfPages();
        int xpos = 90;
        for (int i = 1; i <= pages; i++) {
            if (i % 2 == 0)
                xpos = 160;
            else
                xpos = 90;

            PdfContentByte under = stamp.getUnderContent(i);
            ColumnText.showTextAligned(under, Element.ALIGN_LEFT, phrase, xpos, bottom_margin, -0);
        }

        stamp.setFullCompression(); // without this code it'll 3 times bigger
        stamp.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:imprimer.java

public void openPDF() {

    Document document = new Document(PageSize.A4);
    try {// w  w w.  j  a  v a  2s. c o m
        PdfWriter.getInstance(document, new FileOutputStream("imprimer test.pdf"));

        document.open();

        imagee(document);

        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Attestation de travail",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 3; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph p = new Paragraph(text,
                FontFactory.getFont(FontFactory.TIMES, 16, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p);

        Paragraph time = new Paragraph("                Fait  Ouarzazate le : " + tdnow,
                FontFactory.getFont(FontFactory.TIMES, 17, Font.BOLD, BaseColor.DARK_GRAY));
        Paragraph a = new Paragraph("");
        Paragraph si = new Paragraph("                 Signature:",
                FontFactory.getFont(FontFactory.TIMES, 17, Font.BOLD, BaseColor.DARK_GRAY));

        time.setAlignment(Paragraph.ALIGN_CENTER);
        si.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(time);
        document.add(si);
        document.add(a);
        document.close();

        System.out.println("date2");
        /* Open Pdf */
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("imprimer test.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

        System.out.println("date");

    } catch (Exception ex) {
        System.out.println("qsdqs");
    }
}

From source file:imprimer.java

public void attestation_travail_prof() {

    Document document = new Document(PageSize.A4);
    try {//from   w ww . j ava2s. c o  m
        PdfWriter.getInstance(document, new FileOutputStream("Attestation de travail Professeur.pdf"));
        document.open();

        imagee(document);
        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Attestation de travail",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 3; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph p = new Paragraph(text3,
                FontFactory.getFont(FontFactory.TIMES, 16, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p);

        Paragraph time = new Paragraph("                Fait  Ouarzazate le : " + tdnow,
                FontFactory.getFont(FontFactory.TIMES, 17, Font.BOLD, BaseColor.DARK_GRAY));
        Paragraph a = new Paragraph("");
        Paragraph si = new Paragraph("                 Signature:",
                FontFactory.getFont(FontFactory.TIMES, 17, Font.BOLD, BaseColor.DARK_GRAY));

        time.setAlignment(Paragraph.ALIGN_CENTER);
        si.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(time);
        document.add(si);
        document.add(a);
        document.close();

        System.out.println("date2");
        /* Open Pdf */
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("Attestation de travail Professeur.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

        System.out.println("date");
    } catch (Exception ex) {

        System.out.println("qsdqs");
    }
}

From source file:imprimer.java

public void conje() {
    Document document = new Document(PageSize.A4);
    try {//ww  w .  jav  a2 s  .c om
        PdfWriter.getInstance(document, new FileOutputStream("conjee.pdf"));

        document.open();
        imagee(document);
        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Dcision de cong",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph p = new Paragraph(text2,
                FontFactory.getFont(FontFactory.TIMES, 14, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p);
        Paragraph p3 = new Paragraph("DECIDE :",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));
        p3.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p3);
        Paragraph p4 = new Paragraph("ARTICLE I Un cong dun .",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p4);
        Paragraph p5 = new Paragraph(
                "           Est accord    :    \n" + "           C.I.N           :    \n"
                        + "           GRADE           :    \n" + "           Pour la priode :   ",
                FontFactory.getFont(FontFactory.TIMES, 15, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p5);
        Paragraph p6 = new Paragraph("ARTICLE II",
                FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p6);
        Paragraph p7 = new Paragraph(
                "Lintress(e) est autoris  quitter le territoire national durant la priode indique ci-dessus",
                FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p7);
        Paragraph p8 = new Paragraph("ARTICLE III",
                FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p8);
        Paragraph p9 = new Paragraph(
                "Lintress(e) est tenu daviser le service du personnel de sa reprise de travail aprs expiration du  cong sus-vis.",
                FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p9);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph time = new Paragraph(
                "             Cachet et signature                                        Fait  Ouarzazate le :"
                        + tdnow + "\n" + "\n",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));

        Paragraph si = new Paragraph("Signature du demandeur",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));
        time.setAlignment(Paragraph.ALIGN_LEFT);
        si.setAlignment(Paragraph.ALIGN_RIGHT);
        document.add(time);
        document.add(si);
        document.close();

        System.out.println("date2");
        /* Open Pdf */
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("conjee.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

        System.out.println("date");
    } catch (Exception ex) {

        System.out.println("qsdqs");
    }
}

From source file:imprimer.java

public void conje_exp() {
    Document document = new Document(PageSize.A4);
    try {/*from  www  . java2  s . c o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("conjee_exp.pdf"));

        document.open();
        imagee(document);
        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Dcision de cong",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph p = new Paragraph(text2,
                FontFactory.getFont(FontFactory.TIMES, 14, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p);
        Paragraph p3 = new Paragraph("DECIDE :",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));
        p3.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p3);
        Paragraph p4 = new Paragraph("ARTICLE I",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p4);
        Paragraph p5 = new Paragraph(
                "           Un cong Exceptionnel dune dure de jours\n"
                        + "           Est accord    :    \n" + "           C.I.N           :    \n"
                        + "           GRADE           :    \n" + "           Pour la priode :   ",
                FontFactory.getFont(FontFactory.TIMES, 15, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p5);
        Paragraph p6 = new Paragraph("ARTICLE II",
                FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p6);
        Paragraph p7 = new Paragraph(
                "Lintress(e) est autoris  quitter le territoire national durant la priode indique ci-dessus",
                FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p7);
        Paragraph p8 = new Paragraph("ARTICLE III",
                FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p8);
        Paragraph p9 = new Paragraph(
                "Lintress(e) est tenu daviser le service du personnel de sa reprise de travail aprs expiration du  cong sus-vis.",
                FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p9);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph time = new Paragraph(
                "             Cachet et signature                                        Fait  Ouarzazate le :"
                        + tdnow + "\n" + "\n",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));

        Paragraph si = new Paragraph("Signature du demandeur",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));
        time.setAlignment(Paragraph.ALIGN_LEFT);
        si.setAlignment(Paragraph.ALIGN_RIGHT);
        document.add(time);
        document.add(si);
        document.close();

        System.out.println("date2");
        /* Open Pdf */
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("conjee_exp.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

        System.out.println("date");
    } catch (Exception ex) {

        System.out.println("qsdqs");
    }
}

From source file:adams.core.io.PdfFont.java

License:Open Source License

/**
 * Parses the given string./*from ww  w  . ja v  a2s . c o m*/
 *
 * @param fontStr   the string to parse
 */
public PdfFont(String fontStr) {
    String attsStr;
    String str;
    String[] split;
    int i;

    str = fontStr;

    // size
    m_Size = Integer.parseInt(str.substring(str.lastIndexOf(SEPARATOR) + 1));
    str = str.substring(0, str.lastIndexOf(SEPARATOR));

    // face
    attsStr = str.substring(str.lastIndexOf(SEPARATOR) + 1);
    split = attsStr.split(",");
    str = str.substring(0, str.lastIndexOf(SEPARATOR));
    m_FontFace = Font.NORMAL;
    for (i = 0; i < split.length; i++)
        m_FontFace |= getFontFace(split[i]);

    // family
    m_FontFamily = getFontFamily(str);
}

From source file:adams.gui.chooser.PdfFontChooserPanel.java

License:Open Source License

/**
 * Determines the font based on the current settings and returns it.
 *
 * @return      the generate font//from ww  w.  ja va 2s . c  om
 */
protected PdfFont createFont() {
    int family;
    int style;
    Object[] styles;
    int i;

    family = PdfFont.getFontFamily((String) m_ListFontName.getSelectedValue());
    style = Font.NORMAL;
    styles = m_ListFontFace.getSelectedValues();
    for (i = 0; i < styles.length; i++)
        style |= PdfFont.getFontFace((String) styles[i]);

    return new PdfFont(family, style, (Integer) m_ListFontSize.getSelectedValue());
}

From source file:adams.gui.chooser.PdfFontChooserPanel.java

License:Open Source License

/**
 * Sets the selected font. If null is provided, the default font/size will
 * be used./*from w  w  w . ja  v  a2  s.c  om*/
 *
 * @param value   the font, can be null
 */
public void setCurrent(PdfFont value) {
    String[] styles;
    int[] indices;
    int i;

    m_IgnoreUpdates = true;

    if (value == null)
        value = new PdfFont();

    m_ListFontName.setSelectedValue(value.getFontFamilyName(), true);
    if (m_ListFontName.getSelectedIndex() == -1)
        m_ListFontName.setSelectedValue(DEFAULT_FONT, true);

    if ((value.getFontFace() != Font.NORMAL) && (value.getFontFace() != Font.UNDEFINED)) {
        styles = value.getFontFaces();
        indices = new int[styles.length];
        for (i = 0; i < styles.length; i++)
            indices[i] = Arrays.binarySearch(FONT_FACES, styles[i]);
    } else {
        indices = new int[0];
    }
    m_ListFontFace.setSelectedIndices(indices);

    m_ListFontSize.setSelectedValue((int) value.getSize(), true);
    if (m_ListFontSize.getSelectedIndex() == -1)
        m_ListFontSize.setSelectedValue(DEFAULT_SIZE, true);

    m_IgnoreUpdates = false;

    previewFont();
}

From source file:Almacen.Existencias.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    aux = 0;//from  w w w .  j a  v a2s. c om
    try {
        javax.swing.JFileChooser archivo = new javax.swing.JFileChooser();
        archivo.setFileFilter(new ExtensionFileFilter("pdf document (*.pdf)", new String[] { "PDF" }));
        String ruta = null;
        if (archivo.showSaveDialog(null) == archivo.APPROVE_OPTION) {
            ruta = archivo.getSelectedFile().getAbsolutePath();
            if (ruta != null) {
                try {
                    PDF reporte = new PDF();
                    reporte.Abrir2(PageSize.LEGAL.rotate(), "Existencias", ruta + ".pdf");
                    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
                            BaseFont.NOT_EMBEDDED);
                    float[] tamanio = new float[] { 90, 120, 120, 55, 230, 55, 90, 90 };
                    Font font = new Font(Font.FontFamily.HELVETICA, 9, Font.NORMAL);
                    BaseColor contenido = BaseColor.WHITE;
                    int centro = com.itextpdf.text.Element.ALIGN_CENTER;
                    int izquierda = com.itextpdf.text.Element.ALIGN_LEFT;
                    int derecha = com.itextpdf.text.Element.ALIGN_RIGHT;

                    PdfPTable tabla = reporte.crearTabla(tamanio.length, tamanio, 100, Element.ALIGN_CENTER);
                    cabecera(reporte, bf, tabla, "EXISTENCIAS DE ARTICULOS.", 2);

                    for (int i = 0; i < t_datos.getRowCount(); i++) {
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 0).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 1).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 2).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 3).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 4).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 5).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 6).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 7).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                    }
                    reporte.agregaObjeto(tabla);
                    reporte.cerrar();
                    reporte.visualizar2(ruta + ".pdf");
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(this,
                            "No se pudo realizar el reporte si el archivo esta abierto.");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Almacen.Existencias.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    aux = 1;/*from  ww w  . j a va2s  .c  om*/
    try {
        javax.swing.JFileChooser archivo = new javax.swing.JFileChooser();
        archivo.setFileFilter(new ExtensionFileFilter("pdf document (*.pdf)", new String[] { "PDF" }));
        String ruta = null;
        if (archivo.showSaveDialog(null) == archivo.APPROVE_OPTION) {
            ruta = archivo.getSelectedFile().getAbsolutePath();
            if (ruta != null) {
                try {
                    PDF reporte = new PDF();
                    reporte.Abrir2(PageSize.LEGAL.rotate(), "Existencias", ruta + ".pdf");
                    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
                            BaseFont.NOT_EMBEDDED);
                    float[] tamanio = new float[] { 90, 120, 120, 55, 230, 55, 100, 100 };
                    Font font = new Font(Font.FontFamily.HELVETICA, 9, Font.NORMAL);
                    BaseColor contenido = BaseColor.WHITE;
                    int centro = com.itextpdf.text.Element.ALIGN_CENTER;
                    int izquierda = com.itextpdf.text.Element.ALIGN_LEFT;
                    int derecha = com.itextpdf.text.Element.ALIGN_RIGHT;

                    PdfPTable tabla = reporte.crearTabla(tamanio.length, tamanio, 100, Element.ALIGN_CENTER);
                    cabecera(reporte, bf, tabla, "EXISTENCIAS DE ARTICULOS.", 2);

                    for (int i = 0; i < t_datos.getRowCount(); i++) {
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 0).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 1).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 2).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 3).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 4).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 5).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(t_datos.getValueAt(i, 6).toString(), font, contenido,
                                centro, 0, 1, Rectangle.RECTANGLE));
                        tabla.addCell(reporte.celda(" ", font, contenido, centro, 0, 1, Rectangle.RECTANGLE));
                    }
                    reporte.agregaObjeto(tabla);
                    reporte.cerrar();
                    reporte.visualizar2(ruta + ".pdf");
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(this,
                            "No se pudo realizar el reporte si el archivo esta abierto.");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}