wuyou

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();
    }

}

 

分类:

技术点:

相关文章:

  • 2021-09-19
  • 2022-01-08
  • 2021-12-05
  • 2021-11-17
  • 2021-09-27
  • 2021-11-03
  • 2021-10-31
  • 2021-11-04
猜你喜欢
  • 2021-09-10
  • 2021-12-28
  • 2021-12-09
  • 2021-10-08
  • 2021-11-17
  • 2019-11-25
相关资源
相似解决方案