Example usage for com.lowagie.text FontFactory HELVETICA

List of usage examples for com.lowagie.text FontFactory HELVETICA

Introduction

In this page you can find the example usage for com.lowagie.text FontFactory HELVETICA.

Prototype

String HELVETICA

To view the source code for com.lowagie.text FontFactory HELVETICA.

Click Source Link

Document

This is a possible value of a base 14 type 1 font

Usage

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

private LinkedList<Paragraph> addChordsShape(ArrayList<String> chordsName) throws DocumentException {
    ChordsDB chordsDB = ChordsDB.getInstance();
    String notCatalogued = "";
    LinkedList<Chunk> images = new LinkedList<Chunk>();
    LinkedList<File> filesToDelete = new LinkedList<File>();
    LinkedList<Paragraph> ret = new LinkedList<Paragraph>();

    for (int i = 0; i < chordsName.size(); i++) {
        Chord chord = chordsDB.getChordByName(chordsName.get(i));
        if (chord != null) {
            ChordShapePanel csp = new ChordShapePanel(2, chord.getName(), chord.getShape());
            BufferedImage im = csp.createImage();
            try {
                File tmp = File.createTempFile("datasoul-img", ".png");
                tmp.deleteOnExit();//from w ww. j a v a 2 s .c o m
                filesToDelete.add(tmp);

                ImageIO.write(im, "png", tmp);
                Chunk c = new Chunk(Image.getInstance(tmp.getAbsolutePath()), 0, 0, false);
                images.add(c);
            } catch (IOException e) {
                JOptionPane.showMessageDialog(null, java.util.ResourceBundle
                        .getBundle("datasoul/internationalize").getString("INTERNAL ERROR: ") + e.getMessage());
            }
        } else {
            notCatalogued += chordsName.get(i);
        }
    }

    Paragraph p = new Paragraph();

    if (!images.isEmpty()) {
        for (Chunk c : images) {
            p.add(c);
        }
        p.setLeading(images.getFirst().getImage().getScaledHeight());
        p.setKeepTogether(true);
    }

    ret.add(p);

    if (!notCatalogued.equals("")) {
        p = new Paragraph(
                java.util.ResourceBundle.getBundle("datasoul/internationalize")
                        .getString("THE FOLLOWING CHORDS ARE NOT CATALOGED: ") + notCatalogued,
                FontFactory.getFont(FontFactory.HELVETICA, 8));
        ret.add(p);
    }

    for (File f : filesToDelete) {
        try {
            f.delete();
        } catch (Exception e) {
            //ignore, it will be deleted on exit
        }
    }

    return ret;
}

From source file:de.ipbhalle.metfrag.tools.renderer.WritePDFTable.java

License:Open Source License

private void addProperty(Phrase phrase, String text) {
    phrase.add(new Chunk(text + "\n", FontFactory.getFont(FontFactory.HELVETICA)));
}

From source file:de.xirp.report.ReportGenerator.java

License:Open Source License

/**
 * Returns a default formatted list for the given list type.
 * /*from w  w w.  j  ava  2 s. c  o  m*/
 * @param type
 *            The list type.
 * @return A default formatted list.
 */
private static List getList(ListType type) {
    switch (type) {
    case BULLET:
        List list = new List(false, 20);
        list.setListSymbol(new Chunk("\u2022", FontFactory.getFont( //$NON-NLS-1$
                FontFactory.HELVETICA, 12, Font.BOLD)));
        return list;
    case DASH:
        return new List(false, 20);
    case NUMBER:
        return new List(true, 20);
    }
    return null;
}

From source file:ec.edu.chyc.manejopersonal.managebean.PDFCustomExporter.java

License:Apache License

