java导出word、pdf之添加页眉----页眉(指定格式,包括图片和文字)

doc.open();

// 添加页眉
   Image headerImage = Image.getInstance("f:\\1.jpg");
   headerImage.scaleAbsolute(36, 36);
   Paragraph headerPara1 = new Paragraph();
headerPara1.setAlignment(HeaderFooter.ALIGN_CENTER);
   Phrase headerPara = new Phrase();
   /**
    * 插入表格 三列二行
    */
   Table table = new Table(3);
   int width[] = { 2, 10, 6 };
   table.setWidths(width);
   table.setBorderWidth(1);
   table.setBorder(0);
   table.setBorderColor(Color.BLACK);
   table.setPadding(0);
   table.setSpacing(0);

   table.setWidth(100);
   Cell cell = new Cell(headerImage);// 单元格
   cell.setBorderWidth(0f); // 设置表格没有边框
   cell.setBorderWidthBottom(1);
   cell.setHeader(true);
   cell.setRowspan(2);// 当前单元格占两行,纵向跨度
   cell.setVerticalAlignment(Element.ALIGN_LEFT);
   table.addCell(cell);

   Cell cell

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值