Example usage for org.apache.pdfbox.pdmodel.font PDType1Font getFontDescriptor

List of usage examples for org.apache.pdfbox.pdmodel.font PDType1Font getFontDescriptor

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.font PDType1Font getFontDescriptor.

Prototype

@Override
    public PDFontDescriptor getFontDescriptor() 

Source Link

Usage

From source file:com.foc.vaadin.gui.mswordGenerator.FocMSWordFontProperties.java

License:Apache License

public int getFontHeight(PDPageContentStream contentStream, PDType1Font font, int fontSize, String content)
        throws IOException {
    int start = 0;
    int end = 0;/* w ww .  ja  v  a  2 s .c  om*/
    int stringHeight = 10;
    if (content != null && !content.isEmpty()) {
        for (int i : possibleWrapPoints(content)) {
            float width = font.getStringWidth(content.substring(start, i)) / 1000 * fontSize;
            if (start < end/* && width > paragraphWidth*/) {
                contentStream.moveTextPositionByAmount(10, stringHeight);
                contentStream.drawString(toString().trim().substring(start, end));
                stringHeight += font.getFontDescriptor().getFontBoundingBox().getHeight() / 1000 * fontSize;
                start = end;
            }
            end = i;
        }
    }
    return stringHeight;
}

From source file:com.foc.vaadin.gui.mswordGenerator.MSWordUtil.java

License:Apache License

public static int getStringHeight(PDType1Font font, int fontSize, String content) {
    int stringHeight = (int) (font.getFontDescriptor().getFontBoundingBox().getHeight() / 1000 * fontSize);
    return stringHeight;
}