protected void createCustomFonts(String encoding) {

    if (fontName != null && FontFactory.getFont(fontName).getBaseFont() != null) {
        this.cellFont = FontFactory.getFont(fontName, encoding);
        this.facetFont = FontFactory.getFont(fontName, encoding, Font.DEFAULTSIZE, Font.BOLD);
    } else {//from w  w  w  .j a v  a 2  s .com
        this.cellFont = FontFactory.getFont(FontFactory.HELVETICA, encoding);
        this.facetFont = FontFactory.getFont(FontFactory.HELVETICA, encoding, Font.DEFAULTSIZE, Font.BOLD);
    }
    if (facetFontColor != null) {
        this.facetFont.setColor(facetFontColor);
    }
    if (facetFontSize != null) {
        this.facetFont.setSize(facetFontSize);
    }
    if (facetFontStyle != null) {
        this.facetFont.setStyle(facetFontStyle);
    }
    if (cellFontColor != null) {
        this.cellFont.setColor(cellFontColor);
    }
    if (cellFontSize != null) {
        this.cellFont.setSize(cellFontSize);
    }
    if (cellFontStyle != null) {
        this.cellFont.setStyle(cellFontStyle);
    }
}

From source file:fr.univlorraine.mondossierweb.controllers.InscriptionController.java

License:Apache License

/**
 * //from   w  ww  .j a  v  a 2 s .com
 * @param document pdf
 */
