如题

解决方案 »

  1.   

    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/msword;charset=GBK");PrintWriter out = response.getWriter();out.print(docStr);
    docStr是html语言写的表格。现在画出来的表格在打印预览时页边距比较偏右,打印出来效果不佳,请高手解惑如何用Java设置Word的左右页边距长度。
      

  2.   

    Document document = new Document(PageSize.A4);
      int leftSpace=54;
      int rightSpace=54;
                      String tx10 = ft.getFormfileTextContent();
      Paragraph p15 = new Paragraph(tx10, conten);
      p15.setFirstLineIndent(40);// 首行缩进
      p15.setAlignment(Paragraph.ALIGN_JUSTIFIED);// 对齐方式
      p15.setLeading(20);// 行间距
      p15.setIndentationLeft(leftSpace);// 左边距,右边距
      p15.setIndentationRight(rightSpace);
      document.add(p15);