2 回答

TA貢獻(xiàn)1828條經(jīng)驗 獲得超4個贊
com.lowagie.text.Document對象的構(gòu)建函數(shù)有三個,分別是:
public Document();
public Document(Rectang
le pageSize);
public Document(Rectangle pageSize,
int marginLeft,
int marginRight,
int marginTop,
int marginBottom);
構(gòu)建函數(shù)的參數(shù)pageSize是文檔頁面的大小,對于第一個構(gòu)建函數(shù),頁面的大小為A4,同Document(PageSize.A4)的效果一樣; 對于第三個構(gòu)建函數(shù),參數(shù)marginLeft、marginRight、marginTop、marginBottom分別為左、右、上、下的頁邊距。
通過參數(shù)pageSize可以設(shè)定頁面大小、面背景色、以及頁面橫向/縱向等屬性。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()可以將頁面設(shè)置成橫向。

TA貢獻(xiàn)1833條經(jīng)驗 獲得超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的單位是像素。
添加回答
舉報