你在操作pdf文件??有代码没??

解决方案 »

  1.   

    我操作的不是pdf格式,是打算做成word的形式,不过卡在这里不能下去了。
      

  2.   

    Document document = new Document(PageSize.A4, 80, 70, 70, 70);//创建一个文件时,定义上、下、左、右页边距
    RtfWriter docWriter = null;
    output=new FileOutputStream(filepath+".doc");
    docWriter = RtfWriter.getInstance(document,output);
    document.open();
    HeaderFooter footer = new HeaderFooter(new Phrase(""), true);
    footer.setAlignment(1);
    document.setFooter(footer);
    Paragraph paragraph1 = new Paragraph("陕西省专家推荐书",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 18));
    paragraph1.setAlignment(1);
    document.add(paragraph1);
      System.out.println("expertBean.getExpertKey()"+expertBean.getExpert_name());
    float[] widths= {
      20f, 20f, 20f, 20f, 20f, 20f};
    Paragraph paragraph2 = new Paragraph("一、专家基本信息表",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 18));
    paragraph2.setAlignment(1);
    document.add(paragraph2);
    Table table = new Table(6);
    table.setWidths(widths);
    table.setBorderWidth(1);
    table.setBorderColor(new Color(0, 0, 255));
    table.setDefaultVerticalAlignment(1);
    table.setDefaultHorizontalAlignment(1);
    Cell expert_man = new Cell(new Paragraph("专家姓名",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_man.setRowspan(2);
          System.out.println("expertBean.getGender().trim()"+expertBean.getGender().trim());
    table.addCell(expert_man);
    Cell expert_man1 = new Cell(new Paragraph(expertBean.getExpert_name().trim()+"",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_man1.setRowspan(2);
    table.addCell(expert_man1);
    Cell expert__gendar = new Cell(new Paragraph("性别",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert__gendar.setRowspan(2);
    expert__gendar.setColspan(1);
    table.addCell(expert__gendar);
    Cell expert__gendar1 = new Cell(new Paragraph(expertBean.getGender().trim()+"",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert__gendar1.setRowspan(2);
    table.addCell(expert__gendar1);Cell expert__ecode = new Cell(new Paragraph("编码",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert__ecode.setRowspan(2);
    table.addCell(expert__ecode);
    Cell expert__ecode1 = new Cell(new Paragraph(expertBean.getExpertCode().trim(),FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert__ecode1.setRowspan(2);
    table.addCell(expert__ecode1);
    Cell expert__nation = new Cell(new Paragraph("民族",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert__nation.setRowspan(2);
    table.addCell(expert__nation);
    Cell expert__nation1 = new Cell(new Paragraph(expertBean.getNation().trim(),FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert__nation1.setRowspan(2);
    table.addCell(expert__nation1);
    Cell party = new Cell(new Paragraph("党派",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    party.setRowspan(2);
    table.addCell(party);
    Cell expert__party = new Cell(new Paragraph(expertBean.getParty(),FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
      expert__party.setRowspan(2);
    table.addCell(expert__party);
    Cell expert_borndate = new Cell(new Paragraph("出生时间",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_borndate.setRowspan(2);
    table.addCell(expert_borndate);
    Cell expert_borndate1 = new Cell(new Paragraph(expertBean.getBornDate().trim(),FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_borndate1.setRowspan(2);
    table.addCell(expert_borndate1);
          Cell expert_graduatedate = new Cell(new Paragraph("毕业时间",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_graduatedate.setRowspan(2);
    table.addCell(expert_graduatedate);
    Cell expert_graduatedate1 = new Cell(new Paragraph(expertBean.getGraduateDate().trim(),FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_graduatedate1.setRowspan(2);
    table.addCell(expert_graduatedate1);
      

  3.   

    Cell expert_specScholarship = new Cell(new Paragraph("专业学术成就",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_specScholarship.setRowspan(6);
    table.addCell(expert_specScholarship);
    Cell expert_specScholarship1 = new Cell(new Paragraph(expertBean.getSpecScholarship().trim(),FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_specScholarship1.setRowspan(6);
    expert_specScholarship1.setColspan(5);
    table.addCell(expert_specScholarship1);
     Cell expert_shoulder = new Cell(new Paragraph("担任省评情况",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_shoulder.setRowspan(6);
    table.addCell(expert_shoulder);
    Cell expert_shoulder1 = new Cell(new Paragraph(expertBean.getShoulder().trim(),FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    expert_shoulder1.setRowspan(6);
    expert_shoulder1.setColspan(5);
    table.addCell(expert_shoulder1);
    Cell re = new Cell(new Paragraph("备注",FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    re.setRowspan(6);
    table.addCell(re);
    Cell re1 = new Cell(new Paragraph(expertBean.getRe().trim(),FontFactory.getFont(FontFactory.COURIER_BOLDOBLIQUE, 10.5f)));
    re1.setRowspan(6);
    re1.setColspan(5);
    table.addCell(re1);
     document.add(table);
     document.close();
    output.close();
          System.gc();
      

  4.   

    程序很长
    document.add(table); 
    这句话有问题