Example usage for com.lowagie.text Font Font

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

Introduction

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

Prototype


public Font(int family, float size, int style) 

Source Link

Document

Constructs a Font.

Usage

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

/**
 * Method getDefaultParagraphFont./*  w w  w  . j av  a2 s . c om*/
 * 
 * @return Font
 */
private Font getDefaultParagraphFont() {
    if (defaultParagraphFont == null) {
        defaultParagraphFont = new Font(Font.HELVETICA, 12, Font.BOLD);
    }
    return defaultParagraphFont;
}

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

private int createPasswordLetterContent(DocumentPrintContext dpc) throws ContentCreationException {
    IWBundle iwb = getIWApplicationContext().getIWMainApplication()
            .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER);
    System.out.println("Default locale: "
            + getIWApplicationContext().getApplicationSettings().getDefaultLocale().toString());
    String sAddrString = "";
    PdfContentByte cb = dpc.getPdfWriter().getDirectContent();
    Document document = dpc.getDocument();
    Locale locale = dpc.getLocale();
    PrintMessage msg = dpc.getMessage();
    // String mail_zip = iwb.getProperty("commune.mail_zip");
    // String mail_name = iwb.getProperty("commune.mail_name");

    try {/*from   w  w w. jav a2 s. c  o m*/
        sAddrString = getAddressString(dpc.getMessage().getOwner());
    } catch (Exception nouser) {
        handleNoAddressUser();
        System.err.println(nouser.getMessage());
        // nouser.printStackTrace();
        return ADDRESS_ERROR;
    }
    try {
        if (addTemplateHeader()) {
            ColumnText ct = new ColumnText(cb);
            float margin = getPointsFromMM(14);
            float lly = getPointsFromMM(297 - 22);
            float ury = lly + 60f;
            float urx = 595f - margin - 60f - 5f;
            float llx = 110f + margin;
            Phrase Ph0 = new Phrase(sAddrString, new Font(Font.HELVETICA, 12, Font.BOLD));
            ct.setSimpleColumn(Ph0, llx, lly, urx, ury, 15, Element.ALIGN_LEFT);
            ct.go();

            document.add(new Paragraph("\n\n\n\n\n\n\n"));
        }

        {

            User owner = msg.getOwner();
            HashMap tagmap = new CommuneUserTagMap(getIWApplicationContext(), owner);
            tagmap.putAll(getMessageTagMap(msg, locale));

            XmlPeer date = new XmlPeer(ElementTags.CHUNK, "date");
            date.setContent(new IWTimestamp().getDateString("dd.MM.yyyy"));
            tagmap.put(date.getAlias(), date);
            System.out.println("Date tag: " + date.getTag());

            String letterUrl = getXMLLetterUrl(iwb, locale, "password_letter.xml");
            if (msg.getBody().indexOf("|") > 0) {
                StringTokenizer tokenizer = new StringTokenizer(msg.getBody(), "|");
                XmlPeer peer = new XmlPeer(ElementTags.ITEXT, "letter");
                tagmap.put(peer.getAlias(), peer);

                if (tokenizer.hasMoreTokens()) {
                    peer = new XmlPeer(ElementTags.CHUNK, "username");
                    peer.setContent(tokenizer.nextToken());
                    tagmap.put(peer.getAlias(), peer);
                }
                if (tokenizer.hasMoreTokens()) {
                    peer = new XmlPeer(ElementTags.CHUNK, "password");
                    peer.setContent(tokenizer.nextToken());
                    tagmap.put(peer.getAlias(), peer);
                }

            }
            javax.xml.parsers.SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
            SAXmyHandler handler = new SAXmyHandler(document, tagmap);
            handler.setControlOpenClose(false);

            parser.parse(letterUrl, handler);
        }
    } catch (Exception e) {
        throw new ContentCreationException(e);
    }

    return 0;
}

From source file:it.prato.comune.tolomeo.web.TolomeoPrintPDFServlet.java

License:Open Source License

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    LogInterface logger = getLogger(request);

    String titolo = request.getParameter("titolo");
    String descrizione = request.getParameter("descrizione");
    String scala = request.getParameter("scala");
    String mapx = request.getParameter("mapx");
    String mapy = request.getParameter("mapy");
    //creo URL alla mappa
    URL urlMappa = new URL(URLDecoder.decode(request.getParameter("urlMappa"), "UTF-8"));
    URI uriMappa = null;/*from  www.j av  a 2 s  .  c om*/
    try {
        uriMappa = new URI(urlMappa.getProtocol(), null, urlMappa.getHost(), urlMappa.getPort(),
                urlMappa.getPath(), urlMappa.getQuery() + "&mode=map&scale=" + scala + "&mapxy=" + mapx + "+"
                        + mapy + "&map_size=500 500",
                null);
        logger.info("URI di stampa mappa: " + uriMappa);
    } catch (URISyntaxException e) {
        logger.error("URI errore di sintassi", e);
    }

    Font BOLD15 = new Font(Font.HELVETICA, 15, Font.BOLD);
    Font FONT12 = new Font(Font.HELVETICA, 12, Font.NORMAL);
    Font FONT10 = new Font(Font.HELVETICA, 10, Font.NORMAL);

    Document doc = new Document();
    ;
    PdfWriter pdf = null;
    Paragraph par = new Paragraph();

    try {

        //creo il PDF
        response.setContentType("application/pdf");
        pdf = PdfWriter.getInstance(doc, response.getOutputStream());

        //attributi file
        doc.addTitle("Mappa di Prato");
        doc.addAuthor("Comune di Prato");
        doc.open();

        //intestazione
        par.setAlignment(Paragraph.ALIGN_CENTER);
        print("Comune di Prato", BOLD15, par, doc);
        print(titolo, FONT10, par, doc);
        print("", FONT10, par, doc);

        //mappa
        Image mappa = Image.getInstance(uriMappa.toURL());
        mappa.setAlignment(Image.MIDDLE);
        mappa.setBorder(Rectangle.BOX);
        mappa.setBorderWidth(1f);
        doc.add(mappa);

    } catch (Exception e) {
        logger.error("Errore durante la creazione del PDF", e);
        printErr(doc);
    } finally {
        doc.close();
        pdf.close();
        response.getOutputStream().close();
    }
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static Paragraph setParrafoPDF(String texto, int tipo, int tamanio, int estilo, int alineacion) {
    Paragraph parrafo = new Paragraph(texto, new Font(tipo, tamanio, estilo));
    parrafo.setAlignment(alineacion);/*  ww w  .  j a  v  a 2  s .  c o  m*/
    return parrafo;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);//from www .  ja va2  s  .c  o  m
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        int padding) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);/* www .j  ava  2s  . c  om*/
    celda.setPadding(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        Color color) {//  ww  w  .  ja v a2s.  co m
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);
    celda.setBackgroundColor(color);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        Color color, int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setPadding(padding);/*w  w w .ja v  a 2  s. c o m*/
    celda.setColspan(colspan);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);
    celda.setBackgroundColor(color);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setPadding(padding);//from w  w  w  .  j  a  va2 s  .  co  m
    celda.setColspan(colspan);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setFilaBlanco(int colSpan, int alto) {
    PdfPCell celda = new PdfPCell(new Paragraph(" ", new Font(Font.HELVETICA, alto, Font.NORMAL)));
    celda.setBorderWidth(0);/* w w  w .j av  a  2  s . c  o m*/
    celda.setPadding(0);
    celda.setColspan(colSpan);
    return celda;
}