Example usage for com.lowagie.text Font BOLDITALIC

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

Introduction

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

Prototype

int BOLDITALIC

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

Click Source Link

Document

this is a possible style.

Usage

From source file:org.eclipse.birt.report.engine.emitter.pdf.PDFPage.java

License:Open Source License

private void setTextMatrix(PdfContentByte cb, FontInfo fi, float x, float y) {
    cb.concatCTM(1, 0, 0, 1, x, y);//w  w  w .  j a  v  a  2 s  .  co  m
    if (!fi.getSimulation()) {
        cb.setTextMatrix(0, 0);
        return;
    }
    switch (fi.getFontStyle()) {
    case Font.ITALIC: {
        simulateItalic(cb);
        break;
    }
    case Font.BOLD: {
        simulateBold(cb, fi.getFontWeight());
        break;
    }
    case Font.BOLDITALIC: {
        simulateBold(cb, fi.getFontWeight());
        simulateItalic(cb);
        break;
    }
    }
}

From source file:org.eclipse.birt.report.engine.emitter.postscript.PostscriptWriter.java

License:Open Source License

public void drawString(String str, float x, float y, FontInfo fontInfo, float letterSpacing, float wordSpacing,
        Color color, boolean linethrough, boolean overline, boolean underline, CSSValue align) {
    y = transformY(y);/*from  w ww.  j  a  v  a2s. c om*/
    String text = str;
    boolean needSimulateItalic = false;
    boolean needSimulateBold = false;
    boolean hasSpace = wordSpacing != 0 || letterSpacing != 0;
    float offset = 0;
    if (fontInfo != null) {
        float fontSize = fontInfo.getFontSize();
        int fontStyle = fontInfo.getFontStyle();
        if (fontInfo.getSimulation()) {
            if (fontStyle == Font.BOLD || fontStyle == Font.BOLDITALIC) {
                offset = (float) (fontSize * Math.log10(fontSize) / 100);
                needSimulateBold = true;
            }
            if (fontStyle == Font.ITALIC || fontStyle == Font.BOLDITALIC) {
                needSimulateItalic = true;
            }
        }
        BaseFont baseFont = fontInfo.getBaseFont();
        String fontName = baseFont.getPostscriptFontName();
        text = applyFont(fontName, fontStyle, fontSize, text);
    }
    outputColor(color);
    out.print(x + " " + y + " ");
    if (hasSpace)
        out.print(wordSpacing + " " + letterSpacing + " ");
    out.print(text + " ");
    if (needSimulateBold)
        out.print(offset + " ");
    String command = getCommand(hasSpace, needSimulateBold, needSimulateItalic);
    out.println(command);
}

From source file:org.eclipse.birt.report.engine.layout.area.impl.TextArea.java

License:Open Source License

public int getWidth() {
    int fontStyle = fi.getFontStyle();
    //get width for text with simulated italic font.
    if (fi.getSimulation() && (Font.ITALIC == fontStyle || Font.BOLDITALIC == fontStyle)) {
        width = (int) (width + height * EmitterUtil.getItalicHorizontalCoefficient());
    }// w w w.  j  av a 2  s .  c  o m
    return width;
}

From source file:org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.java

License:Open Source License

/**
 * If the BaseFont can NOT find the correct physical glyph, we need to
 * simulate the proper style for the font. The "simulate" flag will be set
 * if we need to simulate it.//from   w ww . j a  va 2 s.c  om
 */
private boolean needSimulate(BaseFont font) {
    if (fontStyle == Font.NORMAL) {
        return false;
    }

    String[][] fullNames = bf.getFullFontName();
    String fullName = getEnglishName(fullNames);
    String lcf = fullName.toLowerCase();

    int fs = Font.NORMAL;
    if (lcf.indexOf("bold") != -1) {
        fs |= Font.BOLD;
    }
    if (lcf.indexOf("italic") != -1 || lcf.indexOf("oblique") != -1) {
        fs |= Font.ITALIC;
    }
    if ((fontStyle & Font.BOLDITALIC) == fs) {
        if (fontWeight > 400 && fontWeight != 700) {
            // not a regular bold font.
            return true;
        } else {
            return false;
        }
    }
    return true;
}