public void creerPdfCertificatScolarite(final Document document, Etudiant etudiant, Inscription inscription) {

    //configuration des fonts
    Font normal = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    Font normalBig = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    Font header = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD);

    //date
    Date d = new Date();
    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    String date = dateFormat.format(d);

    document.open();
    try {

        Signataire signataire = multipleApogeeService
                .getSignataire(configController.getCertScolCodeSignataire());

        // Ajout Bordeaux1
        if (configController.isCertScolUtiliseLogo()) {
            //ajout image test
            if (configController.getLogoUniversitePdf() != null
                    && !configController.getLogoUniversitePdf().equals("")) {
                Image imageLogo = Image.getInstance(configController.getLogoUniversitePdf());
                float scaleRatio = 40 / imageLogo.getHeight();
                float newWidth = scaleRatio * imageLogo.getWidth();
                imageLogo.scaleAbsolute(newWidth, 40);
                imageLogo.setAbsolutePosition(100, 750);
                document.add(imageLogo);
            } else if (configController.getCertScolHeaderUniv() != null
                    && !configController.getCertScolHeaderUniv().equals("")) {
                Image imageHeader = Image.getInstance(configController.getCertScolHeaderUniv());
                float scaleHeader = 600 / imageHeader.getWidth();
                float newHeigthHeader = scaleHeader * imageHeader.getHeight();
                imageHeader.scaleAbsolute(600, newHeigthHeader);
                imageHeader.setAbsolutePosition(0, 765);
                document.add(imageHeader);
            }

            if (configController.getCertScolFooter() != null
                    && !configController.getCertScolFooter().equals("")) {
                Image imageFooter = Image.getInstance(configController.getCertScolFooter());
                float scaleFooter = 600 / imageFooter.getWidth();
                float newHeigthFooter = scaleFooter * imageFooter.getHeight();
                imageFooter.scaleAbsolute(600, newHeigthFooter);
                imageFooter.setAbsolutePosition(0, 0);
                document.add(imageFooter);
            }
        }

        Paragraph pTitre = new Paragraph("\n\n" + applicationContext
                .getMessage("pdf.certificat.title", null, Locale.getDefault()).toUpperCase(), header);
        pTitre.setAlignment(Element.ALIGN_CENTER);
        document.add(pTitre);

        Paragraph pCertifie = new Paragraph("\n\n\n\n" + signataire.getQua_sig() + " "
                + applicationContext.getMessage("pdf.certificat.certifie", null, Locale.getDefault()) + "\n\n",
                normal);
        pCertifie.setAlignment(Element.ALIGN_LEFT);
        document.add(pCertifie);

        if (etudiant.getNom() != null) {
            String civ = multipleApogeeService.getCodCivFromCodInd(etudiant.getCod_ind());
            String civCertif = "";
            if (civ != null) {
                if (civ.equals("1")) {
                    civCertif = applicationContext.getMessage("pdf.certificat.civ1", null, Locale.getDefault());
                } else if (civ.equals("2")) {
                    civCertif = applicationContext.getMessage("pdf.certificat.civ2", null, Locale.getDefault());
                }
            }
            Paragraph pNom = new Paragraph(civCertif + " " + etudiant.getNom(), normalBig);
            pNom.setIndentationLeft(15);
            document.add(pNom);
        }
        if (etudiant.getCod_nne() != null) {
            Paragraph pNNE = new Paragraph(
                    "\n" + applicationContext.getMessage("pdf.certificat.id", null, Locale.getDefault()) + " : "
                            + etudiant.getCod_nne().toLowerCase(),
                    normal);
            pNNE.setAlignment(Element.ALIGN_LEFT);
            document.add(pNNE);
        }
        if (etudiant.getCod_etu() != null) {
            Paragraph p01 = new Paragraph(
                    applicationContext.getMessage("pdf.certificat.numetudiant", null, Locale.getDefault())
                            + " : " + etudiant.getCod_etu(),
                    normal);
            p01.setAlignment(Element.ALIGN_LEFT);
            document.add(p01);
        }
        if (etudiant.getDatenaissance() != null) {
            Paragraph pDateNaissance = new Paragraph(
                    applicationContext.getMessage("pdf.certificat.naissance1", null, Locale.getDefault()) + " "
                            + etudiant.getDatenaissance(),
                    normal);
            pDateNaissance.setAlignment(Element.ALIGN_LEFT);
            document.add(pDateNaissance);
        }
        if ((etudiant.getLieunaissance() != null) && (etudiant.getDepartementnaissance() != null)) {
            Paragraph pLieuNaissance = new Paragraph(
                    applicationContext.getMessage("pdf.certificat.naissance2", null, Locale.getDefault()) + " "
                            + etudiant.getLieunaissance() + " (" + etudiant.getDepartementnaissance() + ")",
                    normal);
            pLieuNaissance.setAlignment(Element.ALIGN_LEFT);
            document.add(pLieuNaissance);
        }

        String anneeEnCours = etudiantController.getAnneeUnivEnCoursToDisplay(MainUI.getCurrent());
        String inscritCertif = "";
        if (inscription.getCod_anu().equals(anneeEnCours)) {
            inscritCertif = applicationContext.getMessage("pdf.certificat.inscrit", null, Locale.getDefault());
        } else {
            inscritCertif = applicationContext.getMessage("pdf.certificat.ete.inscrit", null,
                    Locale.getDefault());
        }
        Paragraph pEstInscrit = new Paragraph("\n" + inscritCertif + " " + inscription.getCod_anu() + "\n ",
                normal);
        pEstInscrit.setAlignment(Element.ALIGN_LEFT);
        document.add(pEstInscrit);

        float[] widths = { 1.5f, 7.5f };
        PdfPTable table = new PdfPTable(widths);
        table.setWidthPercentage(100f);
        table.addCell(makeCell(applicationContext.getMessage("pdf.diplome", null, Locale.getDefault()) + " :",
                normal));
        table.addCell(makeCell(inscription.getLib_dip(), normal));
        table.addCell(
                makeCell(applicationContext.getMessage("pdf.year", null, Locale.getDefault()) + " :", normal));
        table.addCell(makeCell(inscription.getLib_etp(), normal));
        table.addCell(makeCell(
                applicationContext.getMessage("pdf.composante", null, Locale.getDefault()) + " :", normal));
        table.addCell(makeCell(inscription.getLib_comp(), normal));
        document.add(table);

        document.add(new Paragraph(" "));

        float[] widthsSignataire = { 2f, 1.3f };
        PdfPTable tableSignataire = new PdfPTable(widthsSignataire);
        tableSignataire.setWidthPercentage(100f);
        tableSignataire.addCell(makeCellSignataire("", normal));
        tableSignataire
                .addCell(makeCellSignataire(
                        applicationContext.getMessage("pdf.certificat.fait1", null, Locale.getDefault()) + " "
                                + configController.getCertScolLieuEdition() + applicationContext.getMessage(
                                        "pdf.certificat.fait2", null, Locale.getDefault())
                                + " " + date,
                        normal));
        tableSignataire.addCell(makeCellSignataire("", normal));
        tableSignataire.addCell(makeCellSignataire(signataire.getNom_sig(), normal));
        //ajout signature
        if (signataire.getImg_sig_std() != null && signataire.getImg_sig_std().length > 0) { //MODIF 09/10/2012
            tableSignataire.addCell(makeCellSignataire("", normal));
            LOG.debug(signataire.getImg_sig_std().toString());
            Image imageSignature = Image.getInstance(signataire.getImg_sig_std());

            float scaleRatio = 100 / imageSignature.getHeight();
            float newWidth = scaleRatio * imageSignature.getWidth();
            imageSignature.scaleAbsolute(newWidth, 100);
            imageSignature.setAbsolutePosition(350, 225);
            document.add(imageSignature);

        }

        document.add(tableSignataire);

        // Ajout tampon
        if (configController.getCertScolTampon() != null && !configController.getCertScolTampon().equals("")) {
            Image imageTampon = Image.getInstance(configController.getCertScolTampon());
            float scaleTampon = 100 / imageTampon.getWidth();
            float newHeigthTampon = scaleTampon * imageTampon.getHeight();
            imageTampon.scaleAbsolute(100, newHeigthTampon);
            imageTampon.setAbsolutePosition(415, 215);
            document.add(imageTampon);
        }

    } catch (BadElementException e) {
        LOG.error("Erreur  la gnration du certificat : BadElementException ", e);
    } catch (MalformedURLException e) {
        LOG.error("Erreur  la gnration du certificat : MalformedURLException ", e);
    } catch (IOException e) {
        LOG.error("Erreur  la gnration du certificat : IOException ", e);
    } catch (DocumentException e) {
        LOG.error("Erreur  la gnration du certificat : DocumentException ", e);
    }
    // step 6: fermeture du document.
    document.close();

}

