本文整理匯總了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);
}
示例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;
}
示例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;
}
示例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;
}