From source file:org.eclipse.birt.report.engine.layout.pdf.font.FontInfo.java

License:Open Source License

public int getItalicAdjust() {
    // get width for text with simulated italic font.
    if (simulation && (Font.ITALIC == fontStyle || Font.BOLDITALIC == fontStyle)) {
        return (int) (fontHeight * EmitterUtil.getItalicHorizontalCoefficient());
    }/*w  ww. j a  v a 2  s  .c om*/
    return 0;
}

From source file:org.eclipse.birt.report.engine.nLayout.area.impl.TextArea.java

License:Open Source License

public int getWidth() {
    int fontStyle = style.getFontInfo().getFontStyle();
    // get width for text with simulated italic font.
    if (style.getFontInfo().getSimulation() && (Font.ITALIC == fontStyle || Font.BOLDITALIC == fontStyle)) {
        width = (int) (width + height * EmitterUtil.getItalicHorizontalCoefficient());
    }/* www. j ava 2 s . com*/
    return width;
}

From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java

License:Open Source License

private void addImageSection(Document d, String mapName, Long currentSessionId)
        throws BadElementException, MalformedURLException, IOException, DocumentException {

    Image mapImage = Image.getInstance(mapsHome + mapName + "_T_" + currentSessionId + ".png");
    mapImage.scaleToFit(550, 413);//from w  w  w .j a v  a  2s  .co  m
    mapImage.setAlignment(Image.ALIGN_LEFT);

    // scale
    Image scaleImage = Image.getInstance(mapsHome + "scale.jpg");
    scaleImage.scaleToFit(30, 150);
    scaleImage.setAlignment(Image.ALIGN_RIGHT);

    Paragraph images = new Paragraph();
    images.setAlignment(Paragraph.ALIGN_RIGHT);

    //upper scale leyend
    images.add(new Chunk(this.getI18nString("pdfReport.scaleUpper") + "\n\n\n\n\n\n\n",
            new Font(Font.COURIER, 8, Font.BOLDITALIC)));
    // Map
    images.add(new Chunk(mapImage, 1F, 1F));
    // Scale
    images.add(new Chunk(scaleImage, 1F, 1F));
    // lower scale leyend
    images.add(new Chunk("\n" + this.getI18nString("pdfReport.scaleLower") + "\n",
            new Font(Font.COURIER, 8, Font.BOLDITALIC)));

    d.add(images);
}

From source file:org.oscarehr.phr.web.PHRUserManagementAction.java

License:Open Source License

