iText API操作doc文件

2021-07-30 05:00:57 字數 2282 閱讀 3940

public void createdoccontext(string file) throws documentexception,ioexception ;       

atable.setwidths(width);// 設定每列所佔比例

atable.setwidth(90); // 佔頁面寬度 90%

atable.setalignment(element.align_center);// 居中顯示

atable.setalignment(element.align_middle);// 縱向居中顯示

atable.setautofillemptycells(true); // 自動填滿

atable.setborderwidth(1); // 邊框寬度

atable.setbordercolor(new color(0, 125, 255)); // 邊框顏色

atable.setpadding(2);// 襯距,看效果就知道什麼意思了

atable.setspacing(3);// 即單元格之間的間距

atable.setborder(2);// 邊框 // 設定表頭

cell hadercell = new cell("**表頭");

hadercell.setheader(true);

hadercell.setcolspan(3);

atable.addcell(hadercell);

atable.endheaders();

font fontchinese = new font(bfchinese, 12, font.normal, color.green);

cell cell = new cell(new phrase("這是乙個測試的 3*3 table 資料", fontchinese));

cell.setverticalalignment(element.align_top);

cell.setbordercolor(new color(255, 0, 0));

atable.addcell(cell);

atable.addcell(new cell(img));

atable.addcell(new cell(img));

atable.addcell(new cell(img));

atable.addcell(new cell(img));

atable.addcell(new cell(img));

cell cell3 = new cell(new phrase("一行三列資料"));

cell3.setcolspan(3);

cell3.setverticalalignment(element.align_center);

atable.addcell(cell3);

document.add(atable);

document.add(new paragraph("\n"));

// 新增 image.getinstance即可以放路徑又可以放二進位制位元組流

image img1 = image.getinstance("d:\\1100002361095.png");

img.setabsoluteposition(0, 0);

img.setalignment(image.right);// 設定顯示位置

60);// 直接設定顯示尺寸

// img.scalepercent(50);//表示顯示的大小為原尺寸的50%

// img.scalepercent(25, 12);//影象高寬的顯示比例

// img.setrotation(30);//影象旋轉一定角度

document.add(img);

document.close();

}

public static void main(string args) catch (documentexception e) catch (ioexception e)

}

doc文件轉換為pdf文件

doc格式檔案轉換為pdf檔案 doc檔案向pdf格式轉換還是比較容易的,主要通過adobe 公司提供的adobe distiller虛擬伺服器實現的,在安裝了adobe acrobat完全版後,在windows系統的印表機任務中就會新增乙個acrobat distiller印表機.現在比較流行的d...

doc文件轉換為pdf文件

doc格式檔案轉換為pdf檔案 doc檔案向pdf格式轉換還是比較容易的,主要通過adobe 公司提供的adobe distiller虛擬伺服器實現的,在安裝了adobe acrobat完全版後,在windows系統的印表機任務中就會新增乙個acrobat distiller印表機.現在比較流行的d...

ubuntu下的doc文件

linux下的手冊不光有man,man手冊使用是很方便,在命令下,配合著grep顯得很好用,不過用慣了滑鼠的人則比較喜歡用html文件。linux下的手冊預設安裝的地方在 usr share doc,或者 usr local share doc裡面,在linux裡面大部分程式都提供了比較完善的手冊。...