IText 生成横向的doc文档

IText生成doc文档需要三个包:iTextAsian.jar,iText-rtf-2.1.4.jar,iText-2.1.4.jar

亲测无误,代码如下:

import com.lowagie.text.*;

import com.lowagie.text.Rectangle;

import com.lowagie.text.rtf.RtfWriter2;





import java.io.FileOutputStream;



/**

 * 纸张方向横向测试

 * User: HYY

 * Date: 13-8-1

 * Time: 下午9:54

 * To change this template use File | Settings | File Templates.

 */

public class RotatePageTest {

  

    public static void main(String[] args) throws Exception {

        //设置纸张的大小对象

        Rectangle rectangle = new Rectangle(PageSize.A4);

        // 创建word文档,并旋转,使其横向

        Document document = new Document(rectangle.rotate());



        RtfWriter2.getInstance(document, new FileOutputStream("C:/無幽之路IText教程.doc"));

        document.open();

        document.close();

    }



}

 

你可能感兴趣的:(itext)