Example usage for com.lowagie.text Font HELVETICA

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

Introduction

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

Prototype

int HELVETICA

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

Click Source Link

Document

a possible value of a font family.

Usage

From source file:binky.reportrunner.engine.renderers.exporters.HTMLExporter.java

License:Open Source License

@Override
public void export(ResultSet resultSet, String label, OutputStream outputStream) throws ExportException {
    try {//from  ww  w  . j  a  va2s. c om
        Document document = new Document();
        HtmlWriter.getInstance(document, outputStream);

        // open the document object
        document.open();

        ResultSetMetaData metaData = resultSet.getMetaData();
        Table table = new Table(metaData.getColumnCount());
        for (int i = 1; i <= metaData.getColumnCount(); i++) {
            Paragraph para = new Paragraph(metaData.getColumnName(i), new Font(Font.HELVETICA, 10, Font.BOLD));
            Cell cell = new Cell(para);
            table.addCell(cell);
        }

        while (resultSet.next()) {
            for (int i = 1; i <= metaData.getColumnCount(); i++) {
                Paragraph para = new Paragraph("" + resultSet.getObject(i),
                        new Font(Font.HELVETICA, 10, Font.NORMAL));
                Cell cell = new Cell(para);
                table.addCell(cell);
            }

        }
        document.add(table);
        document.close();
    } catch (DocumentException e) {
        throw new ExportException(e.getMessage(), e);
    } catch (SQLException e) {
        throw new ExportException(e.getMessage(), e);
    }
}

From source file:binky.reportrunner.engine.renderers.exporters.PDFExporter.java

License:Open Source License

@Override
public void export(ResultSet resultSet, String label, OutputStream outputStream) throws ExportException {
    try {/*ww  w  . j a v a  2  s  . co m*/
        Document document = new Document();
        PdfWriter.getInstance(document, outputStream);

        // open the document object
        document.open();

        ResultSetMetaData metaData = resultSet.getMetaData();
        PdfPTable table = new PdfPTable(metaData.getColumnCount());
        for (int i = 1; i <= metaData.getColumnCount(); i++) {
            Paragraph para = new Paragraph(metaData.getColumnName(i), new Font(Font.HELVETICA, 10, Font.BOLD));
            PdfPCell cell = new PdfPCell(para);
            table.addCell(cell);
        }

        while (resultSet.next()) {
            for (int i = 1; i <= metaData.getColumnCount(); i++) {
                Paragraph para = new Paragraph("" + resultSet.getObject(i),
                        new Font(Font.HELVETICA, 10, Font.NORMAL));
                PdfPCell cell = new PdfPCell(para);
                table.addCell(cell);
            }

        }
        document.add(table);
        document.close();
    } catch (DocumentException e) {
        throw new ExportException(e.getMessage(), e);
    } catch (SQLException e) {
        throw new ExportException(e.getMessage(), e);
    }
}

