public static final String filename = " F://demo . pdf ";
公共靜態void main(String[] args)拋出IOException,
文檔異常{
Document文檔=新文檔(新矩形(400,400));
pdf writer writer = pdf writer . getinstance(document,new file output stream(filename));
document . open();
PdfContentByte CB = writer . getdirectcontent();
String content = "hello word!";
CB . begin text();
Font f = new Font();
f . setsize(18);
短語p =新短語(內容,f);
//(100,200)是X,Y坐標45是偏移角度字體的演示設置。
ColumnText.showTextAligned(cb,0,p,100,200,45);
CB . end text();
document.close()。
}
}