corner.orm.tapestry.pdf.PdfUtils.java Source code

Java tutorial

Introduction

Here is the source code for corner.orm.tapestry.pdf.PdfUtils.java

Source

// Copyright 2007 the original author or authors.
// site: http://www.bjmaxinfo.com
// file: $Id: PdfUtils.java 3919 2008-01-16 04:36:52Z xf $
// created at:2007-07-31
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package corner.orm.tapestry.pdf;

import java.io.IOException;

import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.pdf.BaseFont;

/**
 * pdf
 * 
 * @author <a href="mailto:jun.tsai@bjmaxinfo.com">Jun Tsai</a>
 * @author <a href=mailto:Ghostbb@bjmaxinfo.com>Ghostbb</a>
 * @version $Revision: 3919 $
 * @since 2.3.7
 */
public final class PdfUtils {

    /**
     * 
     * @return
     */
    public static final BaseFont createSongLightBaseFont() {
        BaseFont bfChinese;
        try {
            bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
            return bfChinese;
        } catch (DocumentException e) {
            throw new PdfSystemException(e);
        } catch (IOException e) {
            throw new PdfSystemException(e);
        }

    }

    /**
     * .
     * @param size ?
     * @return
     */
    public static final Font createSongLightFont(int size) {
        BaseFont bf = createSongLightBaseFont();
        if (size <= 0) {
            size = Font.UNDEFINED;
        }
        Font font = new Font(bf, size);
        return font;

    }

    /**
     * ()
     * @param size
     * @return
     */
    public static final Font createHeaderSongLightFont(int size) {
        BaseFont bf = createSongLightBaseFont();
        if (size <= 0) {
            size = Font.UNDEFINED;
        }
        Font font = new Font(bf, size, Font.BOLD);
        return font;
    }

}