当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.rotate方法代码示例

本文整理汇总了Java中com.lowagie.text.Rectangle.rotate方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.rotate方法的具体用法?Java Rectangle.rotate怎么用?Java Rectangle.rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lowagie.text.Rectangle的用法示例。


在下文中一共展示了Rectangle.rotate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDoc

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
public void createDoc() throws FileNotFoundException{
	 /** 创建Document对象(word文档)  */
       Rectangle rectPageSize = new Rectangle(PageSize.A4);
       rectPageSize = rectPageSize.rotate();
       // 创建word文档,并设置纸张的大小
       doc = new Document(PageSize.A4);
       file=new File(path+docFileName);
       fileOutputStream=new FileOutputStream(file);
       /** 建立一个书写器与document对象关联,通过书写器可以将文档写入到输出流中 */
       RtfWriter2.getInstance(doc, fileOutputStream );
       doc.open();
       //设置页边距,上、下25.4毫米,即为72f,左、右31.8毫米,即为90f  
       doc.setMargins(90f, 90f, 72f, 72f);
       //设置标题字体样式,粗体、二号、华文中宋  
       tfont  = DocStyleUtils.setFontStyle("华文中宋", 22f, Font.BOLD);  
       //设置正文内容的字体样式,常规、三号、仿宋_GB2312  
       bfont = DocStyleUtils.setFontStyle("仿宋_GB2312", 16f, Font.NORMAL);
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:19,代码来源:DocExportUtil.java

示例2: getPageSizeWithRotation

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
 * Gets the rotated page from a page dictionary.
 * @param page the page dictionary
 * @return the rotated page
 */
public Rectangle getPageSizeWithRotation(PdfDictionary page) {
    Rectangle rect = getPageSize(page);
    int rotation = getPageRotation(page);
    while (rotation > 0) {
        rect = rect.rotate();
        rotation -= 90;
    }
    return rect;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:15,代码来源:PdfReader.java

示例3: getAppearance

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
PdfAppearance getAppearance(PdfDictionary merged, String text, String fieldName) throws IOException, DocumentException {
    topFirst = 0;
    TextField tx = null;
    if (fieldCache == null || !fieldCache.containsKey(fieldName)) {
        tx = new TextField(writer, null, null);
        tx.setExtraMargin(extraMarginLeft, extraMarginTop);
        tx.setBorderWidth(0);
        tx.setSubstitutionFonts(substitutionFonts);
        decodeGenericDictionary(merged, tx);
        //rect
        PdfArray rect = merged.getAsArray(PdfName.RECT);
        Rectangle box = PdfReader.getNormalizedRectangle(rect);
        if (tx.getRotation() == 90 || tx.getRotation() == 270)
            box = box.rotate();
        tx.setBox(box);
        if (fieldCache != null)
            fieldCache.put(fieldName, tx);
    }
    else {
        tx = (TextField)fieldCache.get(fieldName);
        tx.setWriter(writer);
    }
    PdfName fieldType = merged.getAsName(PdfName.FT);
    if (PdfName.TX.equals(fieldType)) {
        tx.setText(text);
        return tx.getAppearance();
    }
    if (!PdfName.CH.equals(fieldType))
        throw new DocumentException("An appearance was requested without a variable text field.");
    PdfArray opt = merged.getAsArray(PdfName.OPT);
    int flags = 0;
    PdfNumber nfl = merged.getAsNumber(PdfName.FF);
    if (nfl != null)
        flags = nfl.intValue();
    if ((flags & PdfFormField.FF_COMBO) != 0 && opt == null) {
        tx.setText(text);
        return tx.getAppearance();
    }
    if (opt != null) {
        String choices[] = new String[opt.size()];
        String choicesExp[] = new String[opt.size()];
        for (int k = 0; k < opt.size(); ++k) {
            PdfObject obj = opt.getPdfObject(k);
            if (obj.isString()) {
                choices[k] = choicesExp[k] = ((PdfString)obj).toUnicodeString();
            }
            else {
                PdfArray a = (PdfArray) obj;
                choicesExp[k] = a.getAsString(0).toUnicodeString();
                choices[k] = a.getAsString(1).toUnicodeString();
            }
        }
        if ((flags & PdfFormField.FF_COMBO) != 0) {
            for (int k = 0; k < choices.length; ++k) {
                if (text.equals(choicesExp[k])) {
                    text = choices[k];
                    break;
                }
            }
            tx.setText(text);
            return tx.getAppearance();
        }
        int idx = 0;
        for (int k = 0; k < choicesExp.length; ++k) {
            if (text.equals(choicesExp[k])) {
                idx = k;
                break;
            }
        }
        tx.setChoices(choices);
        tx.setChoiceExports(choicesExp);
        tx.setChoiceSelection(idx);
    }
    PdfAppearance app = tx.getListAppearance();
    topFirst = tx.getTopFirst();
    return app;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:78,代码来源:AcroFields.java

示例4: guessFormat

import com.lowagie.text.Rectangle; //导入方法依赖的package包/类
/**
 * This method tries to fit the <code>Rectangle pageSize</code> to one of the predefined PageSize rectangles.
 * If a match is found the pageWidth and pageHeight will be set according to values determined from files
 * generated by MS Word2000 and OpenOffice 641. If no match is found the method will try to match the rotated
 * Rectangle by calling itself with the parameter rotate set to true.
 * 
 * @param pageSize the page size for which to guess the correct format
 * @param rotate Whether we should try to rotate the size befor guessing the format
 * @return <code>True</code> if the format was guessed, <code>false/<code> otherwise
 */
private boolean guessFormat(Rectangle pageSize, boolean rotate) {
    if (rotate) {
        pageSize = pageSize.rotate();
    }
    if (rectEquals(pageSize, PageSize.A3)) {
        pageWidth = 16837;
        pageHeight = 23811;
        landscape = rotate;
        return true;
    }
    if (rectEquals(pageSize, PageSize.A4)) {
        pageWidth = 11907;
        pageHeight = 16840;
        landscape = rotate;
        return true;
    }
    if (rectEquals(pageSize, PageSize.A5)) {
        pageWidth = 8391;
        pageHeight = 11907;
        landscape = rotate;
        return true;
    }
    if (rectEquals(pageSize, PageSize.A6)) {
        pageWidth = 5959;
        pageHeight = 8420;
        landscape = rotate;
        return true;
    }
    if (rectEquals(pageSize, PageSize.B4)) {
        pageWidth = 14570;
        pageHeight = 20636;
        landscape = rotate;
        return true;
    }
    if (rectEquals(pageSize, PageSize.B5)) {
        pageWidth = 10319;
        pageHeight = 14572;
        landscape = rotate;
        return true;
    }
    if (rectEquals(pageSize, PageSize.HALFLETTER)) {
        pageWidth = 7927;
        pageHeight = 12247;
        landscape = rotate;
        return true;
    }
    if (rectEquals(pageSize, PageSize.LETTER)) {
        pageWidth = 12242;
        pageHeight = 15842;
        landscape = rotate;
        return true;
    }
    if (rectEquals(pageSize, PageSize.LEGAL)) {
        pageWidth = 12252;
        pageHeight = 20163;
        landscape = rotate;
        return true;
    }
    if (!rotate && guessFormat(pageSize, true)) {
        int x = pageWidth;
        pageWidth = pageHeight;
        pageHeight = x;
        return true;
    }
    return false;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:77,代码来源:RtfPageSetting.java


注:本文中的com.lowagie.text.Rectangle.rotate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。