public ByteArrayOutputStream generateUserRegistrationLetter(String demographicNo, String username,
        String password) throws Exception {
    log.debug("Demographic " + demographicNo + " username " + username + " password " + password);
    DemographicDao demographicDao = (DemographicDao) SpringUtils.getBean("demographicDao");
    Demographic demographic = demographicDao.getDemographic(demographicNo);

    final String PAGESIZE = "printPageSize";
    Document document = new Document();

    ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
    PdfWriter writer = null;/*from   w ww .j  a va2 s .  c  o  m*/

    try {
        writer = PdfWriter.getInstance(document, baosPDF);

        String title = "TITLE";
        String template = "MyOscarLetterHead.pdf";

        Properties printCfg = getCfgProp();

        String[] cfgVal = null;
        StringBuilder tempName = null;

        // get the print prop values

        Properties props = new Properties();
        props.setProperty("letterDate", UtilDateUtilities.getToday("yyyy-MM-dd"));
        props.setProperty("name", demographic.getFirstName() + " " + demographic.getLastName());
        props.setProperty("dearname", demographic.getFirstName() + " " + demographic.getLastName());
        props.setProperty("address", demographic.getAddress());
        props.setProperty("city", demographic.getCity() + ", " + demographic.getProvince());
        props.setProperty("postalCode", demographic.getPostal());
        props.setProperty("credHeading", "MyOscar User Account Details");
        props.setProperty("username", "Username: " + username);
        props.setProperty("password", "Password: " + password);
        //Temporary - the intro will change to be dynamic
        props.setProperty("intro",
                "We are pleased to provide you with a log in and password for your new MyOSCAR Personal Health Record. This account will allow you to connect electronically with our clinic. Please take a few minutes to review the accompanying literature for further information.We look forward to you benefiting from this service.");

        document.addTitle(title);
        document.addSubject("");
        document.addKeywords("pdf, itext");
        document.addCreator("OSCAR");
        document.addAuthor("");
        document.addHeader("Expires", "0");

        Rectangle pageSize = PageSize.LETTER;

        document.setPageSize(pageSize);
        document.open();

        // create a reader for a certain document
        String propFilename = oscar.OscarProperties.getInstance().getProperty("pdfFORMDIR", "") + "/"
                + template;
        PdfReader reader = null;
        try {
            reader = new PdfReader(propFilename);
            log.debug("Found template at " + propFilename);
        } catch (Exception dex) {
            log.debug("change path to inside oscar from :" + propFilename);
            reader = new PdfReader("/oscar/form/prop/" + template);
            log.debug("Found template at /oscar/form/prop/" + template);
        }

        // retrieve the total number of pages
        int n = reader.getNumberOfPages();
        // retrieve the size of the first page
        Rectangle pSize = reader.getPageSize(1);
        float width = pSize.getWidth();
        float height = pSize.getHeight();
        log.debug("Width :" + width + " Height: " + height);

        PdfContentByte cb = writer.getDirectContent();
        ColumnText ct = new ColumnText(cb);
        int fontFlags = 0;

        document.newPage();
        PdfImportedPage page1 = writer.getImportedPage(reader, 1);
        cb.addTemplate(page1, 1, 0, 0, 1, 0, 0);

        BaseFont bf; // = normFont;
        String encoding;

        cb.setRGBColorStroke(0, 0, 255);

        String[] fontType;
        for (Enumeration e = printCfg.propertyNames(); e.hasMoreElements();) {
            tempName = new StringBuilder(e.nextElement().toString());
            cfgVal = printCfg.getProperty(tempName.toString()).split(" *, *");

            if (cfgVal[4].indexOf(";") > -1) {
                fontType = cfgVal[4].split(";");
                if (fontType[1].trim().equals("italic"))
                    fontFlags = Font.ITALIC;
                else if (fontType[1].trim().equals("bold"))
                    fontFlags = Font.BOLD;
                else if (fontType[1].trim().equals("bolditalic"))
                    fontFlags = Font.BOLDITALIC;
                else
                    fontFlags = Font.NORMAL;
            } else {
                fontFlags = Font.NORMAL;
                fontType = new String[] { cfgVal[4].trim() };
            }

            if (fontType[0].trim().equals("BaseFont.HELVETICA")) {
                fontType[0] = BaseFont.HELVETICA;
                encoding = BaseFont.CP1252; //latin1 encoding
            } else if (fontType[0].trim().equals("BaseFont.HELVETICA_OBLIQUE")) {
                fontType[0] = BaseFont.HELVETICA_OBLIQUE;
                encoding = BaseFont.CP1252;
            } else if (fontType[0].trim().equals("BaseFont.ZAPFDINGBATS")) {
                fontType[0] = BaseFont.ZAPFDINGBATS;
                encoding = BaseFont.ZAPFDINGBATS;
            } else {
                fontType[0] = BaseFont.COURIER;
                encoding = BaseFont.CP1252;
            }

            bf = BaseFont.createFont(fontType[0], encoding, BaseFont.NOT_EMBEDDED);

            // write in a rectangle area
            if (cfgVal.length >= 9) {
                Font font = new Font(bf, Integer.parseInt(cfgVal[5].trim()), fontFlags);
                ct.setSimpleColumn(Integer.parseInt(cfgVal[1].trim()),
                        (height - Integer.parseInt(cfgVal[2].trim())), Integer.parseInt(cfgVal[7].trim()),
                        (height - Integer.parseInt(cfgVal[8].trim())), Integer.parseInt(cfgVal[9].trim()),
                        (cfgVal[0].trim().equals("left") ? Element.ALIGN_LEFT
                                : (cfgVal[0].trim().equals("right") ? Element.ALIGN_RIGHT
                                        : Element.ALIGN_CENTER)));

                ct.setText(new Phrase(12, props.getProperty(tempName.toString(), ""), font));
                ct.go();
                continue;
            }

            // draw line directly
            if (tempName.toString().startsWith("__$line")) {
                cb.setRGBColorStrokeF(0f, 0f, 0f);
                cb.setLineWidth(Float.parseFloat(cfgVal[4].trim()));
                cb.moveTo(Float.parseFloat(cfgVal[0].trim()), Float.parseFloat(cfgVal[1].trim()));
                cb.lineTo(Float.parseFloat(cfgVal[2].trim()), Float.parseFloat(cfgVal[3].trim()));
                // stroke the lines
                cb.stroke();
                // write text directly

            } else if (tempName.toString().startsWith("__")) {
                cb.beginText();
                cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim()));
                cb.showTextAligned(
                        (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT
                                : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT
                                        : PdfContentByte.ALIGN_CENTER)),
                        (cfgVal.length >= 7 ? (cfgVal[6].trim()) : props.getProperty(tempName.toString(), "")),
                        Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0);

                cb.endText();
            } else if (tempName.toString().equals("forms_promotext")) {
                if (OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT") != null) {
                    cb.beginText();
                    cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim()));
                    cb.showTextAligned(
                            (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT
                                    : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT
                                            : PdfContentByte.ALIGN_CENTER)),
                            OscarProperties.getInstance().getProperty("FORMS_PROMOTEXT"),
                            Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())),
                            0);

                    cb.endText();
                }
            } else { // write prop text

                cb.beginText();
                cb.setFontAndSize(bf, Integer.parseInt(cfgVal[5].trim()));
                cb.showTextAligned(
                        (cfgVal[0].trim().equals("left") ? PdfContentByte.ALIGN_LEFT
                                : (cfgVal[0].trim().equals("right") ? PdfContentByte.ALIGN_RIGHT
                                        : PdfContentByte.ALIGN_CENTER)),
                        (cfgVal.length >= 7 ? ((props.getProperty(tempName.toString(), "").equals("") ? ""
                                : cfgVal[6].trim())) : props.getProperty(tempName.toString(), "")),
                        Integer.parseInt(cfgVal[1].trim()), (height - Integer.parseInt(cfgVal[2].trim())), 0);

                cb.endText();
            }
        }

    } catch (DocumentException dex) {
        baosPDF.reset();
        throw dex;
    } finally {
        if (document != null)
            document.close();
        if (writer != null)
            writer.close();
    }
    return baosPDF;
}