From source file:gov.medicaid.services.impl.ExportServiceBean.java

License:Apache License

/**
 * Adds a centered cell to the given table.
 * /*from  w w  w.ja v  a2s  . c o m*/
 * @param table
 *            the table to add the cell to
 * @param value
 *            the value text
 */
private static void addCenterCell(PdfPTable table, String value) {
    PdfPCell val = new PdfPCell(
            new Phrase(Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7)));
    val.setBorder(Rectangle.NO_BORDER);
    val.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    table.addCell(val);
}

From source file:gov.medicaid.services.util.PDFHelper.java

License:Apache License

/**
 * Adds a cell to the given table./*from w  w w .  j  a  v  a  2 s  . co m*/
 *
 * @param table the table to add the cell to
 * @param value the value text
 */
public static void addCell(PdfPTable table, String value) {
    PdfPCell val = new PdfPCell(
            new Phrase(": " + Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7)));
    val.setBorder(Rectangle.NO_BORDER);
    val.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
    table.addCell(val);
}

From source file:gov.medicaid.services.util.PDFHelper.java

License:Apache License

/**
 * Adds a centered cell to the given table.
 *
 * @param table the table to add the cell to
 * @param value the value text/*from www  . j a  v a  2  s  .co  m*/
 */
public static void addCenterCell(PdfPTable table, String value) {
    PdfPCell val = new PdfPCell(
            new Phrase(Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7)));
    val.setBorder(Rectangle.NO_BORDER);
    val.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    val.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
    table.addCell(val);
}

From source file:include.nseer_cookie.MakePdf.java

License:Open Source License

