2 回答

TA貢獻1828條經驗 獲得超4個贊
com.lowagie.text.Document對象的構建函數有三個,分別是:
public Document();
public Document(Rectang
le pageSize);
public Document(Rectangle pageSize,
int marginLeft,
int marginRight,
int marginTop,
int marginBottom);
構建函數的參數pageSize是文檔頁面的大小,對于第一個構建函數,頁面的大小為A4,同Document(PageSize.A4)的效果一樣; 對于第三個構建函數,參數marginLeft、marginRight、marginTop、marginBottom分別為左、右、上、下的頁邊距。
通過參數pageSize可以設定頁面大小、面背景色、以及頁面橫向/縱向等屬性。iText定義了A0-A10、AL、LETTER、 HALFLETTER、_11x17、LEDGER、NOTE、B0-B5、ARCH_A-ARCH_E、FLSA 和FLSE等紙張類型,也可以通過Rectangle pageSize = new Rectangle(144, 720);自定義紙張。通過Rectangle方法rotate()可以將頁面設置成橫向。

TA貢獻1833條經驗 獲得超4個贊
/** This is the a4 format */
public static final Rectangle A4 = new RectangleReadOnly(595,842);
/**
* Constructs a <CODE>RectangleReadOnly</CODE>-object starting from the origin
* (0, 0).
*
* @param urx upper right x
* @param ury upper right y
*/
public RectangleReadOnly(final float urx, final float ury) {
super(0, 0, urx, ury);
}
595的單位是像素。
添加回答
舉報