From source file:org.pz.platypus.plugin.html.HtmlFont.java

License:Open Source License

/**
 * iText font style captures bold, italic, strikethru, underline. Since we handle
 * strikethrough and underline ourselves, we use it to communicate italic and bold
 * only. This computation done here.//  www . j  a va  2s . co  m
 *
 * @return the iText Style
 */
int computeItextStyle() {
    int style = 0;

    if (italics && bold) {
        style |= Font.BOLDITALIC;
    } else if (italics) {
        style |= Font.ITALIC;
    } else if (bold) {
        style |= Font.BOLD;
    }

    return (style);
}

From source file:org.pz.platypus.plugin.pdf.PdfFontFactory.java

License:Open Source License

/**
 * iText font style captures bold, italic, strikethru, underline. Since we handle
 * strikethrough and underline ourselves, we use it to communicate italic and bold
 * only. This computation done here./*from   ww  w .j  ava 2s  .  c om*/
 *
 * @param f the PdfFont whose style is being checked
 * @return the iText Style
 */
int computeItextStyle(PdfFont f) {
    int style = 0;

    if (f.getItalics() && f.getBold()) {
        style |= Font.BOLDITALIC;
    } else if (f.getItalics()) {
        style |= Font.ITALIC;
    } else if (f.getBold()) {
        style |= Font.BOLD;
    }

    return (style);
}