From source file:classroom.filmfestival_a.Movies03.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // step 1//from   w w  w.  j  a  v a  2s .  c o  m
    Document document = new Document();
    try {
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();
        Paragraph p;
        Chunk c;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        for (FilmTitle movie : results) {
            p = new Paragraph(30);
            c = new Chunk(movie.getTitle(), bold);
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ")", italic);
            p.add(c);
            document.add(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            document.add(list);
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_a.Movies04.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // step 1/*from w ww  .ja v a 2s.  c  o  m*/
    Document document = new Document();
    try {
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();
        Paragraph p;
        Chunk c;
        Anchor a;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        Font underlined = new Font(Font.HELVETICA, 12, Font.UNDERLINE, Color.BLUE);
        for (FilmTitle movie : results) {
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            a = new Anchor("IMDB", underlined);
            a.setReference("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(a);
            document.add(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            document.add(list);
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_a.Movies05.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // step 1/* w w  w.  j  ava  2  s  .com*/
    Document document = new Document();
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter writer = PdfWriter.getInstance(document, os);
        writer.setPageEvent(new Movies05().new Ellipse());
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();
        Paragraph p;
        Chunk c;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        Font white = new Font(Font.HELVETICA, 12, Font.BOLD | Font.ITALIC, Color.WHITE);
        for (FilmTitle movie : results) {
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB", white);
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            c.setGenericTag("ellipse");
            p.add(c);
            document.add(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            document.add(list);
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_a.Movies06.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // step 1//from  w  w  w .j a  va  2  s  .c  o  m
    Document document = new Document();
    try {
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();
        File f;
        Image img;
        Paragraph p;
        Chunk c;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                img = Image.getInstance(f.getPath());
                document.add(img);
            }
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            document.add(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            document.add(list);
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_a.Movies07.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // step 1//from  w  ww.  j av a  2s.  c  o  m
    Document document = new Document();
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter writer = PdfWriter.getInstance(document, os);
        writer.setStrictImageSequence(true);
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();
        File f;
        Image img;
        Paragraph p;
        Chunk c;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                img = Image.getInstance(f.getPath());
                document.add(img);
            }
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            document.add(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            document.add(list);
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_a.Movies08.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // step 1//from   w ww.  j  ava2s  . co  m
    Document document = new Document();
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter writer = PdfWriter.getInstance(document, os);
        writer.setStrictImageSequence(true);
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();
        File f;
        Image img;
        Paragraph p;
        Chunk c;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                img = Image.getInstance(f.getPath());
                img.scaleToFit(72, 144);
                document.add(img);
            }
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            document.add(p);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }
            document.add(list);
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_b.Movies09.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // step 1//  ww  w .ja  v  a2  s  . co m
    Document document = new Document();
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter writer = PdfWriter.getInstance(document, os);
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();

        ColumnText column = new ColumnText(writer.getDirectContent());
        column.setSimpleColumn(document.left(), document.bottom(), document.right(), document.top());

        float pos;
        int status;
        File f;
        Image img;
        Paragraph p;
        Chunk c;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                img = Image.getInstance(f.getPath());
                img.setWidthPercentage(0);
                img.scaleToFit(72, 144);
            } else {
                img = null;
            }
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }

            if (img != null)
                column.addElement(img);
            column.addElement(p);
            column.addElement(list);
            pos = column.getYLine();
            status = column.go(true);
            if (ColumnText.hasMoreText(status)) {
                document.newPage();
                column.setText(null);
                column.setYLine(document.top());
            } else {
                column.setYLine(pos);
            }
            if (img != null)
                column.addElement(img);
            column.addElement(p);
            column.addElement(list);
            column.addElement(Chunk.NEWLINE);
            column.go();
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}

From source file:classroom.filmfestival_b.Movies10.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {

    // step 1//w w w. j a  v a 2s  .co m
    Document document = new Document();
    float middle = (document.right() + document.left()) / 2;
    float columns[][] = { { document.left(), document.bottom(), middle - 12, document.top() },
            { middle + 12, document.bottom(), document.right(), document.top() } };
    try {
        // step 2
        OutputStream os = new FileOutputStream(RESULT);
        PdfWriter writer = PdfWriter.getInstance(document, os);
        // step 3
        document.open();
        // step 4
        Session session = (Session) MySessionFactory.currentSession();
        Query q = session.createQuery("from FilmTitle order by title");
        java.util.List<FilmTitle> results = q.list();

        ColumnText column = new ColumnText(writer.getDirectContent());
        column.setSimpleColumn(columns[0][0], columns[0][1], columns[0][2], columns[0][3]);

        float pos;
        int status;
        int ccount = 0;
        File f;
        Image img;
        Paragraph p;
        Chunk c;
        Font bold = new Font(Font.HELVETICA, 12, Font.BOLD);
        Font italic = new Font(Font.HELVETICA, 12, Font.ITALIC);
        for (FilmTitle movie : results) {
            f = new File("resources/classroom/filmposters/" + movie.getFilmId() + ".jpg");
            if (f.exists()) {
                img = Image.getInstance(f.getPath());
                img.setWidthPercentage(0);
                img.scaleToFit(72, 144);
            } else {
                img = null;
            }
            p = new Paragraph(20);
            c = new Chunk(movie.getTitle(), bold);
            c.setAnchor("http://cinema.lowagie.com/titel.php?id=" + movie.getFilmId());
            p.add(c);
            c = new Chunk(" (" + movie.getYear() + ") ", italic);
            p.add(c);
            c = new Chunk("IMDB");
            c.setAnchor("http://www.imdb.com/title/tt" + movie.getImdb());
            p.add(c);
            Set<DirectorName> directors = movie.getDirectorNames();
            List list = new List();
            for (DirectorName director : directors) {
                list.add(director.getName());
            }

            if (img != null)
                column.addElement(img);
            column.addElement(p);
            column.addElement(list);
            pos = column.getYLine();
            status = column.go(true);
            if (ColumnText.hasMoreText(status)) {
                column.setText(null);
                ccount++;
                if (ccount > 1) {
                    ccount = 0;
                    document.newPage();
                    column.setSimpleColumn(columns[0][0], columns[0][1], columns[0][2], columns[0][3]);
                } else {
                    column.setSimpleColumn(columns[1][0], columns[1][1], columns[1][2], columns[1][3]);
                }
            } else {
                column.setYLine(pos);
            }
            if (img != null)
                column.addElement(img);
            column.addElement(p);
            column.addElement(list);
            column.addElement(Chunk.NEWLINE);
            column.go();
        }
        // step 5
        document.close();
    } catch (IOException e) {
        LOGGER.error("IOException: ", e);
    } catch (DocumentException e) {
        LOGGER.error("DocumentException: ", e);
    }
}