public void make(String database, String tablename, String sql1, String sql2, String filename, int everypage,
        HttpSession session) {/*from   w ww  . j  a v a 2  s .com*/
    try {

        nseer_db aaa = new nseer_db(database);
        nseer_db demo_db = new nseer_db(database);

        ServletContext context = session.getServletContext();
        String path = context.getRealPath("/");

        Masking reader = new Masking(configFile);
        Vector columnNames = new Vector();
        Vector tables = reader.getTableNicks();
        Iterator loop = tables.iterator();
        while (loop.hasNext()) {
            String tablenick = (String) loop.next();
            columnNames = reader.getColumnNames(tablenick);
        }

        int cpage = 1; //? 

        int spage = 1;
        int ipage = everypage;
        String pagesql = sql1;

        //? 
        ResultSet pagers = demo_db.executeQuery(pagesql);
        pagers.next();
        int allCol = pagers.getInt("A");

        allpage = (int) Math.ceil((allCol + ipage - 1) / ipage);
        //
        for (int m = 1; m <= allpage; m++) {
            spage = (m - 1) * ipage;
            String sql = sql2 + " limit " + spage + "," + ipage;

            ResultSet bbb = aaa.executeQuery(sql);
            //ResultSetMetaData tt=bbb.getMetaData();       //
            int b = columnNames.size(); //
            int a = 0;
            while (bbb.next()) {
                a++;
            } //
            bbb.first(); //    ??
            Rectangle rectPageSize = new Rectangle(PageSize.A4);// 
            rectPageSize = rectPageSize.rotate();
            Document document = new Document(rectPageSize, 20, 20, 20, 20); //? Document
            PdfWriter writer = PdfWriter.getInstance(document,
                    new FileOutputStream(path + filename + m + ".pdf")); //?PDF??
            document.open(); //
            BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); //?
            com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 8,
                    com.lowagie.text.Font.NORMAL); //

            Paragraph title1 = new Paragraph("nseer ERP",
                    FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC));
            Chapter chapter1 = new Chapter(title1, 1); // ? 
            chapter1.setNumberDepth(0);

            Paragraph title11 = new Paragraph(tablename,
                    FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD));
            Section section1 = chapter1.addSection(title11); //?                                                                                            

            Table t = new Table(b, a); // ? 
            t.setPadding(1); //  
            t.setSpacing(0); //  ?
            t.setBorderWidth(1); //

            do { //
                 //
                for (int k = 0; k < b; k++) { //
                    Cell cell = new Cell(
                            new Paragraph(bbb.getString((String) columnNames.elementAt(k)), FontChinese)); //?                                    //
                    t.addCell(cell); //   ?
                    //
                } //
            } while (bbb.next()); //

            section1.add(t); //
            document.add(chapter1); // 
            document.close();

        } // ?
    } catch (Exception pp) {
        pp.printStackTrace();
    }
}

From source file:io.vertigo.dynamo.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

private void renderObject(final ExportSheet exportSheet, final Table datatable) throws BadElementException {
    final Font labelFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    final Font valueFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);

    for (final ExportField exportColumn : exportSheet.getExportFields()) {
        datatable.getDefaultCell().setBorderWidth(2);
        datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
        datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), labelFont));

        datatable.getDefaultCell().setBorderWidth(1);
        datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
        final DtField dtField = exportColumn.getDtField();
        final Object value = dtField.getDataAccessor().getValue(exportSheet.getDtObject());
        final int horizontalAlignement;
        if (value instanceof Number || value instanceof Date) {
            horizontalAlignement = Element.ALIGN_RIGHT;
        } else if (value instanceof Boolean) {
            horizontalAlignement = Element.ALIGN_CENTER;
        } else {/*from ww  w.  jav a 2 s.c  om*/
            horizontalAlignement = Element.ALIGN_LEFT;
        }
        datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement);

        String text = ExportUtil.getText(persistenceManager, referenceCache, denormCache,
                exportSheet.getDtObject(), exportColumn);
        if (text == null) {
            text = "";
        }
        datatable.addCell(new Phrase(8, text, valueFont));
    }
}